Learn R Programming

MSGARCH (version 0.17.7)

kernel: Kernel function.

Description

Method returning the kernel value of a vector of observations given a model specification.

Usage

kernel(object, theta, y, log = TRUE)

Arguments

object
Model specification of class MSGARCH_SPEC created with create.spec or fit object of type MSGARCH_MLE_FIT created with fit.mle or MSGARCH_BAY_FIT created with fit.bayes.
theta
Vector (of size d) or matrix (of size M x d) of parameter estimates (not require when using a fit object).
y
Vector (of size T) of observations (not require when using a fit object).
log
Boolean indicating if the log kernel is returned. (Default: log = TRUE)

Value

(Log-)Kernel value (scalar or vector of size M) of the vector of observations.

Details

If a matrix of parameter estimates is given, each parameter estimates is evaluated individually. The kernel is a combination of the prior and the likelihood function. The kernel is equal to prior($\theta$) + L(y|$\theta$) where L is the likelihood of y given the parameter $\theta$. When doing optimization, the goal is to minimize the negative log-kernel.
  • Details on the prior The prior is different for each specification. It ensures that the $\theta$ makes the conditional variance process stationary, positive, and that it respect that the sums of the probabilities in the case of a multiple-regime models are all equal to 1. If any of these three conditions is not respected the prior return -1e10, meaning that the optimizer or sampler will know that $\theta$ is not a good candidate.

References

Hamilton, J. D. (1989) A New Approach to the Economic Analysis of Nonstationary Time Series and the Business Cycle. Econometrica, 57, pp.357-38

Examples

Run this code
# load data
data("sp500")
sp500 = sp500[1:1000]

# create model specification
spec = MSGARCH::create.spec() 

# fit the model on the data with ML estimation using DEoptim intialization
set.seed(123)
fit = MSGARCH::fit.mle(spec = spec, y = sp500, ctr = list(do.init = FALSE))

# compute the kernel
kernel = MSGARCH::kernel(fit, log = TRUE)

Run the code above in your browser using DataLab