Learn R Programming

fEGarch (version 1.0.1)

ljung_box_test,fEGarch_fit-method: Weighted Ljung-Box Test for Autocorrelation

Description

Apply a (weighted) Ljung-Box test (through the Gamma approximation) to check the standardized residuals of a fitted model from this package for remaining autocorrelation. Two different options allow to check either the simple residuals or the squared residuals.

Usage

# S4 method for fEGarch_fit
ljung_box_test(
  object,
  m_max = 20,
  weight_f = function(lag) {
     m <- max(lag)
     (m + 1 - lag)/m
 },
  adj_df = NULL,
  silent = FALSE,
  type = c("simple", "squared"),
  ...
)

Value

Returns a numeric matrix invisibly.

Arguments

object

an object "fEGarch_fit" as returned by the fitting functions of this package, for example by fEGarch.

m_max

the maximum lag; tests will be conducted for 1 up to m_max.

weight_f

a function with argument lag stating how weights should be calculated.

adj_df

degrees of freedom to adjust for as a number or the default NULL, which uses automatic values from the fitted object; for squared residuals adj_df = 0 is the default and for simple returns, it is the sum of ARMA-parameters.

silent

a logical value reflecting whether or not test results should be printed in a well-formatted manner to the console.

type

either "simple" or "squared" for applying the test to simple or squared residuals.

...

currently without use.

Examples

Run this code
window.zoo <- get("window.zoo", envir = asNamespace("zoo"))
rt <- window.zoo(SP500, end = "2002-12-31")
spec <- fEGarch_spec()
model <- fEGarch(spec, rt)
ljung_box_test(model)

Run the code above in your browser using DataLab