Very new to Stan, recently updated to R 4.0 and Catalina (10.15.4), using RStudio 1.3.959.
Starting with @rcpedroso’s example from the dealing with R 4.0 thread:
# Load rstan
library(rstan)
# Set seed
set.seed(13)
# Make data
stan_data <- list(y = rnorm(500, 0, 1),
N = 500)
# Define model
stan_code <- "
/*
This model is just for testing.
*/
functions {
real times_two(real x) { // Custom function test.
return(x*2);
}
}
data {
int N; // Data length
vector[N] y; // Data
}
transformed data {
real a = 2.0; // Constant Test
}
parameters {
real<lower = 0> sigma; // Constraint test; residual SD
real mu; // Mean
}
transformed parameters {
real mu_over_sigma = mu / sigma; // Transformed param test.
}
model {
mu ~ normal(0, 1); // ~ syntax test.
target += student_t_lpdf(sigma | 5, 0, 1); // Increment test.
y ~ normal(mu, sigma); // Likelihood
}
generated quantities {
real b = normal_rng(0, 1); // RNG test
real c = times_two(a*b); // Custom Function test.
}
"
# Compile model
sm <- rstan::stan_model(model_code = stan_code)
Here’s the error I’m getting, which I also get when I try to run the code I’m trying to work with:
Error in dyn.load(libLFile) :
unable to load shared object ‘/var/folders/b0/gny_hdjx72b12pbflnfxfys80000gn/T//RtmpYLUfwq/filea498129bf44a.so’:
dlopen(/var/folders/b0/gny_hdjx72b12pbflnfxfys80000gn/T//RtmpYLUfwq/filea498129bf44a.so, 6): Symbol not found: __ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED1Ev
Referenced from: /var/folders/b0/gny_hdjx72b12pbflnfxfys80000gn/T//RtmpYLUfwq/filea498129bf44a.so
Expected in: flat namespace
in /var/folders/b0/gny_hdjx72b12pbflnfxfys80000gn/T//RtmpYLUfwq/filea498129bf44a.so
Error in sink(type = “output”) : invalid connection
Here’s what’s in Makevars:
VER=-9
CC=gcc${VER}
CXX=g++${VER}
CXX11=g++${VER}
CXX14=g++${VER}
CXX17=g++${VER}
CXX20=g++${VER}
CFLAGS=-isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk
CCFLAGS=-isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk
CXXFLAGS=-isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk
CPPFLAGS=-isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk
FLIBS=-I/usr/local/Cellar/gcc/9.3.0_1/lib/gcc/9/
FC=gfortran${VER}
F77=gfortran${VER}
All I have in my Renviron file is:
MAKEFLAGS=-j8
I’ve confirmed that I’m up to date on XCode/command line tools.
I’m sure there’s something really silly buried in here that I’m just not seeing, but having read through a bunch of these threads tried all of the recommendations I’ve seen for Mac users I’m really at a loss. I’m also not sure whether this is a dealing with R 4.0 issue or a dealing with Catalina issue, though I suspect the latter.
Any help would be fantastic!