Object 'stan_program' not found

Operating System:Windows 10
Interface Version:2.18.2
Compiler/Toolkit:

Hello,

I just downloaded and installed rstan for the first time and tried using it with a model that has worked for others, but I’m getting the following:

library(rstan);

fit ← stan(model_code=stan_program, data=c(“x”, “n”, “J”, “K”, “S”),

  •         control=list(stepsize=0.01, adapt_delta=0.95),
    
  •         chains=4, iter=5000, refresh=0, seed=12345);
    

Error in stan(model_code = stan_program, data = c(“x”, “n”, “J”, “K”, :
object ‘stan_program’ not found

I’m fairly new to this, so it could be a simple fix, but I cannot find anything to solve this issue. Thank you for your help!

This seems like a problem in R, not Stan. Do you see an object in R called “stan_program”?

I see rstan downloaded and installed inside rstudio. Is that what you’re asking?

I reinstalled R, Rstudio, and rstan today as well just in case something was corrupted or installed weird. But I had the same error after the re-installation of all three.

No, in RStudio you have an “environment” window in the top right of your screen (under default settings). It contains all the variables that you have already declared. Before running the line that gives you trouble, you should check that there is a variable called “stan_program” there.

Right now your code calls the function “stan” using the argument “model_code = stan_program”. So the object “stan_program” must already exist (and be of the type that this function expects).

Ah, got it. Thank you for the help.

No worries, glad I could help :-)