[R] Basic R timeseries data manipulation
Benjamin Dickgiesser
dickgiesser at gmail.com
Mon Nov 20 18:18:26 CET 2006
To elaborate a bit, I fitted a AR(2)-Garch(1,1) model to the Dow Jones
log returns and am now trying to calculate the variance suggested by
the model.
#Get log returns
rt <- diff(log(getStock(1)$value))
#Fit Garch(1,1) and AR(2)
fit = garchFit(~arma(2,0), ~garch(1,1), series = rt)
#Coefficient(s):
# mu ar1 ar2 omega alpha1
beta1
# 3.75101e-04 9.61877e-02 -2.48071e-02 7.86872e-07 7.37382e-02
9.20691e-01
Now I was trying to something in the lines of:
n <- length(rt) - 2
at <- vector(length = n)
at <- rt - (3.75101e-04 + 9.61877e-02 rt[-1] - 2.48071e-02 rt[-2])
var <- 7.86872e-07 + 7.37382e-02 sigma[-1] + 9.20691e-01 rt[-1]
which doesn't work..
I would really appreciate your help.
Thank you,
Benjamin
On 11/20/06, Benjamin Dickgiesser <dickgiesser at gmail.com> wrote:
> Hi,
>
> suppose I have a time series rt. Why does this code not work?
>
> rt <- data
>
> n <- length(rt) - 2
> at <- vector(length = n)
>
> at = rt-(3.75101e-04 + 9.61877e-02 * rt[-1] - 2.48071e-02 * rt[-2])
>
> Thank you,
> Benjamin
>
More information about the R-help
mailing list