Title: | Direct Multi-Step Forecast Based Comparison of Nested Models via an Encompassing Test |
Version: | 0.22 |
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. |
Encoding: | UTF-8 |
RoxygenNote: | 7.3.1 |
License: | GPL (≥ 3) |
Imports: | pracma, stats |
NeedsCompilation: | no |
Packaged: | 2024-02-17 15:07:44 UTC; rp1e23 |
Author: | Rong Peng [aut, cre] |
Maintainer: | Rong Peng <r.peng@soton.ac.uk> |
Repository: | CRAN |
Date/Publication: | 2024-02-19 17:10:22 UTC |
Long-run covariance estimation using Newey-West (Bartlett) weights
Description
Given a vector of residuals, it generates the Heteroskedastic Long run variance.
Usage
NW_lrv(u, nlag = NULL, demean = TRUE)
Arguments
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. |
Value
K by K vector of Long run variance using Newey-West (Bartlett) weights.
Examples
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)
Long-run covariance estimation using Andrews quadratic spectral kernel.
Description
Given a vector of residuals, it generates the Heteroskedastic Long run variance.
Usage
andrews_lrv(e)
Arguments
e |
a vector of residual series, for which we recommend to use the recursive residuals from larger model. |
Value
a vector of Long run variance using Andrews quadratic spectral kernel HAC.
References
Andrews, D. W. (1991). Heteroskedasticity and autocorrelation consistent covariance matrix estimation. Econometrica: Journal of the Econometric Society, 817-858.
Examples
set.seed(2014)
x<- rnorm(15);
#Andrews kernel HAC
andrews_lrcov = andrews_lrv(x)
Direct Multi-Step Forecast Based Comparison of Nested Models via an Encompassing Test
Description
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.
Usage
pred_encompass_dnorm(e1hat, e2hat, mu0)
Arguments
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) |
Value
A list of normalised d statistics and corresponding P values will be produced.
References
Pitarakis, J. Y. (2023). Direct Multi-Step Forecast based Comparison of Nested Models via an Encompassing Test. arXiv preprint arXiv:2312.16099.
Examples
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
Forecasting h-steps ahead using Recursive Least Squares Fast
Description
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.
Usage
recursive_hstep_fast(y, x, pi0, h)
Arguments
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. |
Details
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.
Value
Series of residuals estimated
Examples
x<- rnorm(15);
y<- x+rnorm(15);
temp1 <- recursive_hstep_fast(y,x,pi0=0.5,h=1);