Fatal error when installing older version of RStan

I tried to install a specific version of rstan with:

remotes::install_version(package = "rstan", version = "2.21.8")

And I encountered the error:
chains.cpp:19:10: **fatal error:**stan/math/prim/mat/fun/mean.hpp:No such file or directory

#include <stan/math/prim/mat/fun/mean.hpp>

^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Could be related to the StanHeader version? Although, installing the latest version of StanHeader did not help, either. My Operating System is Rocky Linux 8.9 (Green Obsidian), Platform: x86_64-redhat-linux-gnu (64-bit), with R version 4.3.3

Many thanks in advance for any suggestions :)

If you want to install an older version of rstan, then you also need to install an older version of StanHeaders.

For rstan 2.21.8, you would need StanHeaders 2.21.0-7:

remotes::install_version(package = "StanHeaders", version = "2.21.0-7")
1 Like

This worked, thank you very much!

1 Like