Learn R Programming

fGarch (version 4021.88)

volatility-methods: Extract GARCH Model Volatility

Description

Extracts volatility, here from a fitted GARCH object. This is a method (see methods) for the S3 generic function volatility (we import and re-export) from package fBasics.

Usage

volatility(object, ...)
# S3 method for fGARCH
volatility(object, type = c("sigma", "h"), ...)

Arguments

object

an object of class fGARCH as returned by garchFit().

type

a character string denoting if the conditional standard deviations "sigma" or the variances "h" should be returned.

...

additional arguments to be passed.

Methods

object = "ANY"

Generic function.

object = "fGARCH"

Extractor function for volatility or standard deviation from an object of class "fGARCH".

Author

Diethelm Wuertz for the Rmetrics R-port.

Details

The function extracts the @volatility from the slots @sigma.t or @h.t of an object of class "fGARCH" as returned by the function garchFit().

The class of the returned value depends on the input to the function garchFit who created the object. The returned value is always of the same class as the input object to the argument data in the function garchFit, i.e. if you fit a "timeSeries" object, you will get back from the function fitted also a "timeSeries" object, if you fit an object of class "zoo", you will get back again a "zoo" object. The same holds for a "numeric" vector, for a "data.frame", and for objects of class "ts", "mts".

In contrast, the slot itself returns independent of the class of the data input always a numeric vector, i.e. the function call rslot(object, "fitted") will return a numeric vector.

Examples

Run this code
## Swiss Pension fund Index -
   stopifnot(require("timeSeries")) # need package 'timeSeries'
   x = as.timeSeries(data(LPP2005REC))

## garchFit
   fit = garchFit(LPP40 ~ garch(1, 1), data = 100*x, trace = FALSE)
   fit

## volatility -
   # Standard Deviation:
   vola = volatility(fit, type = "sigma")
   head(vola)
   class(vola)
   # Variance:
   vola = volatility(fit, type = "h")
   head(vola)
   class(vola)

## slot -
   vola = slot(fit, "sigma.t")
   head(vola)
   class(vola)
   vola = slot(fit, "h.t")
   head(vola)
   class(vola)

Run the code above in your browser using DataLab