Rstan will inconsistently run on my computer. The problem seemed to be about Mac OS X Catalina and Rcpp but there is a new error message today:
"
Error in compileCode(f, code, language = language, verbose = verbose) :
Compilation ERROR, function(s)/method(s) not created! In file included from :1:
In file included from /Library/Frameworks/R.framework/Versions/4.0/Resources/library/StanHeaders/include/stan/math/prim/mat/fun/Eigen.hpp:4:
In file included from /Library/Frameworks/R.framework/Versions/4.0/Resources/library/RcppEigen/include/Eigen/Dense:1:
In file included from /Library/Frameworks/R.framework/Versions/4.0/Resources/library/RcppEigen/include/Eigen/Core:535:
/Library/Frameworks/R.framework/Versions/4.0/Resources/library/RcppEigen/include/Eigen/src/Core/util/ReenableStupidWarnings.h:10:30: warning: pragma diagnostic pop could not pop, no matching push [-Wunknown-pragmas]
#pragma clang diagnostic pop
^
In file included from :1:
In file included from /Library/Frameworks/R.framework/Versions/4.0/Resources/library/StanHeaders/include/stan/math/prim/mat/fun/Eigen.hpp:4:
In file included from /Library/Frameworks/R.framework/Versions/4.
In addition: Warning message:
In system(cmd, intern = !verbose) :
running command ‘/Library/Frameworks/R.framework/Resources/bin/R CMD SHLIB file173720520784.cpp 2> file173720520784.cpp.err.txt’ had status 1
Error in sink(type = “output”) : invalid connection
"
I have:
1. uninstalled rstan, the macOS R toolchain, and checked by:
pkgbuild::has_build_tools(debug = TRUE)
[1] FALSE
-
reinstalled everything and checked by
pkgbuild::has_build_tools(debug = TRUE)
[1] TRUE -
changing the header as suggested on another forum
Please any help would be much appreciated!
library("rstan")
options(mc.cores = parallel::detectCores())
rstan_options(auto_write = TRUE)
#make stan file schools.stan####
#####contents of the schools.stan file####
# 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))
fit <- stan(file = 'schools.stan',
data = schools_dat)
print(fit)
Operating System:
R version 4.0.0 (2020-04-24)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS Catalina 10.15.4
Interface Version:
stan_version()
[1] “2.19.1”
Compiler/Toolkit: