For me that page goes to a Google login that is hosted by RStudio. Unfortunately, Stan is not going to work on your computer until the thing with the paths is resolved so that it can find the configuration files correctly.
Possibly (re)installing R to a typical directory such as C:\R
will help rather than the network share drive that it appears to be installed on.
I have tried to fix this on GitHub. Can you try
devtools::install_github("stan-dev/rstan", ref = "develop", subdir = "rstan/rstan")
library(rstan)
to see if it gets past that error.
Thanks for the follow-up
It says
Error in loadNamespace(name) : there is no package called ‘devtools’
Okay, I have downloaded the devtools, and ran the
devtools::install_github(“stan-dev/rstan”, ref = “develop”, subdir = “rstan/rstan”)
It says
These packages have more recent versions available.
Which would you like to update?
1: rlang (0.2.2 -> 0.3.0) [CRAN]
2: stringi (1.1.7 -> 1.2.4) [CRAN]
3: CRAN packages only
4: All
5: None
Enter one or more numbers separated by spaces, or an empty line to cancel
should i update all of them?
yeah
Okay! I ran the following code after installing the packages.
library(rstan)
rstan_options(auto_write = TRUE)
options(mc.cores = parallel::detectCores())
cat(
’
//saved as 8schools.stan
data {
int<lower=0> J; //number of schools
real y[J]; // estimated treatment effects
real<lower=0> sigma[J]; // s.e. of effect estimates
}
parameters {
real mu;
real<lower=0> tau;
real eta[J];
}
transformed parameters {
real theta[J];
for (j in 1:J)
theta[j] = mu + tau * eta[j];
}
model {
target += normal_lpdf(eta | 0, 1);
target += normal_lpdf(y | theta, sigma);
}
',
file = “8school.stan”, sep="", fill=T)
#------------------------------------------------------------
#Prepare the data in R
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 the model to data
fit <- stan(file = ‘8school.stan’, data = schools_dat,
iter = 1000, chains = 4)
And got the error :
Error in if (grepl(pattern, makefile_txt[i])) { : argument is of length zero
which is the same error I got initially.
What’s happening?
After my last conversation, yesterday I installed R, RStudio and Rtools into C:\ drive (not to program file).
Thanks
I am not understanding this. In
out <- system2(file.path(Sys.getenv("R_HOME"), "bin", "R"),
args = "CMD SHLIB --dry-run", stdout = TRUE)
out <- grep("SHLIB", out, value = TRUE)
out
is " make -f “C:/PROGRA~1/R/R-35~1.1/etc/x64/Makeconf” -f “C:/PROGRA~1/R/R-35~1.1/share/make/winshlib.mk” -f “//…/documents/StaffHome/StaffGroups$/…/Documents/.R/Makevars” SHLIB="" WIN=64 TCLBIN=64 OBJECTS="""
right?
the out put for the “out” is:
" make -f "C:/R-35~1.1/etc/x64/Makeconf" -f "C:/R-35~1.1/share/make/winshlib.mk" -f "//…/documents/StaffHome/StaffGroups$/…/Documents/.R/Makevars" SHLIB="" WIN=64 TCLBIN=64 OBJECTS="""
Apparently, the code worked from OneDrive and C drive.
Wondering what caused the error when I used my PC’s local Document drive ?
Thanks
The rstan 2.18.1 on CRAN can’t deal when that system2
line comes back with “UNC paths are not supported. Defaulting to Windows directory.” The rstan on GitHub ostensibly can.
I installed rstan using
install.packages(“rstan”, repos = “https://cloud.r-project.org/”, dependencies = TRUE)
as mentioned on https://github.com/stan-dev/rstan/wiki/Installing-RStan-on-Windows
Would you like to specify the alternative GitHub url which I can download rstan?
Thanks
devtools::install_github(“stan-dev/rstan”, ref = “develop”, subdir = “rstan/rstan”)
is the only one
Thanks @bgoodi. Appreciate your help very much.
I did try previously installing rstan from GitHub, as seen on this thread, but it did not work for me when i use my PC’s Document drive.
You mean you still get the Error in if (grepl(pattern, makefile_txt[i])) { : argument is of length zero
when rstan is installed from GitHub?
yes! i got the same error
This is mind-boggling to me. With the rstan installed from GitHub, what is
rstan:::get_makefile_txt()
Is it NULL or a bunch of strings?
Oh! I forgot the library(rstan)
part.
The code works now, after installing rstan from GitHub
Many thanks for all your help.
That is after doing a library(rstan)
?
It works. Thanks for your help