Hello!
Very new to RStan; so new that I haven’t been able to get it to work. Below is some code from a tutorial I found on line produced by Rasmus Baath:
library(rstan)
The Stan model as a string
model_string<- "
data {
// Number of trials
int nA;
int nB;
// Number of successes
int sA;
int sB;
}
parameters {
real<lower=0, upper=1> rateA;
real<lower=0, upper=1> rateB;
}
model {
rateA ~ uniform(0,1);
rateB ~ uniform(0,1);
sA ~ binomial(nA,rateA);
sB ~ binomial(nB,rateB);
}
generated quantities {
real rate_diff;
rate_diff= rateB-rateA;
}
"
data_list <- list(nA=16, nB=16, sA=6, sB=10)
Compiling and producing posterior samples from the model
stan_samples <-stan(model_code=model_string, data=data_list)
###################################################
When I run the above code, I get the following error messages:
Error in file(con, "r") : cannot open the connection
In addition: Warning messages:
1: In system(cmd, intern = !verbose) :
running command CMD SHLIB file340c3f4110d1.cpp 2> file340c3f4110d1.cpp.err.txt' had status 1
2: In file(con, "r") :
cannot open file 'file340c3f4110d1.cpp.err.txt': No such file or directory
Error in sink(type = "output") : invalid connection
I assum this means I need file340c3f4110d1.cpp.err.txt, but I can’t find it and I don’t know where I got it or if I can get it again if somehow I had it and now I don’t. At this point, I’m wondering if I can get this file somewhere, or if this can only be fixed by removing all r and rstudio and start from scratch. Any recommendations would be very much appreciate it.
I’m not quite sure I understand your question, but here goes.
This line:
stan_samples <-stan(model_code=model_string, data=data_list)
resulted in this error message:
Error in file(con, “r”) : cannot open the connection
In addition: Warning messages:
1: In system(cmd, intern = !verbose) :
running command ‘[]*****/bin/x64/R) CMD SHLIB file340c3f4110d1.cpp 2> file340c3f4110d1.cpp.err.txt’ had status 1
2: In file(con, “r”) :
cannot open file ‘file340c3f4110d1.cpp.err.txt’: No such file or directory
Error in sink(type = “output”) : invalid connection
I think I understand now. I fan your code (i.e., example(stan_model, package = “rstan”, run.dontrun = TRUE))
Here is the line that includes error:
Error in file(con, “r”) : cannot open the connection
In addition: Warning message:
In file(con, “r”) :
cannot open file ‘file4e4021452a4b.cpp.err.txt’: No such file or directory
So I guess i need file4e4021452a4b.cpp.err.txt but I can’t find it.
There are a lot of difficulties when you install packages in network-mounted home directories on Windows. It is better to install them where R is installed.
Ok. So, it sounds like I need to uninstall and reinstall and have install packages directly on the machine? Or can I simply move the R folder to the computer?
Thank you very much, by the way, for coaching me through this. I appreciate it.