# Error in prep\_call\_sampler(object) : could not find function "prep\_call\_sampler"

**URL:** <https://discourse.mc-stan.org/t/error-in-prep-call-sampler-object-could-not-find-function-prep-call-sampler/17844>\
**Category:** General\
**Created:** [September 3, 2020, 11:11pm UTC](https://discourse.mc-stan.org/t/error-in-prep-call-sampler-object-could-not-find-function-prep-call-sampler/17844 "2020-09-03T23:11:13Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![dkaplan](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/dkaplan/32/13835_2.png) [@dkaplan](https://discourse.mc-stan.org/u/dkaplan)\
**Post date:** [September 3, 2020, 11:11pm UTC](https://discourse.mc-stan.org/t/error-in-prep-call-sampler-object-could-not-find-function-prep-call-sampler/17844/1 "2020-09-03T23:11:13Z")

</div>

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);  
}  
}

"

---

<div class="post-metadata">

**Author:** ![bgoodri](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/bgoodri/32/4451_2.png) [@bgoodri](https://discourse.mc-stan.org/u/bgoodri)\
**Post date:** [September 4, 2020, 3:12am UTC](https://discourse.mc-stan.org/t/error-in-prep-call-sampler-object-could-not-find-function-prep-call-sampler/17844/2 "2020-09-04T03:12:07Z")

</div>

R 4.0.x or R 3.x?

---

<div class="post-metadata">

**Author:** ![dkaplan](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/dkaplan/32/13835_2.png) [@dkaplan](https://discourse.mc-stan.org/u/dkaplan)\
**Post date:** [September 4, 2020, 2:20pm UTC](https://discourse.mc-stan.org/t/error-in-prep-call-sampler-object-could-not-find-function-prep-call-sampler/17844/3 "2020-09-04T14:20:19Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![jonah](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/jonah/32/200_2.png) [@jonah](https://discourse.mc-stan.org/u/jonah)\
**Post date:** [September 4, 2020, 9:23pm UTC](https://discourse.mc-stan.org/t/error-in-prep-call-sampler-object-could-not-find-function-prep-call-sampler/17844/4 "2020-09-04T21:23:57Z")

</div>

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.
