1
$\begingroup$

I have the following GARCH(1,1) model

ymod1 = lm(Jobs ~ Month, df)
resid =ymod1$residuals

library(fGarch)
fit = garchFit(~garch(1,1), cond.dist="sged",  data= resid ,trace=F)

I plotted the expected values with a confidence interval based on the variance predicted by my GARCH model using the predict function:

predict(fit, n.ahead = 12, plot=TRUE,conf=.9,nx=100) 

https://i.sstatic.net/At3C8.png

But it has plotted it on the residuals of a linear trend that I removed, instead of the actual data. How do I obtain a confidence interval for the actual data and plot it on that instead?

$\endgroup$

1 Answer 1

1
$\begingroup$

You are interested in prediction intervals (applicable to outcomes of a random variable) rather than confidence intervals (applicable to parameters or their combinations), I presume.

Add Month as an external regressor to the mean equation when specifying the GARCH model. I am not sure whether garchFit has the functionality, but ugarchspec and ugarchfit from the rugarch package certainly do. In the function ugarchspec, there is an argument external.regressors within mean.model for putting Month into. See the documentation.

Alternatively, just add the fitted values from ymod1 to each end of the prediction intervals that you have obtained for the GARCH model on the residuals from ymod1.

$\endgroup$
9
  • $\begingroup$ Note: asking for code is off-topic, but I gave you the core ideas for writing it yourself. $\endgroup$ Commented Jun 9, 2020 at 10:22
  • $\begingroup$ Thank you for your reply. Is this what you had in mind for using rugarch? garchspec <- ugarchspec(mean.model = list(armaOrder = c(0,0) + df$Month), variance.model = list(model = "sGARCH"), distribution.model = "sged") garchfit <- ugarchfit(data = timeseries , spec = garchspec) . When I do this I get an ar1, ma1, and ma2 term added to the model, are these necessary in the model to account for the linear trend? $\endgroup$
    – user553480
    Commented Jun 9, 2020 at 10:44
  • $\begingroup$ @user553480, you have specified armaOrder incorrectly. There is a separate argument external.regressors within mean.model for putting Month into. See the documentation. You may also consider including Month as a regressors in the conditional variance equation; perhaps the conditional variance has some Month-related variation to it. $\endgroup$ Commented Jun 9, 2020 at 10:49
  • $\begingroup$ Thank you. With that in mind, is this the correct way to specify the model if I wish to add the linear trend into the mean component? garchspec = ugarchspec(variance.model=list(model="sGARCH", garchOrder=c(1,1)), mean.model=list(armaOrder=c(0,0), external.regressors = matrix(df$Month)), distribution.model="sged") garchfit <- ugarchfit(data = timeseries, spec = garchspec) $\endgroup$
    – user553480
    Commented Jun 9, 2020 at 11:11
  • $\begingroup$ @user553480, if matrix(df$Month) is a linear trend, then yes. $\endgroup$ Commented Jun 9, 2020 at 11:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.