I am trying Stan for the first time. I specified a model but received the error:
Error in new_CppObject_xp(fields$.module, fields$.pointer, …) :
Exception: variable does not exist; processing stage=data initialization;
I looked at the similar questions and couldn’t get it to work. I decided to try a very simple comparison using the schools example on the stan page. The first method (fit1) works but the second (fit2) reproduces the error in my code. The associated .stan file is copied directly from the stan website. I am running RStudio on Google cloud in Linux (my poor laptop has another model running).
library("rstan") # observe startup messages 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)) # Compile the model compiled_model <- stan_model("schools.stan") fit1 <- stan(file = 'schools.stan', data = schools_dat) fit2 <- sampling(compiled_model, data_list = schools_dat)