Hello, I am new to stan and I could not get the following simple measurement error model to sample.
I am using rstan_2.19.2, r version 3.6.1, under macOS Catalina 10.15.1
model {
data {
int <lower=0> N; \\ number of obs
vector[N] E; \\ obs error
vector[N] I_obs; \\ observations
}
parameters {
vector[N] I_true; \\ unknown true value
real I_tmu; \\ prior location
real<lower=0> sigma_t; \\ prior scale
}
model {
sigma_t ~ exponential(1);
I_tmu ~ normal(0,3);
I_true[N] ~ normal(I_tmu, sigma_t); \\ prior
I_obs ~ normal(I_true, E); \\ measurement model
}
"
the error message was
model{
starting worker pid=10312 on localhost:11250 at 17:55:58.824
starting worker pid=10326 on localhost:11250 at 17:55:59.195
starting worker pid=10340 on localhost:11250 at 17:55:59.549
starting worker pid=10354 on localhost:11250 at 17:55:59.932
SAMPLING FOR MODEL '68b329da9893e34099c7d8ad5cb9c940' NOW (CHAIN 1).
[1] "Error in sampler$call_sampler(args_list[[i]]) : "
[2] " Must use algorithm=\"Fixed_param\" for model that has no parameters."
error occurred during calling the sampler; sampling not done
SAMPLING FOR MODEL '68b329da9893e34099c7d8ad5cb9c940' NOW (CHAIN 2).
[1] "Error in sampler$call_sampler(args_list[[i]]) : "
[2] " Must use algorithm=\"Fixed_param\" for model that has no parameters."
error occurred during calling the sampler; sampling not done
SAMPLING FOR MODEL '68b329da9893e34099c7d8ad5cb9c940' NOW (CHAIN 3).
[1] "Error in sampler$call_sampler(args_list[[i]]) : "
[2] " Must use algorithm=\"Fixed_param\" for model that has no parameters."
error occurred during calling the sampler; sampling not done
SAMPLING FOR MODEL '68b329da9893e34099c7d8ad5cb9c940' NOW (CHAIN 4).
[1] "Error in sampler$call_sampler(args_list[[i]]) : "
[2] " Must use algorithm=\"Fixed_param\" for model that has no parameters."
error occurred during calling the sampler; sampling not done
some chains had errors; consider specifying chains = 1 to debughere are whatever error messages were returned
[[1]]
Stan model '68b329da9893e34099c7d8ad5cb9c940' does not contain samples.
[[2]]
Stan model '68b329da9893e34099c7d8ad5cb9c940' does not contain samples.
[[3]]
Stan model '68b329da9893e34099c7d8ad5cb9c940' does not contain samples.
[[4]]
Stan model '68b329da9893e34099c7d8ad5cb9c940' does not contain samples.
starting worker pid=901 on localhost:11832 at 20:49:11.202
starting worker pid=915 on localhost:11832 at 20:49:11.510
starting worker pid=929 on localhost:11832 at 20:49:11.812
starting worker pid=943 on localhost:11832 at 20:49:12.126
SAMPLING FOR MODEL '68b329da9893e34099c7d8ad5cb9c940' NOW (CHAIN 1).
[1] "Error in sampler$call_sampler(args_list[[i]]) : "
[2] " Must use algorithm=\"Fixed_param\" for model that has no parameters."
error occurred during calling the sampler; sampling not done
SAMPLING FOR MODEL '68b329da9893e34099c7d8ad5cb9c940' NOW (CHAIN 2).
[1] "Error in sampler$call_sampler(args_list[[i]]) : "
[2] " Must use algorithm=\"Fixed_param\" for model that has no parameters."
error occurred during calling the sampler; sampling not done
SAMPLING FOR MODEL '68b329da9893e34099c7d8ad5cb9c940' NOW (CHAIN 3).
[1] "Error in sampler$call_sampler(args_list[[i]]) : "
[2] " Must use algorithm=\"Fixed_param\" for model that has no parameters."
error occurred during calling the sampler; sampling not done
Thanks! So the problem is coming from this part of the stan call: fit = simple_model. The fit option is used with existing stanfit objects (i.e. you’ve already compiled and fit a model and you want to re-estimate it).
You want to be using model_code = simple_model instead:
stan_model <- stan(model_code = simple_model, data = samp_list, cores = 4, chains = 4, warmup = 500, iter = 1e4)