Package {qgarch}


Type: Package
Title: Quadratic GARCH-in-Mean Models for Volatility Feedback
Version: 0.1.0
Description: Fits quadratic generalized autoregressive conditional heteroskedasticity-in-mean (QGARCH-M) models motivated by Campbell and Hentschel (1992). The package supports models with lambda fixed at zero, lambda restricted to a function of the remaining parameters, lambda estimated freely, and a threshold extension with state-dependent lambda. It also provides tools for starting values, estimation, forecasting, likelihood-ratio testing, moment diagnostics, and replication with the included monthly U.S. stock market dataset.
License: MIT + file LICENSE
Encoding: UTF-8
Depends: R (≥ 4.1.0)
Imports: MASS
Suggests: testthat (≥ 3.0.0)
LazyData: true
URL: https://github.com/sho-125/qgarch
BugReports: https://github.com/sho-125/qgarch/issues
Config/testthat/edition: 3
Config/roxygen2/version: 8.0.0
NeedsCompilation: no
Packaged: 2026-05-05 03:06:02 UTC; sho125
Author: Jedrzej Bialkowski [aut], Sanghyun Hong [aut, cre], Moritz Wagner [aut]
Maintainer: Sanghyun Hong <sanghyun.hong@canterbury.ac.nz>
Repository: CRAN
Date/Publication: 2026-05-07 16:41:03 UTC

Extract coefficients from a qgarch model

Description

Extract coefficients from a qgarch model

Usage

## S3 method for class 'qgarch'
coef(object, ...)

Arguments

object

A fitted qgarch object.

...

Additional arguments. Supports type = "estimated" or type = "full".

Value

A named numeric vector of coefficients.


Fitted values from a qgarch model

Description

Fitted values from a qgarch model

Usage

## S3 method for class 'qgarch'
fitted(object, ...)

Arguments

object

A fitted qgarch object.

...

Unused.

Value

A numeric vector of fitted values.


Log-likelihood for a qgarch model

Description

Log-likelihood for a qgarch model

Usage

## S3 method for class 'qgarch'
logLik(object, ...)

Arguments

object

A fitted qgarch object.

...

Unused.

Value

An object of class "logLik".


Plot a qgarch model

Description

Plot a qgarch model

Usage

## S3 method for class 'qgarch'
plot(x, which = c("sigma2", "standardized"), ...)

Arguments

x

A fitted qgarch object.

which

Which plot to show: "sigma2" or "standardized".

...

Additional graphical arguments passed to graphics::plot().

Value

The input object, invisibly.


Forecast from a generalized qgarch(m, n) model

Description

Forecast from a generalized qgarch(m, n) model

Usage

## S3 method for class 'qgarch'
predict(object, n.ahead = 1L, ...)

Arguments

object

A fitted qgarch object.

n.ahead

Number of periods ahead to forecast.

...

Unused.

Value

A data frame with forecast horizon, conditional mean, conditional variance, and conditional standard deviation.


Print a qgarch model

Description

Print a qgarch model

Usage

## S3 method for class 'qgarch'
print(x, digits = max(3L, getOption("digits") - 2L), ...)

Arguments

x

A fitted qgarch object.

digits

Number of digits to print.

...

Unused.

Value

The input object, invisibly.


Print a qgarch summary

Description

Print a qgarch summary

Usage

## S3 method for class 'summary.qgarch'
print(x, digits = max(3L, getOption("digits") - 2L), ...)

Arguments

x

An object of class "summary.qgarch".

digits

Number of digits to print.

...

Unused.

Value

The input object, invisibly.


Default starting values for qgarch estimation

Description

Creates a compact but order-adaptive set of starting values for the selected qgarch model.

Usage

qgarch_default_starts(
  x,
  model = c("zero", "restricted", "free", "threshold"),
  arch_order = 1L,
  garch_order = 1L
)

Arguments

x

A numeric vector or one-column data frame containing the observed series.

model

Character string specifying the model variant. Must be one of "zero", "restricted", "free", or "threshold".

arch_order

Positive integer giving the ARCH lag order.

garch_order

Positive integer giving the GARCH lag order.

Value

A list of named numeric vectors containing candidate starting values.


Fit generalized qgarch(m, n) models

Description

Fits QGARCH-in-mean models using nonlinear minimization of the negative log-likelihood. Four variants are supported: a zero-lambda model, a restricted-lambda model, a free-lambda model, and a threshold model with state-dependent lambda.

Usage

qgarch_fit(
  x,
  model = c("zero", "restricted", "free", "threshold"),
  arch_order = 1L,
  garch_order = 1L,
  threshold_indicator = NULL,
  start = NULL,
  rho = 1,
  steptol = 1e-10,
  typsize = 0.1,
  iterlim = 300L,
  print.level = 0,
  hessian = TRUE,
  vcov_type = c("auto", "sandwich", "hessian", "opg", "none")
)

Arguments

x

A numeric vector or one-column data frame containing the observed series. The series must contain only finite, non-missing values.

model

Character string specifying the model variant. Must be one of "zero", "restricted", "free", or "threshold".

arch_order

Positive integer giving the ARCH lag order m.

garch_order

Positive integer giving the GARCH lag order n.

threshold_indicator

Optional threshold indicator used only when model = "threshold". Must have the same length as x. Nonzero values are converted to 1 and zero values to 0.

start

Optional starting values. May be NULL, a numeric vector, or a list of numeric vectors.

rho

Scalar used in the restricted-lambda mapping.

steptol

Step tolerance passed to stats::nlm().

typsize

Typical size passed to stats::nlm(). A single value is repeated to the appropriate length.

iterlim

Maximum number of iterations passed to stats::nlm().

print.level

Print level passed to stats::nlm().

hessian

Logical; should the Hessian be returned by stats::nlm()?

vcov_type

Character string controlling standard-error estimation. One of "auto", "sandwich", "hessian", "opg", or "none". In "auto" mode, Hessian-based standard errors are tried first.

Value

An object of class "qgarch".


Likelihood ratio test for nested qgarch models

Description

Compares two fitted qgarch models using the likelihood ratio test.

Usage

qgarch_lr_test(restricted, unrestricted, df = NULL)

Arguments

restricted

A fitted qgarch object representing the restricted model.

unrestricted

A fitted qgarch object representing the unrestricted model.

df

Degrees of freedom for the test. If NULL, it is computed as the difference in the number of estimated coefficients.

Value

A data frame with the likelihood ratio statistic, degrees of freedom, p-value, and the model names. The returned object has class c("qgarch_lr_test", "data.frame").


Compute sample moments for a series

Description

Computes the sample mean, variance, skewness, and excess kurtosis for a numeric series, along with simple standard errors.

Usage

qgarch_moments(x, scale_mean_variance = 1)

Arguments

x

A numeric vector or a one-column data frame containing the series.

scale_mean_variance

A finite scalar used to rescale the reported mean and variance and their standard errors.

Value

A list with elements:

estimate

Named numeric vector of moment estimates.

std_error

Named numeric vector of standard errors.

n

Number of usable observations.

The returned object has class "qgarch_moments".


Residuals from a qgarch model

Description

Residuals from a qgarch model

Usage

## S3 method for class 'qgarch'
residuals(object, type = c("raw", "standardized", "eta"), ...)

Arguments

object

A fitted qgarch object.

type

Type of residuals to return: "raw", "standardized", or "eta".

...

Unused.

Value

A numeric vector of residuals.


Summarize a qgarch model

Description

Summarize a qgarch model

Usage

## S3 method for class 'qgarch'
summary(object, ...)

Arguments

object

A fitted qgarch object.

...

Unused.

Value

An object of class "summary.qgarch".


Monthly U.S. data

Description

Monthly data used in examples and tests for the qgarch package.

Usage

us_monthly

Format

A data frame with monthly observations and 3 variables:

YearMon

Month of the observation.

Mktrf

Market excess return.

ER

Excess return series.

Source

Prepared by the package author.


Variance-covariance matrix for a qgarch model

Description

Variance-covariance matrix for a qgarch model

Usage

## S3 method for class 'qgarch'
vcov(object, ...)

Arguments

object

A fitted qgarch object.

...

Unused.

Value

A variance-covariance matrix.