where e,u~N(0,1). My stan code for the latter model is the following:
data {
int<lower=0> T;
vector[T] y;
}
parameters {
real <lower=0> alpha;
real<lower=0,upper=1> beta1;
real<lower=0> sigma;
real x0;
vector[T] x;
}
transformed parameters {
real <lower=0> h[T];
h[1]=sqrt(alpha + beta1 *pow(x0,2));
for (t in 2:T)
h[t]= sqrt((alpha +beta1*pow(x[t-1],2)));
}
model {
alpha ~ normal(0,10);
beta1 ~ uniform(0,1);
sigma ~ cauchy(0, 5);
x0 ~ normal(0,1);
x ~ normal(0,h);
y ~ normal(x, sigma);
}
With the code in R below i am generating 1500 sets of simulated data and then trying to fit the model with my STAN model.
set.seed(1)
T <- 1500
alpha=0.1
beta0=0.8
sigma=0.02
f<- rep(0, T)
y<-rep(0,T)
f[1]=rnorm(1);
for (t in 2:T)
f[t] <- rnorm(1, 0, sqrt(alpha + beta0 * (f[t - 1]^2)))
for (t in 1:T)
y[t] <- rnorm(1, f[t], sigma)
The purpose here is to compare the prior and the posterior values of parameters alpha, beta and sigma. The problem is that the model is not fitting regardless of the number of iterations i choose to sample.
Do you have any suggestions for a rookie user?
Do you have some references?! I really wanna read them (sorry I love time series :) )
Well, I am also running it! And the model has some problems mixing!
Stochastic volatility models have the same problems too! So maybe using more iteration could help. You can read Stan’s SVM post here
I change the priors as well, for example instead of a uniform I use a beta(2,2), and in alpha, a normal(0,1) might be enough. Even so, some x or h parameters are still not mixing, my credible intervals capture the real values in all my simulations. You should get more info of how selecting prior in the Stan’s prior choice recommendations
Ohh I am keep doing experiments and trying a transformations cause I dont ilke the bfmi warning! And I think I almost got it! So I post you later with the updated and checked model.