Version: | 0.7 |
Date: | 2025-03-25 |
Title: | Simulation and Estimation of Log-GARCH Models |
Maintainer: | Genaro Sucarrat <genaro.sucarrat@bi.no> |
Depends: | R (≥ 3.4.0), methods, zoo |
URL: | https://www.sucarrat.net/ |
Description: | Simulation and estimation of univariate and multivariate log-GARCH models. The main functions of the package are: lgarchSim(), mlgarchSim(), lgarch() and mlgarch(). The first two functions simulate from a univariate and a multivariate log-GARCH model, respectively, whereas the latter two estimate a univariate and multivariate log-GARCH model, respectively. |
License: | GPL-2 |
NeedsCompilation: | yes |
Packaged: | 2025-03-25 15:59:52 UTC; sucarrat |
Author: | Genaro Sucarrat [aut, cre] |
Repository: | CRAN |
Date/Publication: | 2025-03-25 19:00:02 UTC |
Simulation and estimation of log-GARCH models
Description
This package provides facilities for the simulation and estimation of univariate log-GARCH models, and for the multivariate CCC-log-GARCH(1,1) model, see Sucarrat, Gronneberg and Escribano (2013), Sucarrat and Escribano (2013), and Francq and Sucarrat (2013).
Let y[t] denote a financial return or the error of a regression at time t such that
y[t] = sigma[t]*z[t],
where sigma[t] > 0 is the conditional standard deviation or volatility at t, and where z[t] is an IID innovation with mean zero and unit variance. The log-volatility specifiction of the log-GARCH-X model is given by
ln sigma[t]^2 = intercept + Sum_i alpha_i * ln y[t-i]^2 + Sum_j beta_j *ln sigma[t-1]^2 + Sum_k lambda_k * x[t]_k,
where the conditioning x-variables can be contemporaneous and/or lagged. The lgarch package estimates this model via its ARMA-X representation, see Sucarrat, Gronneberg and Escribano (2013), and treats zeros on y as missing values, see Sucarrat and Escribano (2013).
Details
Package: | lgarch |
Type: | Package |
Version: | 0.7 |
Date: | 2025-03-25 |
License: | GPL-2 |
LazyLoad: | yes |
The main functions of the package are: lgarchSim
, mlgarchSim
, lgarch
and mlgarch
. The first two functions simulate from a univariate and a multivariate log-GARCH model, respectively, whereas the latter two estimate a univariate and a multivariate log-GARCH model, respectively.
The lgarch and mlgarch functions return an object (a list) of class 'lgarch' and 'mlgarch', respectively. In both cases a collection of methods can be applied to each of them: coef, fitted, logLik, print, residuals, summary and vcov. In addition, the function rss
can be used to extract the Residual Sum of Squares of the estimated ARMA representation from an lgarch object.
The output produced by the lgarchSim
and mlgarchSim
functions, and by the fitted and residuals methods, are of the Z's ordered observations (zoo
) class, see Zeileis and Grothendieck (2005), and Zeileis, Grothendieck and Ryan (2014). This means a range of time-series and plotting methods are available for these objects.
Author(s)
Genaro Sucarrat, http://www.sucarrat.net/
References
C. Francq and G. Sucarrat (2018), 'An Exponential Chi-Squared QMLE for Log-GARCH Models Via the ARMA Representation', Journal of Financial Econometrics 16, pp. 129-154 doi:10.1093/jjfinec/nbx032
G. Sucarrat and A. Escribano (2018), 'Estimation of Log-GARCH Models in the Presence of Zero Returns', European Journal of Finance 24, pp. 809-827, doi:10.1080/1351847X.2017.1336452
G. Sucarrat, S. Gronneberg and A. Escribano (2016), 'Estimation and Inference in Univariate and Multivariate Log-GARCH-X Models When the Conditional Density is Unknown', Computational Statistics and Data Analysis 100, pp. 582-594, doi:10.1016/j.csda.2015.12.005
Zeileis, A. and G. Grothendieck (2005), 'zoo: S3 Infrastructure for Regular and Irregular Time Series', Journal of Statistical Software 14, pp. 1-27
Zeileis, A., G. Grothendieck, J.A. Ryan and F. Andrews(2014), 'zoo: S3 Infrastructure for Regular and Irregular Time Series (Z's ordered observations)', R package version 1.7-11, https://CRAN.R-project.org/package=zoo/
See Also
lgarchSim
, mlgarchSim
, lgarch
, mlgarch
, coef.lgarch
, coef.mlgarch
, fitted.lgarch
,
fitted.mlgarch
, logLik.lgarch
, logLik.mlgarch
, print.lgarch
, print.mlgarch
,
residuals.lgarch
, residuals.mlgarch
, rss
, summary.lgarch
, summary.mlgarch
, vcov.lgarch
,
vcov.mlgarch
and zoo
Examples
##simulate 500 observations w/default parameter values from
##a univariate log-garch(1,1):
set.seed(123)
y <- lgarchSim(500)
##estimate a log-garch(1,1):
mymod <- lgarch(y)
##print results:
print(mymod)
##extract coefficients:
coef(mymod)
##extract Gaussian log-likelihood (zeros excluded, if any) of the log-garch model:
logLik(mymod)
##extract Gaussian log-likelihood (zeros excluded, if any) of the arma representation:
logLik(mymod, arma=TRUE)
##extract variance-covariance matrix:
vcov(mymod)
##extract and plot the fitted conditional standard deviation:
sdhat <- fitted(mymod)
plot(sdhat)
##extract and plot standardised residuals:
zhat <- residuals(mymod)
plot(zhat)
##extract and plot all the fitted series:
myhat <- fitted(mymod, verbose=TRUE)
plot(myhat)
##simulate from a two-dimensional ccc-log-garch(1,1) w/defaults:
set.seed(123)
yy <- mlgarchSim(2000)
##estimate a 2-dimensional ccc-log-garch(1,1):
myymod <- mlgarch(yy)
##print results:
print(myymod)
Extraction methods for 'lgarch' objects
Description
Extraction methods for objects of class 'lgarch' (i.e. the result of estimating a log-GARCH model)
Usage
## S3 method for class 'lgarch'
coef(object, arma = FALSE, ...)
## S3 method for class 'lgarch'
fitted(object, verbose = FALSE, ...)
## S3 method for class 'lgarch'
logLik(object, arma = FALSE, ...)
## S3 method for class 'lgarch'
print(x, arma = FALSE, ...)
## informal method for class 'lgarch'
rss(object, ...)
## S3 method for class 'lgarch'
residuals(object, arma = FALSE, ...)
## S3 method for class 'lgarch'
summary(object, ...)
## S3 method for class 'lgarch'
vcov(object, arma = FALSE, ...)
Arguments
object |
an object of class 'lgarch' |
x |
an object of class 'lgarch' |
verbose |
logical. If FALSE (default), then only basic information is returned |
arma |
logical. If FALSE (default), then information relating to the log-garch model is returned. If TRUE, then information relating to the ARMA representation is returned |
... |
additional arguments |
Details
Note: The rss function is not a formal S3 method.
Value
coef: |
A numeric vector containing the parameter estimates |
fitted: |
A |
logLik: |
The value of the log-likelihood (contributions at zeros excluded) at the maximum |
print: |
Prints the most important parts of the estimation results |
residuals: |
A |
rss: |
A numeric; the Residual Sum of Squares of the ARMA representation |
summary: |
A print of the items in the |
vcov: |
The variance-covariance matrix |
Author(s)
Genaro Sucarrat, http://www.sucarrat.net/
See Also
Examples
##simulate 500 observations w/default parameter values:
set.seed(123)
y <- lgarchSim(500)
##estimate a log-garch(1,1):
mymod <- lgarch(y)
##print results:
print(mymod)
##extract coefficients:
coef(mymod)
##extract Gaussian log-likelihood (zeros excluded) of the log-garch model:
logLik(mymod)
##extract the Residual Sum of Squares of the ARMA representation:
rss(mymod)
##extract log-likelihood (zeros excluded) of the ARMA representation:
logLik(mymod, arma=TRUE)
##extract variance-covariance matrix:
vcov(mymod)
##extract and plot the fitted conditional standard deviation:
sdhat <- fitted(mymod)
plot(sdhat)
##extract and plot standardised residuals:
zhat <- residuals(mymod)
plot(zhat)
##extract and plot all the fitted series:
myhat <- fitted(mymod, verbose=TRUE)
plot(myhat)
Extraction methods for 'mlgarch' objects
Description
Extraction methods for objects of class 'mlgarch' (i.e. the result of estimating a multivariate CCC-log-GARCH model)
Usage
## S3 method for class 'mlgarch'
coef(object, varma = FALSE, ...)
## S3 method for class 'mlgarch'
fitted(object, varma = FALSE, verbose = FALSE, ...)
## S3 method for class 'mlgarch'
logLik(object, varma = FALSE, ...)
## S3 method for class 'mlgarch'
print(x, varma = FALSE, ...)
## S3 method for class 'mlgarch'
residuals(object, varma = FALSE, ...)
## S3 method for class 'mlgarch'
summary(object, ...)
## S3 method for class 'mlgarch'
vcov(object, varma = FALSE, ...)
Arguments
object |
an object of class 'mlgarch' |
x |
an object of class 'mlgarch' |
verbose |
logical. If FALSE (default), then only basic information is returned |
varma |
logical. If FALSE (default), then information relating to the multivariate CCC-log-GARCH model is returned. If TRUE, then information relating to the VARMA representation is returned |
... |
additional arguments |
Details
Empty
Value
coef: |
A numeric vector containing the parameter estimates |
fitted: |
A |
logLik: |
The value of the log-likelihood (contributions at zeros excluded) at the maximum |
print: |
Prints the most important parts of the estimation results |
residuals: |
A |
summary: |
A print of the items in the |
vcov: |
The variance-covariance matrix |
Author(s)
Genaro Sucarrat, http://www.sucarrat.net/
See Also
Examples
##simulate from 2-dimensional model w/default parameter values:
set.seed(123)
y <- mlgarchSim(2000)
##estimate a 2-dimensional ccc-log-garch(1,1):
mymod <- mlgarch(y)
##print results:
print(mymod)
##extract ccc-log-garch coefficients:
coef(mymod)
##extract Gaussian log-likelihood (zeros excluded) of the ccc-log-garch model:
logLik(mymod)
##extract Gaussian log-likelihood (zeros excluded) of the varma representation:
logLik(mymod, varma=TRUE)
##extract variance-covariance matrix:
vcov(mymod) #work in progress!
vcov(mymod, varma=TRUE)
##extract and plot the fitted conditional standard deviations:
sdhat <- fitted(mymod)
plot(sdhat)
##extract and plot standardised residuals:
zhat <- residuals(mymod)
plot(zhat)
Difference a vector or a matrix, with special treatment of zoo
objects
Description
Similar to the diff
function from the base package, but gdiff
enables padding (e.g. NAs or 0s) of the lost entries. Contrary to the diff
function in the base package, however, the default in gdiff is to pad (with NAs). The gdiff function is particularly suited for zoo
objects, since their indexing is retained
Usage
gdiff(x, lag = 1, pad = TRUE, pad.value = NA)
Arguments
x |
a numeric vector or matrix |
lag |
integer equal to the difference-length (the default is 1) |
pad |
logical. If TRUE (default), then the lost entries are padded with pad.value. If FALSE, then no padding is undertaken |
pad.value |
numeric. The pad-value |
Value
A vector or matrix with the differenced values
Note
Empty
Author(s)
Genaro Sucarrat, http://www.sucarrat.net/
See Also
Examples
##1st difference of a series:
x <- rnorm(5)
gdiff(x)
##1st difference with no padding:
gdiff(x, pad=FALSE)
##1st difference retaining the original zoo-index ordering:
gdiff(as.zoo(x))
##1st difference of a matrix:
y <- matrix(rnorm(8),4,2)
gdiff(y)
##2nd difference of the same matrix:
gdiff(y, lag=2)
Lag a vector or a matrix, with special treatment of zoo
objects
Description
Similar to the lag
function from the stats package, but glag enables padding (e.g. NAs or 0s) of the lost entries. Contrary to the lag
function in the stats package, however, the default in glag is to pad (with NAs). The glag is particularly suited for zoo
objects, since their indexing is retained
Usage
glag(x, k = 1, pad = TRUE, pad.value = NA)
Arguments
x |
a numeric vector or matrix |
k |
integer equal to the lag (the default is 1) |
pad |
logical. If TRUE (default), then the lost entries are padded with pad.value. If FALSE, then no padding is undertaken |
pad.value |
the pad-value |
Value
A vector or matrix with the lagged values
Note
Empty
Author(s)
Genaro Sucarrat, http://www.sucarrat.net/
See Also
Examples
##lag series with NA for the missing entries:
x <- rnorm(5)
glag(x)
##lag series with no padding:
x <- rnorm(5)
glag(x, pad=FALSE)
##lag series and retain the original zoo-index ordering:
x <- as.zoo(rnorm(5))
glag(x)
##lag two periods:
glag(x, k=2)
Estimate a log-GARCH model
Description
Fit a log-GARCH model by either (nonlinear) Least Squares (LS) or Quasi Maximum Likelihood (QML) via the ARMA representation. For QML either the Gaussian or centred exponential chi-squared distribution can be used as instrumental density, see Sucarrat, Gronneberg and Escribano (2013), and Francq and Sucarrat (2013). Zero-values on the dependent variable y are treated as missing values, as suggested in Sucarrat and Escribano (2013). Estimation is via the nlminb
function, whereas a numerical estimate of the Hessian is obtained with optimHess
for the computation of the variance-covariance matrix
Usage
lgarch(y, arch = 1, garch = 1, xreg = NULL, initial.values = NULL,
lower = NULL, upper = NULL, nlminb.control = list(), vcov = TRUE,
method=c("ls","ml","cex2"), mean.correction=FALSE,
objective.penalty = NULL, solve.tol = .Machine$double.eps,
c.code = TRUE)
Arguments
y |
numeric vector, typically a financial return series or the error of a regression |
arch |
the arch order (i.e. an integer equal to or greater than 0). The default is 1. NOTE: in the current version the order canno be greater than 1 |
garch |
the garch order (i.e. an integer equal to or greater than 0). The default is 1. NOTE: in the current version the order canno be greater than 1 |
xreg |
vector or matrix with conditioning variables |
initial.values |
NULL (default) or a vector with the initial values of the ARMA-representation |
lower |
NULL (default) or a vector with the lower bounds of the parameter space (of the ARMA-representation). If NULL, then the values are automatically chosen |
upper |
NULL (default) or a vector with the upper bounds of the parameter space (of the ARMA-representation). If NULL, then the values are automatically chosen |
nlminb.control |
list of control options passed on to the |
vcov |
logical. If TRUE (default), then the variance-covariance matrix is computed. The FALSE options makes estimation faster, but the variance-covariance matrix cannot be extracted subsequently |
method |
Estimation method to use. Either "ls", i.e. Nonlinear Least Squares (default), "ml", i.e. Gaussian QML or "cex2", i.e. Centred exponential Chi-squared QML, see Francq and Sucarrat (2013). Note: For the cex2 method mean-correction = FALSE is not available |
mean.correction |
Whether to mean-correct the ARMA representation. Mean-correction is usually faster, but not always recommended if covariates are added (i.e. if xreg is not NULL) |
objective.penalty |
NULL (default) or a numeric value. If NULL, then the log-likelihood value associated with the initial values is used. Sometimes estimation can result in NA and/or +/-Inf values (this can be fatal for simulations). The value objective.penalty is the value returned by the objective function |
solve.tol |
The function |
c.code |
logical. TRUE (default) is (much) faster, since it makes use of compiled C-code in the recursions |
Value
A list of class 'lgarch'
Note
Empty
Author(s)
Genaro Sucarrat, https://www.sucarrat.net/
References
C. Francq and G. Sucarrat (2018), 'An Exponential Chi-Squared QMLE for Log-GARCH Models Via the ARMA Representation', Journal of Financial Econometrics 16, pp. 129-154 doi:10.1093/jjfinec/nbx032
G. Sucarrat and A. Escribano (2018), 'Estimation of Log-GARCH Models in the Presence of Zero Returns', European Journal of Finance 24, pp. 809-827, doi:10.1080/1351847X.2017.1336452
G. Sucarrat, S. Gronneberg and A. Escribano (2016), 'Estimation and Inference in Univariate and Multivariate Log-GARCH-X Models When the Conditional Density is Unknown', Computational Statistics and Data Analysis 100, pp. 582-594, doi:10.1016/j.csda.2015.12.005
See Also
lgarchSim
, coef.lgarch
, fitted.lgarch
, logLik.lgarch
, print.lgarch
, residuals.lgarch
and vcov.lgarch
Examples
##simulate 500 observations w/default parameter values:
set.seed(123)
y <- lgarchSim(500)
##estimate a log-garch(1,1) w/least squares:
mymod <- lgarch(y)
##estimate the same model, but w/cex2 method:
mymod2 <- lgarch(y, method="cex2")
##print results:
print(mymod); print(mymod2)
##extract coefficients:
coef(mymod)
##extract Gaussian log-likelihood (zeros excluded) of the log-garch model:
logLik(mymod)
##extract Gaussian log-likelihood (zeros excluded) of the arma representation:
logLik(mymod, arma=TRUE)
##extract variance-covariance matrix:
vcov(mymod)
##extract and plot the fitted conditional standard deviation:
sdhat <- fitted(mymod)
plot(sdhat)
##extract and plot standardised residuals:
zhat <- residuals(mymod)
plot(zhat)
##extract and plot all the fitted series:
myhat <- fitted(mymod, verbose=TRUE)
plot(myhat)
Auxiliary functions
Description
lgarchObjective and lgarchRecursion1 are auxiliary functions called by lgarch
. The functions are not intended for the average user.
Usage
lgarchObjective(pars, aux)
lgarchRecursion1(pars, aux)
Arguments
pars |
numeric vector with the parameters of the ARMA representation |
aux |
auxiliary list |
Details
To understand the structure and content of pars and aux, see the source code of the lgarch
function
Value
lgarchObjectivek()
returns the value of the objective function (either the log-likelihood or the residual sum of squares) used in estimating the ARMA representation. lgarchRecursion1 returns the residuals of the ARMA representation associated with the ARMA parameters pars
Author(s)
Genaro Sucarrat, https://www.sucarrat.net/
References
C. Francq and G. Sucarrat (2018), 'An Exponential Chi-Squared QMLE for Log-GARCH Models Via the ARMA Representation', Journal of Financial Econometrics 16, pp. 129-154 doi:10.1093/jjfinec/nbx032
G. Sucarrat, S. Gronneberg and A. Escribano (2016), 'Estimation and Inference in Univariate and Multivariate Log-GARCH-X Models When the Conditional Density is Unknown', Computational Statistics and Data Analysis 100, pp. 582-594, doi:10.1016/j.csda.2015.12.005
See Also
Simulate from a univariate log-GARCH model
Description
Simulate the y series (typically a financial return or the error in a regression) from a log-GARCH model. Optionally, the conditional standard deviation, the standardised error (z) and their logarithmic transformations are also returned.
Usage
lgarchSim(n, constant = 0, arch = 0.05, garch = 0.9, xreg = NULL,
backcast.values = list(lnsigma2 = NULL, lnz2 = NULL, xreg = NULL),
check.stability = TRUE, innovations = NULL, verbose = FALSE,
c.code=TRUE)
Arguments
n |
integer, length of y (i.e. number of observations) |
constant |
the value of the intercept in the log-volatility specification |
arch |
numeric vector with the arch coefficients |
garch |
numeric vector with the garch coefficients |
xreg |
numeric vector (of length n) with the conditioning values |
backcast.values |
backcast values for the recursion (chosen automatically if NULL) |
check.stability |
logical. If TRUE (default), then the roots of arch+garch are checked for stability |
innovations |
Etiher NULL (default) or a vector of length n with the standardised errors (i.e. z). If NULL, then the innovations are normal with mean zero and unit variance |
verbose |
logical. If FALSE (default), then only the vector y is returned. If TRUE, then a matrix with all the output is returned |
c.code |
logical. If TRUE (default), then compiled C-code is used for the recursion (faster) |
Details
Empty
Value
A zoo
vector of length n
if verbose = FALSE
(default), or a zoo
matrix with n
rows if verbose = TRUE
.
Author(s)
Genaro Sucarrat, https://www.sucarrat.net/
References
G. Sucarrat, S. Gronneberg and A. Escribano (2016), 'Estimation and Inference in Univariate and Multivariate Log-GARCH-X Models When the Conditional Density is Unknown', Computational Statistics and Data Analysis 100, pp. 582-594, doi:10.1016/j.csda.2015.12.005
See Also
mlgarchSim
, lgarch
, mlgarch
and zoo
Examples
##simulate 500 observations w/default parameter values:
set.seed(123)
y <- lgarchSim(500)
##simulate the same series, but with more output:
set.seed(123)
y <- lgarchSim(500, verbose=TRUE)
head(y)
##plot the simulated values:
plot(y)
##simulate w/conditioning variable:
x <- rnorm(500)
y <- lgarchSim(500, xreg=0.05*x)
##simulate from a log-GARCH with a simple form of leverage:
z <- rnorm(500)
zneg <- as.numeric(z < 0)
zneglagged <- glag(zneg, pad=TRUE, pad.value=0)
y <- lgarchSim(500, xreg=0.05*zneglagged, innovations=z)
##simulate from a log-GARCH w/standardised t-innovations:
set.seed(123)
n <- 500
df <- 5
z <- rt(n, df=df)/sqrt(df/(df-2))
y <- lgarchSim(n, innovations=z)
Estimate a multivariate CCC-log-GARCH(1,1) model
Description
Fit a multivariate Constant Conditional Correlation (CCC) log-GARCH(1,1) model with multivariate Gaussian Quasi Maximum Likelihood (QML) via the VARMA representation, see Sucarrat, Gronneberg and Escribano (2013). Zero-values on y are treated as missing values, as suggested in Sucarrat and Escribano (2013). Estimation is via the nlminb
function, whereas a numerical estimate of the Hessian is obtained with optimHess
for the computation of the variance-covariance matrix
Usage
mlgarch(y, arch = 1, garch = 1, xreg = NULL, initial.values = NULL,
lower = NULL, upper = NULL, nlminb.control = list(), vcov = TRUE,
objective.penalty = NULL, solve.tol = .Machine$double.eps, c.code = TRUE)
Arguments
y |
a numeric matrix, typically financial returns or regression errors |
arch |
the arch order (i.e. an integer equal to or greater than 0). The default is 1. NOTE: in the current version the order cannot be greater than 1 |
garch |
the garch order (i.e. an integer equal to or greater than 0). The default is 1. NOTE: in the current version the order cannot be greater than 1 |
xreg |
a vector or a matrix with the conditioning variables. The x-variables enter in each of the equations |
initial.values |
NULL (default) or a vector with the initial values of the VARMA representation |
lower |
NULL (default) or a vector with the lower bounds of the parameter space (of the VARMA representation). If NULL, then the values are automatically chosen |
upper |
NULL (default) or a vector with the upper bounds of the parameter space (of the VARMA representation). If NULL, then the values are automatically chosen |
nlminb.control |
list of control options passed on to the |
vcov |
logical. If TRUE (default), then the variance-covariance matrix is computed. The FALSE options makes estimation faster, but the variance-covariance matrix cannot be extracted subsequently |
objective.penalty |
NULL (default) or a numeric value. If NULL, then the log-likelihood value associated with the initial values is used. Sometimes estimation can result in NA and/or +/-Inf values (this can be fatal for simulations). The value objective.penalty is the value returned by the log-likelihood function |
solve.tol |
The function |
c.code |
logical. TRUE (default) is (much) faster, since it makes use of compiled C-code |
Value
A list of class 'mlgarch'
Note
Empty
Author(s)
Genaro Sucarrat, https://www.sucarrat.net/
References
G. Sucarrat and A. Escribano (2018), 'Estimation of Log-GARCH Models in the Presence of Zero Returns', European Journal of Finance 24, pp. 809-827, doi:10.1080/1351847X.2017.1336452
G. Sucarrat, S. Gronneberg and A. Escribano (2016), 'Estimation and Inference in Univariate and Multivariate Log-GARCH-X Models When the Conditional Density is Unknown', Computational Statistics and Data Analysis 100, pp. 582-594, doi:10.1016/j.csda.2015.12.005
See Also
lgarchSim
, coef.lgarch
, fitted.lgarch
, logLik.lgarch
, print.lgarch
, residuals.lgarch
and vcov.lgarch
Examples
##simulate from a 2-dimensional ccc-log-garch(1,1) w/defaults:
set.seed(123)
y <- mlgarchSim(1000)
##estimate a 2-dimensional ccc-log-garch(1,1):
mymod <- mlgarch(y)
##print results:
print(mymod)
##extract ccc-log-garch coefficients:
coef(mymod)
##extract Gaussian log-likelihood (zeros excluded) of the ccc-log-garch model:
logLik(mymod)
##extract Gaussian log-likelihood (zeros excluded) of the varma representation:
logLik(mymod, varma=TRUE)
##extract variance-covariance matrix:
vcov(mymod)
##extract and plot the fitted conditional standard deviations:
sdhat <- fitted(mymod)
plot(sdhat)
##extract and plot standardised residuals:
zhat <- residuals(mymod)
plot(zhat)
Auxiliary functions
Description
mlgarchObjective and mlgarchRecursion1 are auxiliary functions called by mlgarch
. The functions are not intended for the average user.
Usage
mlgarchObjective(pars, aux)
mlgarchRecursion1(pars, aux)
Arguments
pars |
numeric vector of VARMA parameters |
aux |
auxiliary list |
Details
To understand the structure and content of pars and aux, see the source code of the mlgarch
function
Value
mlgarchObjective returns the log-likelihood of the VARMA representation, whereas mlgarchRecursion1 returns the residuals of the VARMA representation associated with the VARMA parameters pars
Author(s)
Genaro Sucarrat, https://www.sucarrat.net/
References
G. Sucarrat, S. Gronneberg and A. Escribano (2016), 'Estimation and Inference in Univariate and Multivariate Log-GARCH-X Models When the Conditional Density is Unknown', Computational Statistics and Data Analysis 100, pp. 582-594, doi:10.1016/j.csda.2015.12.005
See Also
Simulate from a multivariate log-GARCH(1,1) model
Description
Simulate the y series (typically a collection of financial returns or regression errors) from a log-GARCH model. Optionally, the conditional standard deviation and the standardised error, together with their logarithmic transformations, are also returned.
Usage
mlgarchSim(n, constant = c(0,0), arch = diag(c(0.1, 0.05)),
garch = diag(c(0.7, 0.8)), xreg = NULL,
backcast.values = list(lnsigma2 = NULL, lnz2 = NULL, xreg = NULL),
innovations = NULL, innovations.vcov = diag(rep(1,
length(constant))), check.stability = TRUE, verbose = FALSE)
Arguments
n |
integer, i.e. number of observations |
constant |
vector with the values of the intercepts in the log-volatility specification |
arch |
matrix with the arch coefficients |
garch |
matrix with the garch coefficients |
xreg |
a vector (of length n) or matrix (with rows n) with the values of the conditioning variables. The first column enters the first equation, the second enters the second equation, and so on |
backcast.values |
backcast values for the recursion (chosen automatically if NULL) |
check.stability |
logical. If TRUE (default), then the system is checked for stability |
innovations |
Either NULL (default) or a vector or matrix of length n with the standardised errors. If NULL, then the innovations are multivariate N(0,1) with correlations equal to zero |
innovations.vcov |
numeric matrix, the variance-covariance matrix of the standardised multivariate normal innovations. Only applicable if innovations = NULL |
verbose |
logical. If FALSE (default), then only the matrix with the y series is returned. If TRUE, then also additional information is returned |
Details
Empty
Value
A zoo
matrix with n rows.
Author(s)
Genaro Sucarrat, https://www.sucarrat.net/
References
G. Sucarrat, S. Gronneberg and A. Escribano (2016), 'Estimation and Inference in Univariate and Multivariate Log-GARCH-X Models When the Conditional Density is Unknown', Computational Statistics and Data Analysis 100, pp. 582-594, doi:10.1016/j.csda.2015.12.005
See Also
Examples
##simulate from a multivariate ccc-log-garch(1,1) w/defaults:
set.seed(123)
y <- mlgarchSim(500)
##simulate the same series, but with more output:
set.seed(123)
y <- mlgarchSim(500, verbose=TRUE)
head(y)
##plot the simulated values:
plot(y)
Random number generation from the multivariate normal distribution
Description
This function is a speed-optimised version of the rmnorm
function from the mnormt package of Adelchi Azzalini (2013).
Usage
rmnorm(n, mean = NULL, vcov = 1)
Arguments
n |
integer, the number of observations to generate |
mean |
numeric vector, i.e. the mean values |
vcov |
numeric matrix, i.e. the variance-covariance matrix |
Details
Empty
Value
A matrix of n
rows
Author(s)
Genaro Sucarrat, https://www.sucarrat.net/
References
Adelchi Azzalini (2013): 'mnormt: The multivariate normal and t distributions', R package version 1.4-7, https://CRAN.R-project.org/package=mnormt
Examples
##generate from univariate standardised normal:
z1 <- rmnorm(100)
##generate from bivariate, independent standardised normal:
z2 <- rmnorm(100, vcov=diag(c(1,1)))
##generate from bivariate, dependent standardised normal:
z3 <- rmnorm(100, vcov=cbind(c(1,0.3),c(0.3,1)))