ugarchfit-methods | R Documentation |
Method for fitting a variety of univariate GARCH models.
ugarchfit(spec, data, out.sample = 0, solver = "solnp", solver.control = list(),
fit.control = list(stationarity = 1, fixed.se = 0, scale = 0, rec.init = 'all',
trunclag = 1000),
numderiv.control = list(grad.eps=1e-4, grad.d=0.0001,
grad.zero.tol=sqrt(.Machine$double.eps/7e-7), hess.eps=1e-4, hess.d=0.1,
hess.zero.tol=sqrt(.Machine$double.eps/7e-7), r=4, v=2),...)
data |
A univariate data object. Can be a numeric vector, matrix, data.frame, zoo, xts, timeSeries, ts or irts object. |
spec |
A univariate GARCH spec object of class |
out.sample |
A positive integer indicating the number of periods before the last to keep for out of sample forecasting (see details). |
solver |
One of either “nlminb”, “solnp”, “lbfgs”, “gosolnp”, “nloptr” or “hybrid” (see notes). |
solver.control |
Control arguments list passed to optimizer. |
fit.control |
Control arguments passed to the fitting routine. Stationarity explicitly imposes
the variance stationarity constraint during optimization. For the FIGARCH model
this imposes the positivity constraint. The fixed.se argument
controls whether standard errors should be calculated for those parameters which
were fixed (through the fixed.pars argument of the |
numderiv.control |
Control arguments passed to the numerical routines for the calculation of the standard errors. See the documentation in the numDeriv package for further details. The arguments which start with ‘hess’ are passed to the hessian routine while those with ‘grad’ to the jacobian routine. |
... |
For the multiplicative component sGARCH model (mcsGARCH), the additional argument ‘DailyVar’ is required and should be an xts object of the daily forecasted variance to use with the intraday data. |
The GARCH optimization routine first calculates a set of feasible starting
points which are used to initiate the GARCH recursion. The main part of the
likelihood calculation is performed in C-code for speed.
The out.sample option is provided in order to carry out forecast performance
testing against actual data. A minimum of 5 data points are required for these
tests. If the out.sample option is positive, then the routine will fit only
N - out.sample (where N is the total data length) data points, leaving
out.sample points for forecasting and testing using the forecast performance
measures. In the ugarchforecast
routine the n.ahead may also be
greater than the out.sample number resulting in a combination of out of sample
data points matched against actual data and some without, which the forecast
performance tests will ignore.
The “gosolnp” solver allows for the initialization of multiple restarts
of the solnp solver with randomly generated parameters (see documentation in
the Rsolnp-package for details of the strategy used). The solver.control list
then accepts the following additional (to the solnp) arguments: “n.restarts”
is the number of solver restarts required (defaults to 1), “parallel”
(logical), “pkg” (either snowfall or multicore) and “cores”
(the number of cores or workers to use) for use of parallel functionality,
“rseed” is the seed to initialize the random number generator, and
“n.sim” is the number of simulated parameter vectors to generate per
n.restarts.
The “hybrid” strategy solver first tries the “solnp” solver, in
failing to converge then tries then “nlminb”, the “gosolnp” and
finally the “nloptr” solvers. Solver control parameters can be passed for
all the solvers in the solver.control list as one long list which will be
filtered for each solver's specific options as and when that solver is called
during the hybrid strategy optimization. It is still possible that the Hessian
at the optimal found cannot be inverted, in which case a warning is printed and
there will not be any standard errors. In this case it is suggested that the
problem is re-run with different solver parameters. It is also possible that the
solution, while still ‘almost’ optimal may be at a saddle-point very near
the global optimum in which case the Hessian may still be invertible but one
eigenvalue is negative. The uGARCHfit object has a value in the fit slot
called condH (object@fit$condH) which indicates the approximate number of decimal
places lost to roundoff/numerical estimation error. When this is NaN, this
indicates the case just described of one negative eigenvalue/saddlepoint (this
previously flagged a warning but is now silenced and it is upto to the user to
decide whether it is worth investigating further).
A uGARCHfit
object containing details of the GARCH fit.
The nloptr solver takes the following options in the solver.control list:
ftol_rel | function value relative tolerance | default: 1e-8 | |
xtol_rel | parameter value relative tolerance | default: 1e-6 | |
maxeval | maximum function evaluations | default: 25000 | |
print_level | trace level | default: 1 | |
solver | the nloptr solver to use | default: 1 (‘SBPLX’). | |
The solver option for nloptr has 10 different choices (1:10), which are 1:‘COBYLA’, 2:‘BOBYQA’, 3:‘PRAXIS’, 4:‘NELDERMEAD’, 5:‘SBPLX’, 6:‘AUGLAG’+‘COBYLA’, 7:‘AUGLAG’+‘BOBYQA’, 8:‘AUGLAG’+‘PRAXIS’, 9:‘AUGLAG’+‘NELDERMEAD’ and 10:‘AUGLAG’+‘SBPLX’. As always, your mileage will vary and care should be taken on the choice of solver, tuning parameters etc. If you do use this solver try 9 or 10 first.
Alexios Ghalanos
For specification ugarchspec
,filtering ugarchfilter
,
forecasting ugarchforecast
, simulation ugarchsim
,
rolling forecast and estimation ugarchroll
, parameter distribution
and uncertainty ugarchdistribution
, bootstrap forecast
ugarchboot
.
# Basic GARCH(1,1) Spec
data(dmbp)
spec = ugarchspec()
fit = ugarchfit(data = dmbp[,1], spec = spec)
fit
coef(fit)
head(sigma(fit))
#plot(fit,which="all")
# in order to use fpm (forecast performance measure function)
# you need to select a subsample of the data:
spec = ugarchspec()
fit = ugarchfit(data = dmbp[,1], spec = spec, out.sample=100)
forc = ugarchforecast(fit, n.ahead=100)
# this means that 100 data points are left from the end with which to
# make inference on the forecasts
fpm(forc)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.