I have been running Rstan on my mac one month ago and now when I try, the exact same code is failing. So I went back to the popular example:
library(rstan)
model_code <- 'data {
int<lower=0> J; // number of schools
real y[J]; // estimated treatment effects
real<lower=0> sigma[J]; // standard error of effect estimates
}
parameters {
real mu; // population treatment effect
real<lower=0> tau; // standard deviation in treatment effects
vector[J] eta; // unscaled deviation from mu by school
}
transformed parameters {
vector[J] theta = mu + tau * eta; // school treatment effects
}
model {
target += normal_lpdf(eta | 0, 1); // prior log-density
target += normal_lpdf(y | theta, sigma); // log-likelihood
}'
schools_dat <- list(J = 8,
y = c(28, 8, -3, 7, -1, 1, 18, 12),
sigma = c(15, 10, 16, 11, 9, 11, 10, 18))
m<- stan_model(model_code = model_code ,verbose = TRUE)
Everything above runs without any issues but when i try running the sampling
line below the Rstudio crashes.
fit1 <- sampling(m, data = schools_dat,chains = 1)
I tried running this many times but every time the R-studio crashes. Can you please help me?
Makevars file :
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 -I/usr/local/include
SHLIB_CXXLDFLAGS+=-Wl,-rpath,/Library/Frameworks/R.framework/Resources/lib /Library/Frameworks/R.framework/Resources/lib/libc++abi.1.dylib
SHLIB_CXX11LDFLAGS+=-Wl,-rpath,/Library/Frameworks/R.framework/Resources/lib /Library/Frameworks/R.framework/Resources/lib/libc++abi.1.dylib
SHLIB_CXX14LDFLAGS+=-Wl,-rpath,/Library/Frameworks/R.framework/Resources/lib /Library/Frameworks/R.framework/Resources/lib/libc++abi.1.dylib
CXX14FLAGS=-O3 -march=native -mtune=native
CXX14FLAGS += -arch x86_64 -ftemplate-depth-256
OS : macOS Catalina 10.15.6.
R Studio version is 1.2.5001 and R version details are as below.
R.Version()
$platform
[1] "x86_64-apple-darwin15.6.0"
$arch
[1] "x86_64"
$os
[1] "darwin15.6.0"
$system
[1] "x86_64, darwin15.6.0"
$status
[1] ""
$major
[1] "3"
$minor
[1] "6.3"
$year
[1] "2020"
$month
[1] "02"
$day
[1] "29"
$`svn rev`
[1] "77875"
$language
[1] "R"
$version.string
[1] "R version 3.6.3 (2020-02-29)"
$nickname
[1] "Holding the Windsock"