Problem running Rstan 2.19.3 in R version 4.0.1

Welcome to the forums!

This is a bit of a known error, where the compiler flag for including that Eigen.hpp file isn’t in quotations, so filenames with spaces cause an error. You can see this in your output:

“g++.exe: error: Graham/Documents/R/win-library/4.0/StanHeaders/include/stan/math/prim/mat/fun/Eigen.hpp

Where the filename starts with ‘Graham’, rather than ‘C:/Users/Patrick Graham’.

One workaround is to not load the RStan library, and just use the rstan:: qualifier instead.

So rather than:

library(rstan)
stan(model, data)

Use:

rstan::stan(model, data)

As this causes the Eigen.hpp file to be included in a different way (more info here)

2 Likes