EstimateDMQ {DMQ}R Documentation

Estimate the Dynamic Multiple Quantile (DMQ) model.

Description

Estimate the parameters of the DMQ model using the estimator detailed in Catania and Luati (2023).

Usage

EstimateDMQ(vY, vTau, iTau_star = NULL, vPn_Starting = NULL, 
                        FixReference = FALSE, FixOthers = FALSE, 
                        ScalingType = "InvSqrt",
                         vQ_0 = NULL,  
                         fn.optimizer = fn.DEoptim, 
                        cluster = NULL, smooth = NULL, ...)

Arguments

vY

numeric vector of length Tx1 containing the time series of observations.

vTau

numeric vector of length Jx1 containing probability levels at which quantiles are estimated.

iTau_star

Integer indicating the position in vTau where the reference quantile is placed. For instance, if vTau = seq(0.01, 0.99, 0.01) then iTau_star = 50 means that the median is used as the reference quantile.

vPn_Starting

numeric named vector of length 4x1 with starting values for the optimizer. For example vPn_Starting = c("phi" = 0.9, "gamma" = 0.05, "alpha" = 0.01, "beta" = 0.7).

FixReference

logical. Should the reference quantile be fixed? By default FixReference = FALSE.

FixOthers

logical. Should the quantiles other than the reference quantile be fixed? By default FixOthers = FALSE.

ScalingType

character Indicating the scaling mechanism for the conditional quasi score. Possible choices are "Identity", "Inv","InvSqrt". When ScalingType = "InvSqrt" quasi scores are scaled by their standard deviation. When ScalingType = "Inv" quasi scores are scaled by their variance. When ScalingType = "Identity" quasi scores are not scaled. Default value ScalingType = "InvSqrt".

vQ_0

numeric. Vector of limiting quantiles evaluated at vTau. By default FixOthers = NULL meaning that empirical unconditional quantilies are used.

fn.optimizer

function. This is a generic optimization function that can be provided by the user. By default fn.optimizer = fn.DEoptim where fn.DEoptim is a wrapper to the DEoptim function of the package DEoptim. See the Details and Examples sections for user defined optimization routines.

cluster

A cluster object created calling using the paralell package. If supplied parallel processing is used to speed up the computations if fn.optimizer makes use of it. When fn.optimizer = fn.DEoptim parallel computation can be used.

smooth

logical. Should a smooth version of the objective function should be used? If using a gradient based optimizer like fn.optimizer = fn.optim is it advised to set smooth = TRUE. By default, when fn.optimizer = fn.DEoptim we set smooth = FALSE and when fn.optimizer = fn.optim or fn.optimizer = fn.solnp we set smooth = TRUE.

...

Additional arguments to be passed to fn.optimizer.

Details

Starting values for the optimizer are by default set as c("phi" = 0.94, "gamma" = 0.10, "alpha" = 0.05, "beta" = 0.95).
The user is free to employ his/her own optimization routine via the fn.optimizer argument. fn.optimizer accepts a function object. The user provided optimizer has to satisfy strict requirements. The arguments of the fn.optimizer are:

par0

a vector of starting values,

vY

the data provided,

FUN

the objective function,

LB

vector of lower bounds for the parameters,

UB

vector of upper bounds for the parameters.

...

additional arguments.

The output of fn.optimizer has to be an object of the class list with four named elements:

pars

a numeric vector where the estimated parameters are stored,

value

a numeric containing the value of the objective function evaluated at its minimum,

hessian

a numeric matrix containing the Hessian matrix evaluated at the minimum of the objective function, this is used for inferential purposes,

convergence

a numeric variable reporting information about the convergence of the optimization. convergence = 0 has to indicate successful completion.

The user is allowed to not include the last two elements of the output of the fn.optimizer function, that is, the values hessian = NULL and convergence = NULL are admissible. In the case of hessian = NULL, no standard errors will be computed.

Value

A list with, among others, elements:

lFilter

A list containing the output from the filtering procedure. For instance filtered quantiles, hit variables, and losses.

vPn

numeric named vector of estimated parameters.

optimizer

A list with the output from fn.optimizer.

Inference

A list with output from the inferential procedure.

Author(s)

Leopoldo Catania

References

Catania, L, and Luati, A. (2023). "Semiparametric modeling of multiple quantiles." Journal of Econometrics doi:10.1016/j.jeconom.2022.11.002.

Examples

# Load Microsoft Corporation logarithmic percentage returns from December 8, 
# 2010 to November 15, 2018 for a total of T = 2000 observation
data("MSFT")

##############################################################
######################## Estimate DMQ ########################
##############################################################

# Deciles
vTau = seq(0.1, 0.9, 0.1)

# Reference quantile to the median
iTau_star = 5

# Fix the reference quantile to a constant
FixReference = TRUE

# Estimate DMQ
Fit_solnp = EstimateDMQ(vY = vY,
                  vTau = vTau,
                  iTau_star = iTau_star,
                  FixReference = FixReference,
                  fn.optimizer = fn.solnp,
                  cluster = cluster)

Fit_solnp$vPn
Fit_solnp$optimizer$value

## Not run: 
#### Estimate DMQ using different optimizers

# With the DEoptim optimizer

# parallel computation
iG = 7
cluster = makeCluster(iG)

set.seed(123)

# Estimate DMQ
Fit_DEoptim = EstimateDMQ(vY = vY,
                  vTau = vTau,
                  iTau_star = iTau_star,
                  FixReference = FixReference,
                  fn.optimizer = fn.DEoptim,
                  cluster = cluster)

Fit_DEoptim$vPn
Fit_DEoptim$optimizer$value

# Estimate the model with a user defined optimizer.
# Let's use the gosolnp() optimizer from the Rsolnp package.

library("Rsolnp")
fn.gosolnp <- function(par0, vY, FUN, LB, UB, ...) {
  
  foo = list(...)
  if (!is.null(foo$cluster)) {
    cluster = foo$cluster
    clusterEvalQ(cluster, library(DMQ))
  } 
  
  optimiser = gosolnp(
    pars = par0,
    fun = FUN, vY = vY, 
    n.sim = 1000,
    n.restarts = 5,
    LB = LB,
    UB = UB, control = list(trace = 1), 
    ...)
  
  out = list(pars = optimiser$pars,
             value = tail(optimiser$values, 1),
             hessian = optimiser$hessian,
             convergence = optimiser$convergence)
  
  return(out)
  
}

set.seed(123)
# Estimate DMQ
Fit_gosolnp = EstimateDMQ(vY = vY,
                  vTau = vTau,
                  iTau_star = iTau_star,
                  FixReference = FixReference,
                  fn.optimizer = fn.gosolnp,
                  cluster = cluster,
                  smooth = TRUE) 

Fit_gosolnp$vPn
Fit_gosolnp$optimizer$value

stopCluster(cluster)


## End(Not run)

[Package DMQ version 0.1.2 Index]