Learn R Programming

SVDNF (version 0.1.10)

DNFOptim.dynamicsSVM: Discrete Nonlinear Filter Maximum Likelihood Estimation Function

Description

The DNFOptim function finds maximum likelihood estimates for stochastic volatility models parameters using the DNF function.

Usage

# S3 method for dynamicsSVM
DNFOptim(dynamics, data, par, factors, tol, N = 50, K = 20, R = 1,
  grids = 'Default', 
  rho = 0, delta = 0, alpha = 0, rho_z = 0, nu = 0, jump_params_list = "dummy",
  ...)

Value

optim

Returns a list obtained from R's optim function. See help(optim) for details about the output.

SVDNF

Returns a SVDNF object obtained from running the DNF function at the MLE parameter values. See help(DNF) for details about the output

rho, delta, alpha, rho_z, nu

See help(dynamicsSVM) for a description of each of these arguments individually. If they are estimated, they are set to 'var'. If the parameters were fixed during the estimation, this will return the value at which they were fixed.

Arguments

dynamics

A dynamicsSVM object representing the model dynamics to be used by the optimizer to find maximum likelihood parameter estimates.This should be a vector or an xts object.

data

A series of asset returns for which we want to find maximum likelihood estimates.

par

Initial values for the parameters to be optimized over. Information about how to pass the initial parameters is given in the 'Note' section.

factors

Series of values taken by d explanatory variables. This should be a matrix or an xts object with d rows and T columns.

tol

Tolerance hyperparameter for the optimization. The optim function will be rerun until the difference between the maximum values for the likelihood function is less than tol. After the first optim call, which uses the initial parameters, the next optimizers are run using the previous optimizer's maximum likelihood parameter estimates as initial values.

N

Number of nodes in the variance grid.

K

Number of nodes in the jump size grid.

grids

Grids to be used for numerical integration by the DNF function. The DNF function creates grids for built-in models. However, this arguments must be provided for custom models. It should contain a list of three sequences: var_mid_points (variance mid-point sequence), j_nums (sequence for the number of jumps), and jump_mid_points (jump mid-point sequence). If there are no variance jumps in the model, set jump_mid_points equal to zero. If there are no jumps in the model, both j_nums and jump_mid_points should be set to zero.

R

Maximum number of jumps used in the numerical integration at each timestep.

rho, delta, alpha, rho_z, nu

See help(dynamicsSVM) for a description of each of these arguments individually. These arguments should be used only for custom models and can be fixed to a certain value (e.g., rho = -0.75). If they are estimated, they should be set to 'var' (e.g., to estimate rho set rho = 'var') and include it in the vector par to be passed to the optim function. See Note for more details on the order in which custom models should receive parameters.

jump_params_list

List of the names of the arguments in the jump parameter distribution in the order that they are used by the jump_dist function. This is used by DNFOptim to check for parameters that occur both in the jump_dist function and as arguments in drift or diffusion functions.

...

Further arguments to be passed to the optim function. See Note.

References

R Core Team (2019). R: A language and environment for statistical computing. R Foundation for Statistical Computing, Vienna, Austria. URL https://www.R-project.org/.

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)
plot(Taylor_sim$volatility_factor, type = 'l')
plot(Taylor_sim$returns, type = 'l')

# 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)

# Plot prediction and filtering distributions
plot(optim_test)

Run the code above in your browser using DataLab