Hi Danielle,

cbind( round(coef(garch1),5), round(coef(garch2),5) )
          fGarch  rugarch
mu      0.00040   0.00045
ar1     0.09860   0.09814
omega   0.00001   0.00001
alpha1  0.10210   0.09940
beta1   0.85944   0.86367

cbind( round(garch1@fit$se.coef,5), round(garch2@fit$se.coef,5) )
        fGarch  rugarch
mu     0.00017  0.00017
ar1    0.01544  0.01426
omega  0.00000  0.00000
alpha1 0.03255  0.00559
beta1  0.04558  0.00628

The small differences (and they are small) in the 2 results are down to
one, and only one issue: How the AR(MA) models are implemented in the 2
packages.

In the fGarch package, the AR model is:
\y_t = \mu + ar_1 y_{t-1} + \varepsilon_t

In the rugarch package, the AR model is:
\y_t = \mu + ar_1 (y_{t-1} - \mu) + \varepsilon_t
or alternatively:
\y_t - \mu  =  ar_1 (y_{t-1} - \mu) + \varepsilon_t

(and more generally: \y_t = \mu_t + ar_1 (y_{t-1} - \mu_t)...in the
presence of external regressors in the conditional mean equation).

Following up from your code, the following illustrates this:
#---------------------------------------------------------------------
library(xts)
Sys.setenv(TZ = "GMT")
data(bmw,package="evir")
bmw = xts(bmw, attr(bmw,"times"))
# we use xts in order to make use of the 'lag' functionality
# First thing is to compare the log-likelihoods:
c(-garch1@fit$llh, likelihood(garch2))
# fGarch 'appears' to be a little higher...
17757  17752
# Add the estimated parameters from fGarch and
# use them in the ugarchfilter routine:
spec2 = spec
setfixed(spec2)<-as.list(coef(garch1))
filt = ugarchfilter(spec2, bmw)
likelihood(filt)
17752
# so the likelihood does not change.
# Investigate the conditional mean equation:
pars1 = coef(garch1)
pars2 = coef(garch2)
# both fGarch and rugarch use the mean to initialize the recursions
fitted1 = cbind(garch1@fitted, pars1[1]+pars1[2]*lag(bmw),
pars1[1]+pars1[2]*(lag(bmw)-pars1[1]))
fitted1[1,2:3] = pars1[1]
fitted2 = cbind(as.numeric(fitted(garch2)),
pars2[1]+pars2[2]*lag(bmw-pars2[1]))
fitted2[1,2] = pars2[1]

# the garch likelihood:
# fGarch 1
sum(log(dnorm((bmw[,1]-fitted1[,1])/[email protected]^0.5)/[email protected]^0.5))
17757
# use the alternate representation (y_{t-1} - \mu)
sum(log(dnorm((bmw[,1]-fitted1[,3])/[email protected]^0.5)/[email protected]^0.5))
17752
#---------------------------------------------------------------------

I leave it to you to decide...you might want to take a look at this:
http://www.stat.pitt.edu/stoffer/tsa2/Rissues.htm

Regards,

Alexios

On 17/01/2014 20:40, Danielle Davidian wrote:
> Hi,
> 
> I am trying to fit an arma(0,1) + garch(1,1) model using the functions
> available in two different packages (fGarch and rugarch).  I am getting
> slightly different answers for the toy problem I was trying to solve and
> thought I'd see if I could get some help before I complicated things by
> adding exogenous variables.
> 
> Code below:
> 
> # Based on code from Ruppert 2011, Example 18.3 and 18.4 and Figure 18.4
> rm(list=ls(all=TRUE))
> 
> library(fGarch)
> library(rugarch)
> data(bmw,package="evir")
> 
> garch1 = garchFit(~arma(1,0)+garch(1,1),data=bmw,cond.dist="norm")
> options(digits=3)
> summary(garch1)
> options(digits=10)
> 
> 
> spec <- ugarchspec(variance.model = list(model = "sGARCH", garchOrder =
> c(1, 1)),
>                    mean.model = list(armaOrder = c(1, 0),
> external.regressors = NULL),
>                    distribution.model = "norm")
> garch2 <- ugarchfit(spec=spec, data = bmw)
> 
> options(digits=3)
> garch2@fit$coef
> garch2@fit$se.coef
> 
> garch1@fit$coef
> garch1@fit$se.coef
> 
> Any help or insight appreciated!
> 
> Thanks,
> 
> Danielle
> 
>       [[alternative HTML version deleted]]
> 
> _______________________________________________
> [email protected] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-finance
> -- Subscriber-posting only. If you want to post, subscribe first.
> -- Also note that this is not the r-help list where general R questions 
> should go.
> 
>

_______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-sig-finance
-- Subscriber-posting only. If you want to post, subscribe first.
-- Also note that this is not the r-help list where general R questions should 
go.

Reply via email to