Create the regressors of the variance equation
regressorsVariance.Rd
The function generates the regressors of the log-variance equation in an arx
model. The returned value is a matrix
with the regressors and, by default, the regressand in column one. By default, observations (rows) with missing values are removed in the beginning and the end with na.trim
, and the returned matrix is a zoo
object.
Usage
regressorsVariance(e, vc = TRUE, arch = NULL, asym = NULL,
log.ewma = NULL, vxreg = NULL, zero.adj = 0.1, vc.adj = TRUE,
return.regressand = TRUE, return.as.zoo = TRUE, na.trim = TRUE,
na.omit = FALSE)
Arguments
- e
numeric vector, time-series or
zoo
object.- vc
logical.
TRUE
includes an intercept in the log-variance specification, whereasFALSE
(default) does not. If the log-variance specification contains any other item but the log-variance intercept, then vc is set toTRUE
- arch
either
NULL
(default) or an integer vector, say,c(1,3)
or2:5
. The log-ARCH lags to include in the log-variance specification- asym
either
NULL
(default) or an integer vector, say,c(1)
or1:3
. The asymmetry (i.e. 'leverage') terms to include in the log-variance specification- log.ewma
either
NULL
(default) or a vector of the lengths of the volatility proxies, seeleqwma
- vxreg
either
NULL
(default) or a numeric vector or matrix, say, azoo
object, of conditioning variables. If bothy
andmxreg
arezoo
objects, then their samples are chosen to match- zero.adj
numeric value between 0 and 1. The quantile adjustment for zero values. The default 0.1 means the zero residuals are replaced by the 10 percent quantile of the absolute residuals before taking the logarithm
- vc.adj
logical. If
TRUE
(default), then the log-variance intercept is adjusted by the estimate of E[ln(z^2)], where z is the standardised error. This adjustment is needed for the conditional scale to be equal to the conditional standard deviation. IfFALSE
, then the log-variance intercept is not adjusted- return.regressand
logical.
TRUE
, the default, includes the regressand as column one in the returned matrix.- return.as.zoo
TRUE
, the default, returns the matrix as azoo
object.- na.trim
TRUE
, the default, removes observations withNA
-values in the beginning and the end withna.trim
.- na.omit
TRUE
, the non-default, removes observations withNA
-values, not necessarily in the beginning or in the end, withna.omit
.
References
Pretis, Felix, Reade, James and Sucarrat, Genaro (2018): 'Automated General-to-Specific (GETS) Regression Modeling and Indicator Saturation for Outliers and Structural Breaks'. Journal of Statistical Software 86, Number 3, pp. 1-44. DOI: https://www.jstatsoft.org/article/view/v086i03
Sucarrat, Genaro and Escribano, Alvaro (2012): 'Automated Financial Model Selection: General-to-Specific Modelling of the Mean and Volatility Specifications', Oxford Bulletin of Economics and Statistics 74, Issue 5 (October), pp. 716-735
Author
Genaro Sucarrat, http://www.sucarrat.net/
See also
regressorsMean
, arx
, zoo
, leqwma
, na.trim
and na.omit
.
Examples
##generate some data:
eps <- rnorm(10) #error term
x <- matrix(rnorm(10*5), 10, 5) #regressors
##create regressors (examples):
regressorsVariance(eps, vxreg=x)
#> loge2 vconst vxreg1 vxreg2 vxreg3 vxreg4 vxreg5
#> 1 -0.1634702 1 -1.1696153 0.05621485 1.61554532 0.1467085 -0.5272343
#> 2 0.3786650 1 -1.4420346 0.29908690 -0.02969397 1.6236212 1.6659909
#> 3 0.4123792 1 1.0543223 -0.75939812 0.56226735 0.9112097 -1.1392006
#> 4 -0.5960116 1 -0.5973301 2.68485900 -0.09741250 0.1424584 0.1436232
#> 5 -4.9797594 1 0.7894599 -0.45839014 1.01645522 -1.3894835 -1.0995509
#> 6 -0.4719057 1 1.5164906 0.06424356 -1.15616739 -0.8660377 0.9035164
#> 7 -2.6357287 1 -0.1917748 0.64979187 2.32086022 -0.1632849 1.4837795
#> 8 -1.0488618 1 0.2838789 -0.02601863 -0.60353125 2.5530261 1.9507210
#> 9 -1.9974294 1 -1.7510675 -0.64356739 -1.45884941 -1.8602276 0.7976007
#> 10 1.2331983 1 -0.8186698 1.04530566 -0.35091783 1.1310547 1.8432663
regressorsVariance(eps, vxreg=x, return.regressand=FALSE)
#> vconst vxreg1 vxreg2 vxreg3 vxreg4 vxreg5
#> 1 1 -1.1696153 0.05621485 1.61554532 0.1467085 -0.5272343
#> 2 1 -1.4420346 0.29908690 -0.02969397 1.6236212 1.6659909
#> 3 1 1.0543223 -0.75939812 0.56226735 0.9112097 -1.1392006
#> 4 1 -0.5973301 2.68485900 -0.09741250 0.1424584 0.1436232
#> 5 1 0.7894599 -0.45839014 1.01645522 -1.3894835 -1.0995509
#> 6 1 1.5164906 0.06424356 -1.15616739 -0.8660377 0.9035164
#> 7 1 -0.1917748 0.64979187 2.32086022 -0.1632849 1.4837795
#> 8 1 0.2838789 -0.02601863 -0.60353125 2.5530261 1.9507210
#> 9 1 -1.7510675 -0.64356739 -1.45884941 -1.8602276 0.7976007
#> 10 1 -0.8186698 1.04530566 -0.35091783 1.1310547 1.8432663
regressorsVariance(eps, arch=1:3, vxreg=x)
#> loge2 vconst arch1 arch2 arch3 vxreg1 vxreg2
#> 4 -0.5960116 1 0.4123792 0.3786650 -0.1634702 -0.5973301 2.68485900
#> 5 -4.9797594 1 -0.5960116 0.4123792 0.3786650 0.7894599 -0.45839014
#> 6 -0.4719057 1 -4.9797594 -0.5960116 0.4123792 1.5164906 0.06424356
#> 7 -2.6357287 1 -0.4719057 -4.9797594 -0.5960116 -0.1917748 0.64979187
#> 8 -1.0488618 1 -2.6357287 -0.4719057 -4.9797594 0.2838789 -0.02601863
#> 9 -1.9974294 1 -1.0488618 -2.6357287 -0.4719057 -1.7510675 -0.64356739
#> 10 1.2331983 1 -1.9974294 -1.0488618 -2.6357287 -0.8186698 1.04530566
#> vxreg3 vxreg4 vxreg5
#> 4 -0.0974125 0.1424584 0.1436232
#> 5 1.0164552 -1.3894835 -1.0995509
#> 6 -1.1561674 -0.8660377 0.9035164
#> 7 2.3208602 -0.1632849 1.4837795
#> 8 -0.6035312 2.5530261 1.9507210
#> 9 -1.4588494 -1.8602276 0.7976007
#> 10 -0.3509178 1.1310547 1.8432663
regressorsVariance(eps, arch=1:2, asym=1, vxreg=x)
#> loge2 vconst arch1 arch2 asym1 vxreg1 vxreg2
#> 3 0.4123792 1 0.3786650 -0.1634702 0.3786650 1.0543223 -0.75939812
#> 4 -0.5960116 1 0.4123792 0.3786650 0.4123792 -0.5973301 2.68485900
#> 5 -4.9797594 1 -0.5960116 0.4123792 0.0000000 0.7894599 -0.45839014
#> 6 -0.4719057 1 -4.9797594 -0.5960116 -4.9797594 1.5164906 0.06424356
#> 7 -2.6357287 1 -0.4719057 -4.9797594 0.0000000 -0.1917748 0.64979187
#> 8 -1.0488618 1 -2.6357287 -0.4719057 -2.6357287 0.2838789 -0.02601863
#> 9 -1.9974294 1 -1.0488618 -2.6357287 -1.0488618 -1.7510675 -0.64356739
#> 10 1.2331983 1 -1.9974294 -1.0488618 -1.9974294 -0.8186698 1.04530566
#> vxreg3 vxreg4 vxreg5
#> 3 0.5622673 0.9112097 -1.1392006
#> 4 -0.0974125 0.1424584 0.1436232
#> 5 1.0164552 -1.3894835 -1.0995509
#> 6 -1.1561674 -0.8660377 0.9035164
#> 7 2.3208602 -0.1632849 1.4837795
#> 8 -0.6035312 2.5530261 1.9507210
#> 9 -1.4588494 -1.8602276 0.7976007
#> 10 -0.3509178 1.1310547 1.8432663
regressorsVariance(eps, arch=1:2, asym=1, log.ewma=5)
#> loge2 vconst arch1 arch2 asym1 logEqWMA(5)
#> 6 -0.4719057 1 -4.9797594 -0.5960116 -4.979759 -0.1328886
#> 7 -2.6357287 1 -0.4719057 -4.9797594 0.000000 -0.1857433
#> 8 -1.0488618 1 -2.6357287 -0.4719057 -2.635729 -0.5928434
#> 9 -1.9974294 1 -1.0488618 -2.6357287 -1.048862 -1.1371270
#> 10 1.2331983 1 -1.9974294 -1.0488618 -1.997429 -1.4368514
##let eps and x be time-series:
eps <- ts(eps, frequency=4, end=c(2018,4))
x <- ts(x, frequency=4, end=c(2018,4))
regressorsVariance(eps, vxreg=x)
#> loge2 vconst Series 1 Series 2 Series 3 Series 4
#> 2016 Q3 -0.1634702 1 -1.1696153 0.05621485 1.61554532 0.1467085
#> 2016 Q4 0.3786650 1 -1.4420346 0.29908690 -0.02969397 1.6236212
#> 2017 Q1 0.4123792 1 1.0543223 -0.75939812 0.56226735 0.9112097
#> 2017 Q2 -0.5960116 1 -0.5973301 2.68485900 -0.09741250 0.1424584
#> 2017 Q3 -4.9797594 1 0.7894599 -0.45839014 1.01645522 -1.3894835
#> 2017 Q4 -0.4719057 1 1.5164906 0.06424356 -1.15616739 -0.8660377
#> 2018 Q1 -2.6357287 1 -0.1917748 0.64979187 2.32086022 -0.1632849
#> 2018 Q2 -1.0488618 1 0.2838789 -0.02601863 -0.60353125 2.5530261
#> 2018 Q3 -1.9974294 1 -1.7510675 -0.64356739 -1.45884941 -1.8602276
#> 2018 Q4 1.2331983 1 -0.8186698 1.04530566 -0.35091783 1.1310547
#> Series 5
#> 2016 Q3 -0.5272343
#> 2016 Q4 1.6659909
#> 2017 Q1 -1.1392006
#> 2017 Q2 0.1436232
#> 2017 Q3 -1.0995509
#> 2017 Q4 0.9035164
#> 2018 Q1 1.4837795
#> 2018 Q2 1.9507210
#> 2018 Q3 0.7976007
#> 2018 Q4 1.8432663
regressorsVariance(eps, arch=1:3, vxreg=x)
#> loge2 vconst arch1 arch2 arch3 Series 1
#> 2017 Q2 -0.5960116 1 0.4123792 0.3786650 -0.1634702 -0.5973301
#> 2017 Q3 -4.9797594 1 -0.5960116 0.4123792 0.3786650 0.7894599
#> 2017 Q4 -0.4719057 1 -4.9797594 -0.5960116 0.4123792 1.5164906
#> 2018 Q1 -2.6357287 1 -0.4719057 -4.9797594 -0.5960116 -0.1917748
#> 2018 Q2 -1.0488618 1 -2.6357287 -0.4719057 -4.9797594 0.2838789
#> 2018 Q3 -1.9974294 1 -1.0488618 -2.6357287 -0.4719057 -1.7510675
#> 2018 Q4 1.2331983 1 -1.9974294 -1.0488618 -2.6357287 -0.8186698
#> Series 2 Series 3 Series 4 Series 5
#> 2017 Q2 2.68485900 -0.0974125 0.1424584 0.1436232
#> 2017 Q3 -0.45839014 1.0164552 -1.3894835 -1.0995509
#> 2017 Q4 0.06424356 -1.1561674 -0.8660377 0.9035164
#> 2018 Q1 0.64979187 2.3208602 -0.1632849 1.4837795
#> 2018 Q2 -0.02601863 -0.6035312 2.5530261 1.9507210
#> 2018 Q3 -0.64356739 -1.4588494 -1.8602276 0.7976007
#> 2018 Q4 1.04530566 -0.3509178 1.1310547 1.8432663
regressorsVariance(eps, arch=1:2, asym=1, vxreg=x)
#> loge2 vconst arch1 arch2 asym1 Series 1
#> 2017 Q1 0.4123792 1 0.3786650 -0.1634702 0.3786650 1.0543223
#> 2017 Q2 -0.5960116 1 0.4123792 0.3786650 0.4123792 -0.5973301
#> 2017 Q3 -4.9797594 1 -0.5960116 0.4123792 0.0000000 0.7894599
#> 2017 Q4 -0.4719057 1 -4.9797594 -0.5960116 -4.9797594 1.5164906
#> 2018 Q1 -2.6357287 1 -0.4719057 -4.9797594 0.0000000 -0.1917748
#> 2018 Q2 -1.0488618 1 -2.6357287 -0.4719057 -2.6357287 0.2838789
#> 2018 Q3 -1.9974294 1 -1.0488618 -2.6357287 -1.0488618 -1.7510675
#> 2018 Q4 1.2331983 1 -1.9974294 -1.0488618 -1.9974294 -0.8186698
#> Series 2 Series 3 Series 4 Series 5
#> 2017 Q1 -0.75939812 0.5622673 0.9112097 -1.1392006
#> 2017 Q2 2.68485900 -0.0974125 0.1424584 0.1436232
#> 2017 Q3 -0.45839014 1.0164552 -1.3894835 -1.0995509
#> 2017 Q4 0.06424356 -1.1561674 -0.8660377 0.9035164
#> 2018 Q1 0.64979187 2.3208602 -0.1632849 1.4837795
#> 2018 Q2 -0.02601863 -0.6035312 2.5530261 1.9507210
#> 2018 Q3 -0.64356739 -1.4588494 -1.8602276 0.7976007
#> 2018 Q4 1.04530566 -0.3509178 1.1310547 1.8432663
regressorsVariance(eps, arch=1:2, asym=1, log.ewma=5)
#> loge2 vconst arch1 arch2 asym1 logEqWMA(5)
#> 2017 Q4 -0.4719057 1 -4.9797594 -0.5960116 -4.979759 -0.1328886
#> 2018 Q1 -2.6357287 1 -0.4719057 -4.9797594 0.000000 -0.1857433
#> 2018 Q2 -1.0488618 1 -2.6357287 -0.4719057 -2.635729 -0.5928434
#> 2018 Q3 -1.9974294 1 -1.0488618 -2.6357287 -1.048862 -1.1371270
#> 2018 Q4 1.2331983 1 -1.9974294 -1.0488618 -1.997429 -1.4368514