FitML: Maximum Likelihood estimation.

View source: R/FitML.R

FitMLR Documentation

Maximum Likelihood estimation.

Description

Method that performs Maximum Likelihood estimation of a MSGARCH_SPEC object on a set of observations.

Usage

FitML(spec, data, ctr = list())

Arguments

spec

Model specification created with CreateSpec.

data

Vector (of size T) of observations.

ctr

A list of control parameters:

  • par0: Vector (of size d) where d must have the same length as the default parameters of the specification. It is the starting value for the optimizer (if empty the the method automatically set starting parameters; see *Details*).

  • do.se Logical. Should standard errors be computed? (Default: do.se = TRUE).

  • do.plm Logical. If do.plm = FALSE, parameter transformation during the optimization step is performed without ensuring stationarity for the volatility processes. For combinations of parameters that do not imply stationarity the likelihood value is fixed at -1e10. If fixed is defined in the list contraint.spec of CreateSpec, do.plm = TRUE is used. (Default: do.plm = FALSE)

  • OptimFUN: Custom optimization function (see *Details*).

Details

By default, OptimFUN is set such that optimization is done via the well-known Broyden- Fletcher-Goldfarb-Shanno (BFGS) algorithm using the optim function with method = "BFGS". Starting values when par0 is not provided are chosen automatically before optimization (see Ardia et al. (2019) for more details)
OptimFUN allows for a custom optimizer to be used. The function must take the form:
function(vPw, f_nll, spec, data, do.plm),
where vPw are starting parameters (transformed), f_nll is the function to be minimize, spec is the specification, data is the data, and do.plm the originally inputed or default do.plm. The inputs spec, data, and do.plm must be passed as inputs in the optimizer (see *Examples*). It must output a list with the following elements:

  • value: Optimal negative log-likelihood.

  • par: Optimal parameters.

Value

A list of class MSGARCH_ML_FIT with the following elements:

  • par: Vector (of size d) of optimal parameters.

  • loglik: Log-likelihood of y given the optimal parameters.

  • Inference: list with elements MatCoef and Hessian. MatCoef is a matrix (of size d x 4) with optimal parameter estimates, standard errors, t-stats, and p-values. Hessian is the Hessian (matrix of size d x d) of the negative log-likelihood function evaluated at the optimal parameter estimates par.

  • spec: Model specification of class MSGARCH_SPEC created with CreateSpec.

  • data: Vector (of size T) of observations.

  • ctr: list of the control used for the fit.

The MSGARCH_ML_FIT with the following methods:

  • AIC: Akaike Information Criterion (AIC).

  • BIC: Bayesian Information Criterion (BIC).

  • simulate: Simulation.

  • Volatility: In-sample conditional volatility.

  • predict: Forecast of the conditional volatility (and predictive distribution).

  • UncVol: Unconditional volatility.

  • PredPdf: Predictive density (pdf).

  • PIT: Probability Integral Transform.

  • Risk: Value-at-Risk and Expected-Shortfall.

  • State: State probabilities (smoothed, filtered, predictive, Viterbi).

  • ExtractStateFit: Single-regime model extractor.

  • summary: Summary of the fit.

References

Ardia, D. Bluteau, K. Boudt, K. Catania, L. Trottier, D.-A. (2019). Markov-switching GARCH models in R: The MSGARCH package. Journal of Statistical Software, 91(4), 1-38. doi: 10.18637/jss.v091.i04

Examples

# create model specification
spec <- CreateSpec()

# load data
data("SMI", package = "MSGARCH")

# fit the model on the data by ML
fit <- FitML(spec = spec, data = SMI)
summary(fit)

# custom optimizer example
## Not run: 
f_custom_optim <- function(vPw, f_nll, spec, data, do.plm){
 out <- stats::optim(vPw, f_nll, spec = spec, data = data,
                     do.plm = do.plm, method = "Nelder-Mead")
 return(out)
}

set.seed(123)
fit <- FitML(spec, data = SMI, ctr = list(OptimFUN = f_custom_optim))
summary(fit)

## End(Not run)

MSGARCH documentation built on Dec. 6, 2022, 1:06 a.m.