# ARMA Bayesian NB Model

NBts.stan (2.1 KB) newposCOVID.R (6.4 KB)

Hello everyone, i’m new here and i just found out about STAN and this amazing community.

I am doing for my university a project about a count time series for the new positives to COVID-19 here in Italy. I did at first a model using the R’s package tscount but the model is not very smoothe and for this reason my Professor suggested me to do it with a Bayesian approach. I’m a neofite to time series analisys and STAN coding and I did my best but it appears that, when i run the code in R, the inverse scale parameter at row 7 of my STAN code is always 0 which is not good. The professor told me that sometimes it happens but by reparametrizing I should be able to fix everything. I’m not able to fix it so i would like to have your suggestion. Is good my code? How can I fix this problem with the inverse scale parameter (phi)? I’m open to any kind of suggestion also concering the choice of the priors etc.

Thanks in advance for the help, and sorry also for my english (I know it’s not super good but i hope it’s understandable).

I don’t know what’s causing `phi=0` but the following part does not look right

``````for (t in 2 : T) {
lambda = alpha + beta_AR1 * log(n_newpos[t - 1] + 1) + ...
``````

This assigns the whole vector in every iteration of the loop. You presumably want to assign the components one-by-one. The probably should be

``````  for (t in 2 : T) {
lambda[t] = alpha + beta_AR1 * log(n_newpos[t - 1] + 1)
+ beta_MA1 * log(lambda[t - 1]) + beta_times * times[t]
+ beta_times2 * times2[t] + beta_n_tamponi * n_tamponi[t]
+ beta_lockdown_rep * lockdown_rep[t]
+ beta_stag_calda * stag_calda[t]
+ beta_interaction1 * interaction1[t]
+ beta_interaction2 * interaction2[t];
}
``````