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

Hi,

As the title indicates, when I run the the example (8 schools) code as below, the error regarding prep_call_sampler(object) appears. Please note that before I submitted this ticket, I did a quick check online, for a*b within the model, it has been specified as a * b, and my operation system is Win 10.

Thanks for your input in advance.

The prep_call_sampler function comes with the rstan package


so there is no way it cannot be found when the rstan package is installed properly.
My guess is that rstan was installed while a previous rstan was loaded or else there were stanfit or stanmodel objects from a previous version of rstan in R’s global environment when you tried to install the new rstan or something else weirdly specific to that laptop. I would suggest closing all R sessions, opening up a new one without bringing in any stanfit or stanmodel objects (including those in the .RData file) and calling

remove.packages("rstan")

then do

install.packages("https://win-builder.r-project.org/jpMlFHwQs41q/rstan_2.19.1.zip", repos = NULL)

again.

Hi Ben,

Thank you so much!

Believe or not, I did not delete or remove anything. Just rerun the statement as I did last night at home. It works now…

I am really sick of it…

Ben, thank you so much for your continuous and instant input and help!!!

Chuanwu

Hi, I’m having the same issue 'prep_call_sampler(object): could not find function “prep_call_sampler”. I’ve tried uninstalling and reinstalling R, RStudio, rstan, to no avail. it won’t even run the example script. I was running some models last night, woke up today, tried to run the same model, all of a sudden nothing works. Are there any other solutions? Thanks ahead of time!

Running:
R Version 4.3.0 GUI 1.79 Big Sur Intel build
RStudio Version 2023.03.1+446 (2023.03.1+446)
RStan Version 2.21

Oddly, when I use the ‘Ulam’ function from Richard McElreath’s Rethinking package, Stan runs. But it won’t run the example function, or when I use the combo of compiling (stan_model) with sampling().

One more update. When I open a new R project the example stan script works. but not in the one that I am currently using.

Hi, I noticed that you encountered the same issue I’m currently facing. May I ask if you have resolved this problem? I would greatly appreciate it if you could share your solution with me. Thank you very much in advance.