I am new to Stan and this is probably a very basic question, but I have not found an answer.
I am trying to fit the stochastic volatility model from https://github.com/stan-dev/example-models/blob/master/misc/moving-avg/stochastic-volatility-optimized.stan. This works fine, but when I try to reparametrize the model to having mu = 0, but scaling the variance by sigma_y I get the following error:
“Error in sampler$call_sampler(args_list[[i]]) : " " c++ exception (unknown reason)”.
What does this mean? I can’t find any error in the code. The only change I have done is to replace mu by sigma in the “parameters” stage, and in “transformed parameters” I have removed mu. In the modelling stage, the only difference is that I multiply the standard error of y by sigma_y. This is the code I’m working with:
data {
int<lower=0> T; // # time points (equally spaced)
vector[T] y; // mean corrected return at time t
}
parameters {
real<lower=0> sigma_y; // variance of observations
real<lower=-1,upper=1> phi; // persistence of volatility
real<lower=0> sigma; // white noise shock scale
vector[T] h_std; // std log volatility time t
}
transformed parameters {
vector[T] h;
h <- h_std * sigma;
h[1] <- h[1] / sqrt(1 - phi*phi);
for (t in 2:T){
h[t] <- h[t] + phi *h[t-1];
}
}
model {
sigma ~ cauchy(0,5);
sigma_y ~ cauchy(0,2.5);
h_std ~ normal(0,1);
y ~ normal(0,exp(h/2)*sigma_y);
}
Thanks for the response.
I know that I have downloaded the clang4 compiler, but I can’t tell if I’m using that one specific.
I opened the Makeconf file the first part reads:
We have this fixed for rstan 2.17.x, but in the meantime, it is probably best to use the compiler that comes with XCode. You can edit ~/.R/Makevars so that the CXX is environmental variable is /usr/bin/clang++ or wherever it lives on a Mac.