Error caused by missing stan header

I’m able to compile your model in cmdstanR, which uses a more recent version of Stan, so I’d recommend that you run your models through that in the mean time.

The Getting Started guide is available here: https://mc-stan.org/cmdstanr/articles/cmdstanr.html

But many people are running into issues with getting it installed and up-and-running.

Here’s what worked for me:

Install the mingw32-make package and update the PATH:

processx::run(
    "pacman",
    args = c("-Syu", "mingw-w64-x86_64-make","--noconfirm"),
    wd = file.path(Sys.getenv("RTOOLS40_HOME"), "usr", "bin"),
    echo = TRUE
)
write('PATH="${RTOOLS40_HOME}\\usr\\bin;${RTOOLS40_HOME}\\mingw64\\bin;${PATH}"', file = "~/.Renviron", append = FALSE)

Restart R and run:

install.packages("cmdstanr", repos = c("https://mc-stan.org/r-packages/", getOption("repos")))

library(cmdstanr)
install_cmdstan()

If the install_cmdstan() finishes without an error, then you’re good to start running models. If it does error, try running:

setwd(".cmdstanr/cmdstan-2.24.1/")
processx::run(
    "mingw32-make",args="clean"
)
processx::run(
    "mingw32-make",args=c("-j4","build"),
    echo=T
)

If that runs without an error, then restart R and you’re ready to run your Stan model!

1 Like