I am trying to build a GARCH(1,1) model in JAGS, and for simplicity let's assume that the mean equation follows the AR(1) process. I am trying to build 1 JAGS model that will allow joining the AR(1), and GARCH(1,1) processes.
For now I can only achieve the results by building 2 separate JAGS models (they are simplified for the clarity of the presentation). The first JAGS model estimates the parameters of the AR(1) process:
modelstring="
model {
for (i in 2:n) {
y[i]~dnorm(alpha0+alpha1*y[i-1],1)
}
alpha0 ~ dnorm(alpha0.mean,alpha0.prec)
alpha1 ~ dunif(-1,1)
}
Having the parameter's estimates I generate the data of the AR(1) process, obtain residuals, and variances (assuming some window):
ALPHA0=summary(output1)$statistics[1]
ALPHA1=summary(output1)$statistics[2]
y_hat=ALPHA0+ALPHA1*y[1:(dim(DATA)[1])]
eps=y-y_hat
window=30
VAR=rep(NA, dim(DATA)[1]-window)
for (i in 1:length(VAR)){
VAR[i]=var(eps[i:(i+window)])
}
The next block is the GARCH(1,1) proses in JAGS:
modelstring="
model {
for (i in 2:n) {
Var[i]~dnorm(beta0+beta1*Var[i-1]*+beta2*eps[i-1]^2,1)
}
beta0 ~ dnorm(beta0.mean,beta0.prec)
beta1 ~ dunif(0,1)
beta2 ~ dnorm(0,1-beta1)
}
"
How do I join two processes that are dependent?