Title: | Direct Multi-Step Forecast Based Comparison of Nested Models via an Encompassing Test |
---|---|
Description: | The encompassing test is developed based on multi-step-ahead predictions of two nested models as in Pitarakis, J. (2023) <doi:10.48550/arXiv.2312.16099>. The statistics are standardised to a normal distribution, and the null hypothesis is that the larger model contains no additional useful information. P-values will be provided in the output. |
Authors: | Rong Peng [aut, cre] |
Maintainer: | Rong Peng <[email protected]> |
License: | GPL (>= 3) |
Version: | 0.22 |
Built: | 2024-11-16 06:22:50 UTC |
Source: | CRAN |
Given a vector of residuals, it generates the Heteroskedastic Long run variance.
andrews_lrv(e)
andrews_lrv(e)
e |
a vector of residual series, for which we recommend to use the recursive residuals from larger model. |
a vector of Long run variance using Andrews quadratic spectral kernel HAC.
Andrews, D. W. (1991). Heteroskedasticity and autocorrelation consistent covariance matrix estimation. Econometrica: Journal of the Econometric Society, 817-858.
set.seed(2014) x<- rnorm(15); #Andrews kernel HAC andrews_lrcov = andrews_lrv(x)
set.seed(2014) x<- rnorm(15); #Andrews kernel HAC andrews_lrcov = andrews_lrv(x)
Given a vector of residuals, it generates the Heteroskedastic Long run variance.
NW_lrv(u, nlag = NULL, demean = TRUE)
NW_lrv(u, nlag = NULL, demean = TRUE)
u |
a vector of residual series, for which we recommend to use the recursive residuals from larger model. |
nlag |
Non-negative integer containing the lag length to use. If empty or not included, nleg = min(floor(1.2*T^(1/3)),T) will be used. |
demean |
Logical true of false (0 or 1) indicating whether the mean should be subtracted when computing. |
K by K vector of Long run variance using Newey-West (Bartlett) weights.
x<- rnorm(15); #Newey-West covariance with automatic BW selection lrcov = NW_lrv(x) #Newey-West covariance with 10 lags lrcov = NW_lrv(x, 10) #Newey-West covariance with 10 lags and no demeaning lrcov = NW_lrv(x, 10, 0)
x<- rnorm(15); #Newey-West covariance with automatic BW selection lrcov = NW_lrv(x) #Newey-West covariance with 10 lags lrcov = NW_lrv(x, 10) #Newey-West covariance with 10 lags and no demeaning lrcov = NW_lrv(x, 10, 0)
It calculates the dbar statistics for nested models with null hypothesis being the larger model failing to add any useful information to the small model following Pitarakis (2023). There are in total six versions of dbar, based on the assumptions of variance (homo or hete) and residuals (original, adjusted based on NW, or adjusted based on Andrews). All dbar statistics will be standarised to a standard N(0,1) normal distribution, and corresponding P values would be provided.
pred_encompass_dnorm(e1hat, e2hat, mu0)
pred_encompass_dnorm(e1hat, e2hat, mu0)
e1hat |
a vector of out of sample forecast errors from model 1 (smaller model) |
e2hat |
a vector of out of sample forecast errors from model 2 (larger model) |
mu0 |
Fraction of the sample, which should be within 0 and 1 (0.5 should be avoid) |
A list of normalised d statistics and corresponding P values will be produced.
Pitarakis, J. Y. (2023). Direct Multi-Step Forecast based Comparison of Nested Models via an Encompassing Test. arXiv preprint arXiv:2312.16099.
e1<- rnorm(15); e2<- rnorm(15); temp1 <- pred_encompass_dnorm(e1,e2,mu0=0.2) temp1$T1_d_alrv #normalised d statistics with Andrews quadratic kernel long-run variance temp1$Pval_T1_d_alrv #P value of it
e1<- rnorm(15); e2<- rnorm(15); temp1 <- pred_encompass_dnorm(e1,e2,mu0=0.2) temp1$T1_d_alrv #normalised d statistics with Andrews quadratic kernel long-run variance temp1$Pval_T1_d_alrv #P value of it
Consider the following LS-fitted Model with intercept: y_(t+h) = beta_0 + x_t * beta + u_(t+h) which is used to generate out-of-sample forecasts of y, h-steps ahead (h=1,2,3,. . . ). Notes: (1) first estimation window is (1,...,k0) and last window is (1,....,n-h) for k0 = round(n*pi0). First forecast is yhat(k0+h|k0) and last forecast is yhat(n|n-h). There are a total of (n-h-k0+1) forecasts and corresponding forecast errors. (2) this fast version of the recursive least squares algorithm uses the Sherman-Morrison matrix formula to avoid matrix inversions at each recursion.
recursive_hstep_fast(y, x, pi0, h)
recursive_hstep_fast(y, x, pi0, h)
y |
an outcome series, which should be numeric and one dimensional. |
x |
a predictor matrix (intercept would be added automatically). |
pi0 |
Fraction of the sample, which should be within 0 and 1. |
h |
Number of steps ahead to predict, which should be a positive integer. |
recursive_hstep_fast is the fast version that avoids the recursive calculation of inverse of the matrix using Sherman-Morrison formula. recursive_hstep_slow is the slow version that calculates the standard OLS recursively.
Series of residuals estimated
x<- rnorm(15); y<- x+rnorm(15); temp1 <- recursive_hstep_fast(y,x,pi0=0.5,h=1);
x<- rnorm(15); y<- x+rnorm(15); temp1 <- recursive_hstep_fast(y,x,pi0=0.5,h=1);