Learn R Programming

MSGARCH (version 0.17.7)

pit: Probability Integral Transform.

Description

Method returning the predictive probability integral transform (PIT) in-sample or of a vector of points at t = T + 1.

Usage

pit(object, x, theta, y, do.norm = 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).
do.norm
Boolean indicating if the PIT value are transforms into standard Normal variate. (Default: do.norm = FALSE).
do.its
Boolean indicating if the in-sample pit is returned. (Default: do.its = FALSE)

Value

A list of class MSGARCH_PIT containing two components:
  • pit: If do.its = FALSE: probability integral transform of the points x at t = T + 1 or Normal variate derived from the probability integral transform of x (vector of size N). If do.its = TRUE: In-sample probability integral transform or Normal variate derived from the probability integral transform of y (vector of size T or matrix of size M x T).
  • x: If do.its = FALSE: Vector (of size N) of at point t = T + 1 evaluated. If do.its = TRUE: Vector (of size T) of observations.
The class MSGARCH_PIT 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. The do.norm argument transforms the PIT value into Normal variate so that normality test can be done.

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 pit method in-sample              
pit.its = MSGARCH::pit(object = fit, do.norm = FALSE, do.its = TRUE)                              

plot(pit.its)  
                                                                         
# generate random draws at T + 1 from model
set.seed(123)
sim.ahead = MSGARCH::simahead(object = fit, n = 1, m = 100)

x = sim.ahead$draws

# run pit method on random draws at T + 1 from model
pit = MSGARCH::pit(object = fit, x = x, do.norm = FALSE)

plot(pit)

Run the code above in your browser using DataLab