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 |
|
vTau |
|
iTau_star |
Integer indicating the position in |
vPn_Starting |
|
FixReference |
|
FixOthers |
|
ScalingType |
|
vQ_0 |
|
fn.optimizer |
|
cluster |
A |
smooth |
|
... |
Additional arguments to be passed to |
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 |
vPn |
|
optimizer |
A |
Inference |
A |
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)