Learn R Programming

MSGARCH (version 0.17.7)

pred: Predictive function.

Description

Method returning the predictive probability density in-sample or of a vector of points at t = T + 1.

Usage

pred(object, x, theta, y, log = FALSE, do.its = FALSE)

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.
x
Vector (of size N) of point at t = T + 1 to be evaluated (used when do.its = FALSE).
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-density is returned. (Default: log = FALSE)
do.its
Boolean indicating if the in-sample predictive is returned. (Default: do.its = FALSE)

Value

A list of class MSGARCH_PRED containing two components:
  • pred: If do.its = FALSE: (Log-)Predictive of of the points x at t = T + 1 (vector of size N). If do.its = TRUE: In-sample Predictive of y (vector of size T or matrix of size M x T).
  • x: If do.its = FALSE: Vector (of size N) of point at t = T + 1 evaluated. If do.its = TRUE: Vector (of size T) of observations.
The class MSGARCH_PRED contains the plot method only if do.its = FALSE.

Details

If a matrix of MCMC posterior draws estimates is given, the Bayesian Probability integral transform is calculated. If do.its = FALSE, the points x are evaluated as t = T + 1 realization and the method uses the variance estimate at t = T + 1. If do.its = TRUE, y is evaluated using their respective variance estimate at each time t.

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))
                           
# run pred method in-sample     
pred.its = MSGARCH::pred(object = fit, log = TRUE, do.its = TRUE)  

sum(pred.its$pred, na.rm = TRUE)
                                             
# create mesh
x = seq(-3,3,0.01)

# run pred method on mesh at T + 1
pred = MSGARCH::pred(object = fit, x = x, log = TRUE, do.its = FALSE)

plot(pred)

Run the code above in your browser using DataLab