| FitML | R Documentation |
Method that performs Maximum Likelihood estimation
of a MSGARCH_SPEC object on a set of observations.
FitML(spec, data, ctr = list())
spec |
Model specification created with |
data |
Vector (of size T) of observations. |
ctr |
A list of control parameters:
|
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.
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.
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
# 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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.