Learn R Programming

SVDNF (version 0.1.10)

predict.DNFOptim: Predict Method for DNFOptim and SVDNF Objects

Description

This function generates Monte Carlo predictions for DNFOptim objects. The function does this by sampling volatilities from the discrete nonlinear filter's last filtering distribution. Then, using these volatilities as inital values for the modelSim function, the predict method generates n_sim path and estimates the means and confidence intervals for future volatility factor and return values.

Usage

# S3 method for DNFOptim
predict(object, n_ahead = 15, new_data = NULL, n_sim = 1000, confidence = 0.95, ...)

Value

A list containing the following components:

volatility_pred

A list with mean volatility values and confidence intervals. Contains the following components: UB_vol: the upper bound of the confidence interval for volatility, mean_vol_pred: the mean prediction for volatility, and LB_vol: the lower bound of the confidence interval for volatility.

ret_pred

A list with mean return values and confidence intervals. Contains the following components: (1) UB_ret: the upper bound of the confidence interval for mean returns, (2) mean_ret_pred: the mean prediction for mean returns, and (3) LB_ret: the lower bound of the confidence interval for mean returns.

object

The DNFOptim object input to the predict function.

confidence

The specified confidence level.

Arguments

object

An object of class "DNFOptim".

n_ahead

Number of periods ahead to predict.

new_data

An optional data frame of new predictor values for models with factors (e.g., the CAPM-SV model) for which we want to forecast returns and volatility values.

n_sim

Number of simulated paths used to estimate the future volatility factor and return means and confidence intervals.

confidence

Confidence level for prediction intervals. Should be between 0 and 1.

...

Other parameters to be passed through to function.

Details

This function uses Monte Carlo paths simulated from the MLE dynamics obtained via a DNFOptim object to generate predictions for a specified number of periods ahead. It returns predicted mean volatility and return values based on simulations with confidence intervals.

See Also

DNFOptim,

Examples

Run this code
set.seed(1)

# Generating return data
Taylor_mod <- dynamicsSVM(model = "Taylor", phi = 0.9,
  theta = -7.36, sigma = 0.363)
Taylor_sim <- modelSim(t = 30, dynamics = Taylor_mod, init_vol = -7.36)

# Initial values and optimization bounds
init_par <- c( 0.7, -5, 0.3)
lower <- c(0.01, -20, 0.1); upper <- c(0.99, 0, 1)

# Running DNFOptim to get MLEs
optim_test <- DNFOptim(data = Taylor_sim$returns,
  dynamics = Taylor_mod,
  par = init_par, lower = lower, upper = upper, method = "L-BFGS-B")
                
# Parameter estimates
summary(optim_test)

# Predict 5 steps ahead
preds <- predict(optim_test, n_ahead = 5)

# Plot predictions with 95 percent confidence interval
plot(preds)

Run the code above in your browser using DataLab