Hi,
I have a problem with compiling rstan after I updated new macOS operating system. I ran the 8-school example code on getting-started-with-rstan and got the error:
Error in compileCode(f, code, language = language, verbose = verbose) :
Compilation ERROR, function(s)/method(s) not created! In file included from file25277b5520e.cpp:8:
In file included from /Library/Frameworks/R.framework/Versions/3.5/Resources/library/StanHeaders/include/src/stan/model/model_header.hpp:4:
In file included from /Library/Frameworks/R.framework/Versions/3.5/Resources/library/StanHeaders/include/stan/math.hpp:4:
In file included from /Library/Frameworks/R.framework/Versions/3.5/Resources/library/StanHeaders/include/stan/math/rev/mat.hpp:4:
In file included from /Library/Frameworks/R.framework/Versions/3.5/Resources/library/StanHeaders/include/stan/math/rev/core.hpp:4:
In file included from /Library/Frameworks/R.framework/Versions/3.5/Resources/library/StanHeaders/include/stan/math/rev/core/autodiffstackstorage.hpp:4:
In file included from /Library/Frameworks/R.framework/Versions/3.5/Resources/library/StanHeaders/include/stan/math/memory/stack_alloc.hpp:8:
In file included from /usr/local/clang4/bin/../include/c++/v1/cstdlib:86:
/
In addition: Warning messages:
1: In readLines(file, warn = TRUE) :
incomplete final line found on '/Users/yang/Documents/RProgramming/8schools.stan'
2: In system(cmd, intern = !verbose) :
running command '/Library/Frameworks/R.framework/Resources/bin/R CMD SHLIB file25277b5520e.cpp 2> file25277b5520e.cpp.err.txt' had status 1
Error in sink(type = "output") : invalid connection
For traceback, the stan file is:
// saved as 8schools.stan
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
}
And the R code is:
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 = '8schools.stan', data = schools_dat)
print(fit)
plot(fit)
Can anyone help me out here? Thanks!!!
Operating system: macOS Mojave 10.14
R version 3.5.1