Package ‘rstan’ is not available (for R version 4.0.2)


I was trying to install rstan but it shows that the package is not available for y current R version. Is it possible that rstan will be available for R 4.0.2 soon or I need to change R to older version to use it?


That’s strange, rstan is definitely available for R 4.0.2. Which operating system do you have and do you know which CRAN mirror you are using with install.packages()? (I think getOption("repos") will tell you.)

Hi Thanks for your reply. The following is what I got:

[1] TRUE


That looks fine, so this is pretty strange! Which operating system are you using?

@bgoodri Any idea why it would say rstan is not available for R 4.0.2 from the rstudio CRAN mirror?

Hi, I just fixed it. When I executed the following command, it asked me if I want to install something compiled? If I say yes, then the error “not available occurs” if later I want to library it, but if I say no, there is no error. But after I ran my code, the following error related to initialization occurs, any ideas why? Thanks!

install.packages(“rstan”, repos = “”, dependencies = TRUE)

Chain 1: Rejecting initial value:
Chain 1: Log probability evaluates to log(0), i.e. negative infinity.
Chain 1: Stan can’t start sampling from this initial value.
Chain 1:
Chain 1: Initialization between (-2, 2) failed after 100 attempts.
Chain 1: Try specifying initial values, reducing ranges of constrained values, or reparameterizing the model.
[1] “Error in sampler$call_sampler(args_list[[i]]) : Initialization failed.”
[2] “In addition: Warning messages:”
[3] “1: In system2(CXX, args = ARGS) : error in running command”
[4] “2: In file.remove(c(unprocessed, processed)) :”
[5] " cannot remove file ‘/var/folders/5x/rxc8hsw96rvblp_118zbchwh0000gn/T//RtmpIJxN8x/file3d942d4c2ee.stan’, reason ‘No such file or directory’"
error occurred during calling the sampler; sampling not done

1 Like

That’s at least some good news since it looks like it’s trying to run but is having trouble initializing (that’s better than failing to install!).

Regarding initialization, are you running one of the Stan examples or one of your own models? Do you mind starting a new topic here on the forums with a title about initialization failing? That way you’ll get more eyes on your question. When you do that can you share your Stan code? Even better would be to also include data (real or fake) if possible so that people can try running your example and help you troubleshoot it. But at a minimum include the Stan code.

Thanks! I’m running my own model and I just created another topic with my code attached.