Hello! I’m trying to replicate an example of fitting an autoregressive model in rstan (Autoregressive Modeling in Stan), and am running into compiler issues, which is weird, because everything was working as normal a few weeks ago, and I haven’t updated my OS or R/RStudio since then.
The example I’m trying to replicate is short, so I’ll paste it here:
# The model
write("
data {
int<lower=0> K; // Order of Autoregression
int<lower=0> N; // number of observations
real y[N]; // Outcome
}
parameters {
real alpha;
real beta[K];
real sigma;
}
model {
for (n in (K+1):N) {
real mu = alpha;
for (k in 1:K)
mu += beta[k] * y[n-k];
y[n] ~ normal(mu, sigma);
}
}
", "AutoRegressive_Trial.stan")
# Compile model
library(rstan)
# rstan_options(auto_write = TRUE)
model <- stan_model("AutoRegressive_Trial.stan")
I’ve commented out the rstan_options(auto_write = TRUE)
line because I read in another post that doing so might fix the problem, but I’ve had no such luck.
Here’s the error I’m getting:
Error in compileCode(f, code, language = language, verbose = verbose) :
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cstdlib:119:9: error: no member named 'strtoul' in the global namespaceusing ::strtoul; ~~^fatal error: too many errors emitted, stopping now [-ferror-limit=]20 errors generated.make: *** [filef63a2e5990f7.o] Error 1
Error in sink(type = "output") : invalid connection
I’ve read on other posts that this can be caused by an installation error, but I’m just not sure how to diagnose the problem here, so any help would be much appreciated :)
Thanks so much for any suggestions!