midas_qr: Restricted MIDAS quantile regression

Description Usage Arguments Value Author(s) Examples

View source: R/midasqr.R

Description

Estimate restricted MIDAS quantile regression using nonlinear quantile regression

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
midas_qr(
  formula,
  data,
  tau = 0.5,
  start,
  Ofunction = "nlrq",
  weight_gradients = NULL,
  guess_start = TRUE,
  ...
)

Arguments

formula

formula for restricted MIDAS regression or midas_qr object. Formula must include mls function

data

a named list containing data with mixed frequencies

tau

quantile

start

the starting values for optimisation. Must be a list with named elements.

Ofunction

the list with information which R function to use for optimisation. The list must have element named Ofunction which contains character string of chosen R function. Other elements of the list are the arguments passed to this function. The default optimisation function is optim with argument method="BFGS". Other supported functions are nls

weight_gradients

a named list containing gradient functions of weights. The weight gradient function must return the matrix with dimensions d_k \times q, where d_k and q are the number of coefficients in unrestricted and restricted regressions correspondingly. The names of the list should coincide with the names of weights used in formula. The default value is NULL, which means that the numeric approximation of weight function gradient is calculated. If the argument is not NULL, but the name of the weight used in formula is not present, it is assumed that there exists an R function which has the name of the weight function appended with _gradient.

guess_start,

logical, if TRUE tries certain strategy to improve starting values

...

additional arguments supplied to optimisation function

Value

a midas_r object which is the list with the following elements:

coefficients

the estimates of parameters of restrictions

midas_coefficients

the estimates of MIDAS coefficients of MIDAS regression

model

model data

unrestricted

unrestricted regression estimated using midas_u

term_info

the named list. Each element is a list with the information about the term, such as its frequency, function for weights, gradient function of weights, etc.

fn0

optimisation function for non-linear least squares problem solved in restricted MIDAS regression

rhs

the function which evaluates the right-hand side of the MIDAS regression

gen_midas_coef

the function which generates the MIDAS coefficients of MIDAS regression

opt

the output of optimisation procedure

argmap_opt

the list containing the name of optimisation function together with arguments for optimisation function

start_opt

the starting values used in optimisation

start_list

the starting values as a list

call

the call to the function

terms

terms object

gradient

gradient of NLS objective function

hessian

hessian of NLS objective function

gradD

gradient function of MIDAS weight functions

Zenv

the environment in which data is placed

use_gradient

TRUE if user supplied gradient is used, FALSE otherwise

nobs

the number of effective observations

convergence

the convergence message

fitted.values

the fitted values of MIDAS regression

residuals

the residuals of MIDAS regression

Author(s)

Vaidotas Zemlys-Balevicius

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
##Take the same example as in midas_r

theta_h0 <- function(p, dk, ...) {
   i <- (1:dk-1)/100
   pol <- p[3]*i + p[4]*i^2
   (p[1] + p[2]*i)*exp(pol)
}

##Generate coefficients
theta0 <- theta_h0(c(-0.1,10,-10,-10),4*12)

##Plot the coefficients
plot(theta0)

##Generate the predictor variable
xx <- ts(arima.sim(model = list(ar = 0.6), 600 * 12), frequency = 12)

##Simulate the response variable
y <- midas_sim(500, xx, theta0)

x <- window(xx, start=start(y))

##Fit quantile regression. All the coefficients except intercept should be constant.
##Intercept coefficient should correspond to quantile function of regression errors.
mr <- midas_qr(y~fmls(x,4*12-1,12,theta_h0), tau = c(0.1, 0.5, 0.9),
              list(y=y,x=x),
              start=list(x=c(-0.1,10,-10,-10)))
              
mr

Example output

Loading required package: sandwich
Loading required package: optimx
Loading required package: quantreg
Loading required package: SparseM

Attaching package: 'SparseM'

The following object is masked from 'package:base':

    backsolve


MIDAS quantile regression model with "ts" data:
Start = 104, End = 600
 model: y ~ fmls(x, 4 * 12 - 1, 12, theta_h0) 
   tau: 0.1 0.5 0.9 
                 0.1       0.5       0.9
(Intercept)  -1.1051   0.01782   1.26970
x1           -0.1199  -0.08774  -0.09659
x2           10.6963   9.94230  11.30375
x3          -10.2959 -10.34209 -12.35247
x4          -10.0817  -8.43921  -2.95119

Function nlrq was used for fitting

midasr documentation built on Feb. 23, 2021, 5:11 p.m.