I installed rstan successfully, but when stan was compiling my model, I got “Error in path.expand(path) : invalid ‘path’ argument”.
How were you calling it?
What do you mean?
When you call stan()
what were the arguments? Also, can you trigger the same error from doing rstan:::last_makefile()
?
Please see my model below, and when I ran ‘rstan:::last_makefile()’, I got “C:/Users/Henry/Documents/.R/Makevars.win”.
library(rstan)
smodel = "data {
int<lower=0> Ncohorts;
int<lower=0> Ntox[Ncohorts];
int<lower=0> Npat[Ncohorts];
vector[Ncohorts] DosesAdm;
int<lower=0> DoseRef;
}
parameters {
real logalphabeta1;
real logalphabeta2;
}
model {
logalphabeta1 ~ normal(-0.693, 2);
logalphabeta2 ~ normal(0, 1);
Ntox ~ binomial_logit(Npat, logalphabeta1 + exp(logalphabeta2)*log(DosesAdm/DoseRef));
}
"
stanm <- stan_model(model_code = smodel)
DosesAdm <- c(1, 2, 4, 8, 12, 16)
Npat <- c(3, 3, 3, 6, 6, 6)
Ntox <- c(0, 0, 0, 1, 1, 2)
Ncohorts <- length(DosesAdm)
DoseRef <- 16
data1 <- list(DosesAdm = DosesAdm, Npat = Npat, Ntox = Ntox, Ncohorts = Ncohorts,
DoseRef = DoseRef)
fit <- stan(file = stanm, data = data1, iter = 1000, chains = 1)
On the last line, I think you meant to call it as
fit <- sampling(stanm, data = data1, iter = 1000, chains = 1)
The first argument to the stan
function should be the path to a Stan program on disk, which is why there was an error.
It is working now. Thank you, bgoodri!