Error in prep_call_sampler(object) : could not find function "prep_call_sampler"

Hi all,

I’m receiving the following error when running the code pasted below

Error in prep_call_sampler(object) : could not find function “prep_call_sampler”

I tried some of the suggestions indicated in a post in June 2019 and it didn’t work. I am running on a Mac with Catalina recently installed. I am using RStudio version 1.3.1073 and rstan version 2.21.2. The code is here

modelString = "
data {

int<lower=1> n; // number of students
int<lower=1> G; // number of schools
int schid[n]; // school indices
vector[n] ASRREA01; // reading outcome variable
vector[n] ASBG04;
vector[n] ACBG03A;

}

parameters {
vector[G] alpha;
vector[G] beta1;
real gamma00;
real gamma01;
real mu_beta1;
real<lower=0> sigma_alpha;
real<lower=0> sigma_beta1;
real<lower=0> sigma_read;
}

model{

gamma00 ~ normal(300,100);
gamma01 ~ normal(0, 5);
mu_beta1 ~ normal(0, 5);
sigma_read ~ cauchy(1,5);
sigma_alpha ~ cauchy(1,5);
sigma_beta1 ~ cauchy(1,5);

for(g in 1:G) {
alpha[g] ~ normal(gamma00 + gamma01 * ACBG03A[g], sigma_alpha);
beta1[g] ~ normal(mu_beta1, sigma_beta1);
}

for(i in 1:n) {
ASRREA01[i] ~ normal(alpha[schid[i]] + beta1[schid[i]] * ASBG04[i], sigma_read);
}
}

"

R 4.0.x or R 3.x?

That was it. Thanks. Everything seems to be working. However, strangely when I run the following code

multilevelM1 = stan(data=data.list,model_code=modelString,chains=nChains,
iter=nIter,warmup=burnInSteps,thin=thinSteps)

I get the message

Loading required package: blavaan
Loading required package: lavaan
This is lavaan 0.6-7
lavaan is BETA software! Please report any bugs.
Loading required package: Rcpp
This is blavaan 0.3-10
On multicore systems, we suggest use of future::plan(“multiprocess”) for faster post-MCMC computations.

These are programs that I do have installed, but I haven’t encountered this message until now and I am not running these programs. It’s not crashing anything, but it is weird.

David

Hmm, no idea why blavaan/lavaan is being loaded unless you’re loading them or one of the other packages you’re loading loads them. RStan definitely doesn’t, so something else must be going on.