and by the way, the nu is called under model, so it is a local instead of global. I cannot recall it at prediction step.

Ok, give me a chance I will check everything and send you back :)

Hi again,

This worked for me

arma_help.stan (1.2 KB)

I just do it like this and work.

Basically just do the arma equation update again:

generated quantities{

vector[x] predict;

vector[x] nu_predict;

vector[x] err_predict;

```
for(i in 1:x){
if(i <= T){
predict[i] = normal_rng(nu[i],sigma);
nu_predict[i] = nu[i];
err_predict[i] = err[i];
}
else{
nu_predict[i] = mu + phi*predict[i-1] + theta*err_predict[i-1];
predict[i] = normal_rng(nu_predict[i],sigma);
err_predict[i] = predict[i]-nu_predict[i];
}
}
}
```

You can see the code I upload, I change nu! And make the predictions in the generated quantities part

some people can make prediction in the model part, but I really don’t understand.

do you know how to do it in the case?

Being honest with you I havent try it.

I remember once @bgoodri recommend use the generated quant… part, because in that section all the unknown parameters are fitted, so a simple Monte Carlo makes thing easier.

Hope that works :)

I got some wrong information like below, it looks doesn’t divergence well, I think I should dismiss the error after T:

WARNING:pystan:n_eff / iter below 0.001 indicates that the effective sample size has likely been overestimated

WARNING:pystan:Rhat above 1.1 or below 0.9 indicates that the chains very likely have not mixed

WARNING:pystan:391 of 4000 iterations ended with a divergence (9.78 %).

WARNING:pystan:Try running with adapt_delta larger than 0.8 to remove the divergences.

WARNING:pystan:1 of 4000 iterations saturated the maximum tree depth of 10 (0.025 %)

WARNING:pystan:Run again with max_treedepth larger than 10 to avoid saturation

WARNING:pystan:Truncated summary with the ‘fit.**repr**’ method. For the full summary use ‘print(fit)’

how do you handle these kinds of errors if your encounter them.

Well probably will be because you model is not fitting the data

The problems with arma models is that you need that your time series is stationary! Have you check that already?

the time series actually is dummy data and the data feed is first differenced. it got a bad result.

I also tries the model with original data, and the result looks good, all the parameters have Rhat=1.0.

I remember somewhere said the Rhat should = 1.01. do you thinks it is necessary, or 1.0 is fine too.?

Like 0,1 data? If that is the case, maybe a normal likelihood is not a good idea, maybe a poisson arma model?

Rob Hydman write some things about it:

I think 1 is fine

thanks!

you help me a lot. I will read this, and do you have other posts or books recommend?

A practical book is

Time series analysis and its applications with R examples of R Shumway, and D. Stoffer

Is a good start and the theory is not hard explained

thanks

by the way, I mean the book stuffs regarding Stan, I always get confuse about stan and how to encode.

Have you check the Stan User´s Guide?

It even has an arma implementation!

Or maybe Bayesian Data analysis, I think this book has some examples implemented

in Stan. @avehtari could help you more!

Some days ago I saw this post, you might like it:

yeah, I already checked it