I have a question regarding the "rugarch" package in R. I try to fit a ARMA(1,1)+GARCH(1,1) to a time series $x$ using the following command:
spec <- ugarchspec(variance.model=list(model="sGARCH", garchOrder=c(1,1)), mean.model=list(c(1,1)))
fitted <- ugarchfit(spec, x)
The code above gives me the following result:
Optimal Parameters
------------------------------------
Estimate Std. Error t value Pr(>|t|)
mu 0.001001 0.001315 0.761040 0.446633
ar1 0.008470 0.351193 0.024118 0.980759
ma1 0.119446 0.345840 0.345379 0.729809
omega 0.000025 0.000016 1.571823 0.115992
alpha1 0.127315 0.053834 2.364961 0.018032
beta1 0.814652 0.069936 11.648563 0.000000`
Now my question is the following, how are the residuals calculated? The one you obtain from the command residuals(fitted)
?
I mean for me I would assume that for instance, if $r_t$ is residual at time $t$:
$r_t = x_t – \mu – AR_1x_{t-1} – MA_1r_{t-1}$
But already for their first residuals, how do you obtain it?
Here are my values of $x$ :
$x_1 = 0.009888849$
$x_2 = -0.008468736$
$x_3=0.014004795$
and the residuals from command residuals(fitted)
:
$r_1=0.008887706$,
$r_2=-0.010606758$
$r_3=0.014350796$.
Using my method I get:
$r_1 = x_1 -\mu = 0.007927641 \neq r_1$
$r_2 = x_1 – \mu – AR_1 x_1 – MA_1 r_1 = -0.01099179$
and so on. Basically it is not far, but it is also not what they have, so I would like to know if someone could tell me what I am missing here?
Thanks!
Best Answer
I can see that you have made errors in your calculation (that you haven't shown). Please recalculate properly and you'll see that the answers are exactly matching.
For e.g.
r1 = x1 −μ = 0.009888849-0.001001 = 0.008887
,which is equal to r1 that you get with the residuals functions. Secondly, in your formula of r2, the first term should be x2 instead of x1, and I believe it's a typo.
Also, note that you can obtain the optimal parameter values with higher number of significant figures using the
coef(fitted)
function, which will be useful in your calculation.