rtime-seriesfgarch

R Output of fGarch


I am modelling a time series as a GARCH(1,1)-process:

Garch

And the z_t are t-distributed.

In R, I do this in the fGarch-package via

model <- garchFit(formula = ~garch(1,1), cond.dist = "std", data=r)

Is this correct?

Now, I would like to understand the output of this to check my formula.

Obviously, model@fit$coefs gives me the coefficients and model@fitted gives me the fitted r_t.

But how do I get the fitted sigma_t and z_t?


Solution

  • I believe that the best way is to define extractor functions when generics are not available and methods when generics already exist.

    The first two functions extract the values of interest from the fitted objects.

    get_sigma_t <- function(x, ...){
      x@sigma.t
    }
    get_z_t <- function(x, ...){
      x@fit$series$z
    }
    

    Here a logLik method for objects of class "fGARCH" is defined.

    logLik.fGARCH <- function(x, ...){
      x@fit$value
    }
    

    Now use the functions, including the method. The data comes from the first example in help("garchFit").

    N <- 200
    r <- as.vector(garchSim(garchSpec(rseed = 1985), n = N)[,1])
    model <- garchFit(~ garch(1, 1), data = r, trace = FALSE)
    
    get_sigma_t(model) # output not shown
    get_z_t(model)     # output not shown
    
    logLik(model)
    #LogLikelihood 
    #    -861.9494 
    

    Note also that methods coef and fitted exist, there is no need for model@fitted or model@fit$coefs, like is written in the question.

    fitted(model)  # much simpler
    coef(model)
    #          mu        omega       alpha1        beta1 
    #3.541769e-05 1.081941e-06 8.885493e-02 8.120038e-01