Error in running rstan "8 schools" example


#1

Hi! I am new to rstan, I want to run the “8 schools” example in rtsan (Windows 7 x64 SP 1 , R version 3.5.1, rstan 2.18.2 ) with the code as follows.

library(rstan)
schools_dat <- list(J = 8, y = c(28, 8, -3, 7, -1, 1, 18, 12), sigma = c(15, 10, 16, 11, 9, 11, 10, 18))
fit <- stan(file = “schools.stan”, data = schools_dat)

The code is exactly copied from “RStan getting started” and schools.stan file is stored in my current working directory. However, I have got an error like this:

Error in process_initialize(self, private, command, args, stdin, stdout, : Command not found
In addition: Warning message:
In readLines(file, warn = TRUE) : incomplete final line found on ‘wd\schools.stan’
Error in sink(type = “output”) : invalid connection

Do you guys have any idea of this problem?


#2

It looks like it is some problem with the permissions. Can you try doing

stan_model("8schools.stan", verbose = TRUE)

and telling us what follows on the line that includes error: (with the colon)?


#3

Hi, Ben. The log and error are as follows.

TRANSLATING MODEL ‘8schools’ FROM Stan CODE TO C++ CODE NOW.
successful in parsing the Stan model ‘8schools’.
COMPILING THE C++ CODE FOR MODEL ‘8schools’ NOW.
OS: x86_64, mingw32; rstan: 2.18.2; Rcpp: 0.12.18; inline: 0.3.15
Error in process_initialize(self, private, command, args, stdin, stdout, :
Command not found
In addition: Warning message:
In readLines(file, warn = TRUE) :
incomplete final line found on ‘wd\8schools.stan’

Thanks!


#4

What does

pkgbuild::has_build_tools(debug = TRUE)

say?


#5

[1] TRUE

I have tried every line of “configuration code” in " RStan Getting Started" after I installed the package, but it seems that I am still in trouble. This is the desktop of my department, thing is just fine for my own Windows 10 laptop.


#6

Can you try running it outside of RStudio? The error message seems to be truncated

Error in process_initialize(self, private, command, args, stdin, stdout, : ???
Command not found

but does not say which command is not found.


#8

I have tried the example as well as the “rats” example in “RStan getting started” in RGui on the same desktop, and still got the error:

Error in process_initialize(self, private, command, args, stdin, stdout, : 
Command not found

It seems that I can only use STAN on my laptop for now.


#9

You might try updating Rcpp, it’s currently at version 1.0.0.

It’s working for me on Windows 7 and the same versions of R and rstan as yours.


#10

@bgoodri @pete Thank you guys, I have reinstalled R in another disk instead of C: disk, and it finally works! I think maybe it is due to the authorization of C: disk of our department desktop.