Create regressors for a log-variance model
regressorsVariance.RdThe function creates the regressors of a log-variance model, e.g. in a arx model. The returned value is a matrix with the regressors and, by default, the regressand in the first column. 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, harch = NULL, asym = NULL,
asymind = NULL, log.ewma = NULL, vxreg = NULL, prefix = "v", zero.adj = NULL,
vc.adj = TRUE, return.regressand = TRUE, return.as.zoo = TRUE, na.trim = TRUE,
na.omit = FALSE)Arguments
- e
numeric vector, time-series or
zooobject.- vc
logical.
TRUEincludes 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.- harch
either
NULL(default) or an integer vector, say,c(5,20). The log of heterogenous ARCH-terms as proposed by Muller et al. (1997).- 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.- asymind
either
NULL(default) or an integer vector, say,c(1)or1:3. The indicator ('binary') asymmetry terms to include in the log-variance specification.- log.ewma
either
NULL(default) or a vector of the lengths of the volatility proxies, seeleqwma. The log of heterogenous volatility proxies similar to those of Corsi (2009).- vxreg
either
NULL(default) or a numeric vector or matrix, say, azooobject, of conditioning variables. If bothyandmxregarezooobjects, then their samples are chosen to match.- prefix
a
characterused as prefix in the labelling of the variables invxregand of the intercept.- zero.adj
NULL(default) or a strictly positivenumericscalar. IfNULL, the zeros in the squared e's are replaced by the 10 percent quantile of the non-zero squared e's. Ifzero.adjis a strictly positivenumericscalar, then this value is used to replace the zeros of the squared e's.- vc.adj
deprecated and ignored.
- return.regressand
logical.TRUE(default) includes the regressand as column one in the returned matrix.- return.as.zoo
logical.TRUE(default) returns the matrix as azooobject.- na.trim
logical.TRUE(default) removes observations withNA-values in the beginning and the end withna.trim.- na.omit
logical.FALSE(default) meansNA-observations that are not in the beginning or at the end are kept (i.e. not omitted).TRUEremoves withna.omit.
Value
A matrix, by default of class zoo, with the regressand as column one (the default).
References
Corsi, Fulvio (2009): 'A Simple Approximate Long-Memory Model of Realized Volatility', Journal of Financial Econometrics 7, pp. 174-196
Muller, Ulrich A., Dacorogna, Michel M., Dave, Rakhal D., Olsen, Richard B, Pictet, Olivier, Weizsaker, Jacob E. (1997): 'Volatilities of different time resolutions - Analyzing the dynamics of market components'. Journal of Empirical Finance 4, pp. 213-239
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/
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
#> 1 -1.81358320 1 -0.6688047 -0.36611661 -1.4664402136 -1.90744533
#> 2 -10.83053327 1 0.3430061 0.50644120 0.5132418443 0.48435318
#> 3 0.03604845 1 1.2668281 -0.57849893 1.2300639371 -1.01534253
#> 4 -1.04171751 1 -0.5358369 -0.01510772 0.0003588142 0.05616500
#> 5 0.86050185 1 -0.5206941 -0.70741163 -0.4171432908 1.26706961
#> 6 -0.67502714 1 0.4855969 1.18353451 -0.5300941211 -0.21457269
#> 7 -1.66462185 1 -0.6016140 -0.42845570 0.7221536300 0.73344466
#> 8 0.82681302 1 -0.5872741 -1.98554270 2.5598198662 -0.05893913
#> 9 -4.35101692 1 0.7789016 -1.00981190 -0.5577840830 1.13043653
#> 10 -0.68979645 1 1.8546588 -0.12814534 -0.0823527423 0.76247928
#> vxreg5
#> 1 -0.35578297
#> 2 1.38183780
#> 3 0.53277462
#> 4 -0.32518627
#> 5 -1.32926819
#> 6 -0.52779093
#> 7 1.49037243
#> 8 -0.02900963
#> 9 0.01237915
#> 10 1.73204559
regressorsVariance(eps, vxreg=x, return.regressand=FALSE)
#> vconst vxreg1 vxreg2 vxreg3 vxreg4 vxreg5
#> 1 1 -0.6688047 -0.36611661 -1.4664402136 -1.90744533 -0.35578297
#> 2 1 0.3430061 0.50644120 0.5132418443 0.48435318 1.38183780
#> 3 1 1.2668281 -0.57849893 1.2300639371 -1.01534253 0.53277462
#> 4 1 -0.5358369 -0.01510772 0.0003588142 0.05616500 -0.32518627
#> 5 1 -0.5206941 -0.70741163 -0.4171432908 1.26706961 -1.32926819
#> 6 1 0.4855969 1.18353451 -0.5300941211 -0.21457269 -0.52779093
#> 7 1 -0.6016140 -0.42845570 0.7221536300 0.73344466 1.49037243
#> 8 1 -0.5872741 -1.98554270 2.5598198662 -0.05893913 -0.02900963
#> 9 1 0.7789016 -1.00981190 -0.5577840830 1.13043653 0.01237915
#> 10 1 1.8546588 -0.12814534 -0.0823527423 0.76247928 1.73204559
regressorsVariance(eps, arch=1:3, vxreg=x)
#> loge2 vconst arch1 arch2 arch3 vxreg1
#> 4 -1.0417175 1 0.03604845 -10.83053327 -1.81358320 -0.5358369
#> 5 0.8605019 1 -1.04171751 0.03604845 -10.83053327 -0.5206941
#> 6 -0.6750271 1 0.86050185 -1.04171751 0.03604845 0.4855969
#> 7 -1.6646218 1 -0.67502714 0.86050185 -1.04171751 -0.6016140
#> 8 0.8268130 1 -1.66462185 -0.67502714 0.86050185 -0.5872741
#> 9 -4.3510169 1 0.82681302 -1.66462185 -0.67502714 0.7789016
#> 10 -0.6897965 1 -4.35101692 0.82681302 -1.66462185 1.8546588
#> vxreg2 vxreg3 vxreg4 vxreg5
#> 4 -0.01510772 0.0003588142 0.05616500 -0.32518627
#> 5 -0.70741163 -0.4171432908 1.26706961 -1.32926819
#> 6 1.18353451 -0.5300941211 -0.21457269 -0.52779093
#> 7 -0.42845570 0.7221536300 0.73344466 1.49037243
#> 8 -1.98554270 2.5598198662 -0.05893913 -0.02900963
#> 9 -1.00981190 -0.5577840830 1.13043653 0.01237915
#> 10 -0.12814534 -0.0823527423 0.76247928 1.73204559
regressorsVariance(eps, arch=1:2, asym=1, vxreg=x)
#> loge2 vconst arch1 arch2 asym1 vxreg1
#> 3 0.03604845 1 -10.83053327 -1.81358320 0.0000000 1.2668281
#> 4 -1.04171751 1 0.03604845 -10.83053327 0.0000000 -0.5358369
#> 5 0.86050185 1 -1.04171751 0.03604845 0.0000000 -0.5206941
#> 6 -0.67502714 1 0.86050185 -1.04171751 0.8605019 0.4855969
#> 7 -1.66462185 1 -0.67502714 0.86050185 0.0000000 -0.6016140
#> 8 0.82681302 1 -1.66462185 -0.67502714 -1.6646218 -0.5872741
#> 9 -4.35101692 1 0.82681302 -1.66462185 0.0000000 0.7789016
#> 10 -0.68979645 1 -4.35101692 0.82681302 -4.3510169 1.8546588
#> vxreg2 vxreg3 vxreg4 vxreg5
#> 3 -0.57849893 1.2300639371 -1.01534253 0.53277462
#> 4 -0.01510772 0.0003588142 0.05616500 -0.32518627
#> 5 -0.70741163 -0.4171432908 1.26706961 -1.32926819
#> 6 1.18353451 -0.5300941211 -0.21457269 -0.52779093
#> 7 -0.42845570 0.7221536300 0.73344466 1.49037243
#> 8 -1.98554270 2.5598198662 -0.05893913 -0.02900963
#> 9 -1.00981190 -0.5577840830 1.13043653 0.01237915
#> 10 -0.12814534 -0.0823527423 0.76247928 1.73204559
regressorsVariance(eps, arch=1:2, asym=1, log.ewma=5)
#> loge2 vconst arch1 arch2 asym1 logEqWMA(5)
#> 6 -0.6750271 1 0.8605019 -1.0417175 0.8605019 -0.24411448
#> 7 -1.6646218 1 -0.6750271 0.8605019 0.0000000 -0.15944987
#> 8 0.8268130 1 -1.6646218 -0.6750271 -1.6646218 -0.11601575
#> 9 -4.3510169 1 0.8268130 -1.6646218 0.0000000 0.13131270
#> 10 -0.6897965 1 -4.3510169 0.8268130 -4.3510169 0.06983704
##example where eps and x are 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 -1.81358320 1 -0.6688047 -0.36611661 -1.4664402136 -1.90744533
#> 2016 Q4 -10.83053327 1 0.3430061 0.50644120 0.5132418443 0.48435318
#> 2017 Q1 0.03604845 1 1.2668281 -0.57849893 1.2300639371 -1.01534253
#> 2017 Q2 -1.04171751 1 -0.5358369 -0.01510772 0.0003588142 0.05616500
#> 2017 Q3 0.86050185 1 -0.5206941 -0.70741163 -0.4171432908 1.26706961
#> 2017 Q4 -0.67502714 1 0.4855969 1.18353451 -0.5300941211 -0.21457269
#> 2018 Q1 -1.66462185 1 -0.6016140 -0.42845570 0.7221536300 0.73344466
#> 2018 Q2 0.82681302 1 -0.5872741 -1.98554270 2.5598198662 -0.05893913
#> 2018 Q3 -4.35101692 1 0.7789016 -1.00981190 -0.5577840830 1.13043653
#> 2018 Q4 -0.68979645 1 1.8546588 -0.12814534 -0.0823527423 0.76247928
#> Series 5
#> 2016 Q3 -0.35578297
#> 2016 Q4 1.38183780
#> 2017 Q1 0.53277462
#> 2017 Q2 -0.32518627
#> 2017 Q3 -1.32926819
#> 2017 Q4 -0.52779093
#> 2018 Q1 1.49037243
#> 2018 Q2 -0.02900963
#> 2018 Q3 0.01237915
#> 2018 Q4 1.73204559
regressorsVariance(eps, arch=1:3, vxreg=x)
#> loge2 vconst arch1 arch2 arch3 Series 1
#> 2017 Q2 -1.0417175 1 0.03604845 -10.83053327 -1.81358320 -0.5358369
#> 2017 Q3 0.8605019 1 -1.04171751 0.03604845 -10.83053327 -0.5206941
#> 2017 Q4 -0.6750271 1 0.86050185 -1.04171751 0.03604845 0.4855969
#> 2018 Q1 -1.6646218 1 -0.67502714 0.86050185 -1.04171751 -0.6016140
#> 2018 Q2 0.8268130 1 -1.66462185 -0.67502714 0.86050185 -0.5872741
#> 2018 Q3 -4.3510169 1 0.82681302 -1.66462185 -0.67502714 0.7789016
#> 2018 Q4 -0.6897965 1 -4.35101692 0.82681302 -1.66462185 1.8546588
#> Series 2 Series 3 Series 4 Series 5
#> 2017 Q2 -0.01510772 0.0003588142 0.05616500 -0.32518627
#> 2017 Q3 -0.70741163 -0.4171432908 1.26706961 -1.32926819
#> 2017 Q4 1.18353451 -0.5300941211 -0.21457269 -0.52779093
#> 2018 Q1 -0.42845570 0.7221536300 0.73344466 1.49037243
#> 2018 Q2 -1.98554270 2.5598198662 -0.05893913 -0.02900963
#> 2018 Q3 -1.00981190 -0.5577840830 1.13043653 0.01237915
#> 2018 Q4 -0.12814534 -0.0823527423 0.76247928 1.73204559
regressorsVariance(eps, arch=1:2, asym=1, vxreg=x)
#> loge2 vconst arch1 arch2 asym1 Series 1
#> 2017 Q1 0.03604845 1 -10.83053327 -1.81358320 0.0000000 1.2668281
#> 2017 Q2 -1.04171751 1 0.03604845 -10.83053327 0.0000000 -0.5358369
#> 2017 Q3 0.86050185 1 -1.04171751 0.03604845 0.0000000 -0.5206941
#> 2017 Q4 -0.67502714 1 0.86050185 -1.04171751 0.8605019 0.4855969
#> 2018 Q1 -1.66462185 1 -0.67502714 0.86050185 0.0000000 -0.6016140
#> 2018 Q2 0.82681302 1 -1.66462185 -0.67502714 -1.6646218 -0.5872741
#> 2018 Q3 -4.35101692 1 0.82681302 -1.66462185 0.0000000 0.7789016
#> 2018 Q4 -0.68979645 1 -4.35101692 0.82681302 -4.3510169 1.8546588
#> Series 2 Series 3 Series 4 Series 5
#> 2017 Q1 -0.57849893 1.2300639371 -1.01534253 0.53277462
#> 2017 Q2 -0.01510772 0.0003588142 0.05616500 -0.32518627
#> 2017 Q3 -0.70741163 -0.4171432908 1.26706961 -1.32926819
#> 2017 Q4 1.18353451 -0.5300941211 -0.21457269 -0.52779093
#> 2018 Q1 -0.42845570 0.7221536300 0.73344466 1.49037243
#> 2018 Q2 -1.98554270 2.5598198662 -0.05893913 -0.02900963
#> 2018 Q3 -1.00981190 -0.5577840830 1.13043653 0.01237915
#> 2018 Q4 -0.12814534 -0.0823527423 0.76247928 1.73204559
regressorsVariance(eps, arch=1:2, asym=1, log.ewma=5)
#> loge2 vconst arch1 arch2 asym1 logEqWMA(5)
#> 2017 Q4 -0.6750271 1 0.8605019 -1.0417175 0.8605019 -0.24411448
#> 2018 Q1 -1.6646218 1 -0.6750271 0.8605019 0.0000000 -0.15944987
#> 2018 Q2 0.8268130 1 -1.6646218 -0.6750271 -1.6646218 -0.11601575
#> 2018 Q3 -4.3510169 1 0.8268130 -1.6646218 0.0000000 0.13131270
#> 2018 Q4 -0.6897965 1 -4.3510169 0.8268130 -4.3510169 0.06983704