| Title: | VAR Modelling: Estimation, Testing, and Prediction |
|---|---|
| Description: | A collection of the functions for estimation, hypothesis testing, prediction for stationary vector autoregressive models. |
| Authors: | Jae. H. Kim |
| Maintainer: | Jae H. Kim <[email protected]> |
| License: | GPL-2 |
| Version: | 1.1 |
| Built: | 2026-05-29 09:45:21 UTC |
| Source: | https://github.com/cran/VAR.etp |
Estimation, Hypothesis Testing, Prediction in Stationary Vector Autoregressive Models
| Package: | VAR.etp |
| Type: | Package |
| Version: | 1.1 |
| Date: | 2023-08-31 |
| License: | GPL-2 |
The data set dat.rda is from Lutkepohl's book.
It is German Macrodata in log difference.
Bootstrap bias-correction and prediction intervals are also included.
Estimation and Forecasting based on Predictive Regression is also included.
Jae H. Kim
Maintainer: Jae H. Kim
Lutkepohl's data
data(dat)data(dat)
Lutkepohl, H. 2005, New Introduction to Multiple Time Series Analysis, Springer
data(dat)data(dat)
stock return data used in Kim (2014)
data(data1)data(data1)
Kim, J.H. 2014, Testing for parameter restrictions in a stationary VAR model: a bootstrap alternative. Economic Modelling, 41, 267-273.
data(data1)data(data1)
Function for forecasting based on Imporved ARM
PR.Fore(x, y, M, h = 10)PR.Fore(x, y, M, h = 10)
x |
predictor or matrix of predictors in column |
y |
variable to be predicted, usually stock return |
M |
Estimation results of the function PR.IARM |
h |
forecasting period |
Function for forecasting based on Imporved ARM
Fore |
Out-of sample and dynamic forecasts for y and x |
Kim J.H., 2014, Predictive Regression: Improved Augmented Regression Method, Journal of Empirical Finance 25, 13-15.
jae H. Kim
Kim J.H., 2014, Predictive Regression: Improved Augmented Regression Method, Journal of Empirical Finance 25, 13-15.
data(data1) # Replicating Table 5 (excess return) y=data1$ret.nyse.vw*100 -data1$tbill*100 x=cbind(log(data1$dy.nyse), data1$tbill*100); k=ncol(x) p=4 Rmat1=Rmatrix(p,k,type=1,index=1); Rmat=Rmat1$Rmat; rvec=Rmat1$rvec M=PR.IARM(x,y,p,Rmat,rvec) PRF=PR.Fore(x,y,M)data(data1) # Replicating Table 5 (excess return) y=data1$ret.nyse.vw*100 -data1$tbill*100 x=cbind(log(data1$dy.nyse), data1$tbill*100); k=ncol(x) p=4 Rmat1=Rmatrix(p,k,type=1,index=1); Rmat=Rmat1$Rmat; rvec=Rmat1$rvec M=PR.IARM(x,y,p,Rmat,rvec) PRF=PR.Fore(x,y,M)
Function for Improved ARM (IARM) estimation and testing
PR.IARM(x, y, p, Rmat = diag(k * p), rvec = matrix(0, nrow = k * p))PR.IARM(x, y, p, Rmat = diag(k * p), rvec = matrix(0, nrow = k * p))
x |
predictor or a matrix of predictors in column |
y |
variable to be predicted, usually data1 return |
p |
AR order |
Rmat |
Restriction matrix, refer to function Rmatrix |
rvec |
Restriction matrix, refer to function Rmatrix |
Kim J.H., 2014, Predictive Regression: Improved Augmented Regression Method, Journal of Empirical Finance, 26, 13-25.
LS |
Ordinary Least Squares Estimators |
IARM |
IARM Estimators |
AR |
AR parameter estimators |
ARc |
Bias-corrected AR parameter estimators |
Fstats |
Fstats and their p-values |
Covbc |
Covariance matrix of the IARM estimators (for the predictive coefficients only) |
Kim J.H., 2014, Predictive Regression: Improved Augmented Regression Method, Journal of Empirical Finance, 26, 13-25.
Jae H. Kim
Kim J.H., 2014, Predictive Regression: Improved Augmented Regression Method, Journal of Empirical Finance, 26, 13-25.
data(data1) # Replicating Table 5 (excess return) of Kim (2014) y=data1$ret.nyse.vw*100 -data1$tbill*100 x=cbind(log(data1$dy.nyse), data1$tbill*100); Rmat1=Rmatrix(p=1,k=2,type=1,index=0); Rmat=Rmat1$Rmat; rvec=Rmat1$rvec M=PR.IARM(x,y,p=1,Rmat,rvec)data(data1) # Replicating Table 5 (excess return) of Kim (2014) y=data1$ret.nyse.vw*100 -data1$tbill*100 x=cbind(log(data1$dy.nyse), data1$tbill*100); Rmat1=Rmatrix(p=1,k=2,type=1,index=0); Rmat=Rmat1$Rmat; rvec=Rmat1$rvec M=PR.IARM(x,y,p=1,Rmat,rvec)
Function to select the order p by AIC or BIC
PR.order(x, y, pmax = 10)PR.order(x, y, pmax = 10)
x |
predictor or a matrix of predictors in column |
y |
variable to be predicted, usually stock return |
pmax |
maximum order for order selection |
Kim J.H., 2014, Predictive Regression: Improved Augmented Regression Method, Journal of Empirical Finance 25, 13-15.
p.aic |
order chosen by AIC |
p.aic |
order chosen by BIC |
Kim J.H., 2014, Predictive Regression: Improved Augmented Regression Method, Journal of Empirical Finance 25, 13-15.
Jae H. Kim
Kim J.H., 2014, Predictive Regression: Improved Augmented Regression Method, Journal of Empirical Finance 25, 13-15.
data(data1) # Replicating Table 5 (excess return) y=data1$ret.nyse.vw*100 -data1$tbill*100 x=cbind(log(data1$dy.nyse), data1$tbill*100); k=ncol(x) p=PR.order(x,y,pmax=10)$p.bic; # AR(1)data(data1) # Replicating Table 5 (excess return) y=data1$ret.nyse.vw*100 -data1$tbill*100 x=cbind(log(data1$dy.nyse), data1$tbill*100); k=ncol(x) p=PR.order(x,y,pmax=10)$p.bic; # AR(1)
Function to generate restriction matrices
Rmatrix(p, k, type = 1, index = 0)Rmatrix(p, k, type = 1, index = 0)
p |
AR order |
k |
number of predictors |
type |
type = 1: H0: b1=b2=b3=0; type = 2: H0: b1+b2+b3=0 |
index |
index=0 : H0 applies for all parameters; index=k : H0 applies for kth predictor |
Function to generate restriction matrices
Rmat |
this value should be passed to PR.IARM |
rvec |
this value should be passed to PR.IARM |
Jae H. Kim
Kim J.H., 2014, Predictive Regression: Improved Augmented Regression Method, Journal of Empirical Finance 25, 13-15.
Rmat1=Rmatrix(p=1,k=1,type=2,index=1); Rmat=Rmat1$Rmat; rvec=Rmat1$rvecRmat1=Rmatrix(p=1,k=1,type=2,index=1); Rmat=Rmat1$Rmat; rvec=Rmat1$rvec
Bias-correction given with stationarity Correction
VAR.BaBPR(x, p, h, nboot = 500, nb = 200, type = "const", alpha = 0.95)VAR.BaBPR(x, p, h, nboot = 500, nb = 200, type = "const", alpha = 0.95)
x |
data matrix in column |
p |
AR order |
h |
forecasting period |
nboot |
number of 2nd-stage bootstrap iterations |
nb |
number of 1st-stage bootstrap iterations |
type |
"const" for the AR model with intercept only, "const+trend" for the AR model with intercept and trend |
alpha |
100(1-alpha) percent prediction intervals |
Bias-correction given with stationarity Correction
Intervals |
Prediction Intervals |
Forecast |
Point Forecasts |
alpha |
Probability Content of Prediction Intervals |
Bias-correction given with stationarity Correction
Jae H. Kim
Kim, J. H. (2001). Bootstrap-after-bootstrap prediction intervals for autoregressive models, Journal of Business & Economic Statistics, 19, 117-128.
data(dat) VAR.BaBPR(dat,p=2,h=10,nboot=200,nb=100,type="const",alpha=0.95) # nboot and nb are set to low numbers for fast execution in the example # In actual implementation, use higher numbers such as nboot=1000, nb=200data(dat) VAR.BaBPR(dat,p=2,h=10,nboot=200,nb=100,type="const",alpha=0.95) # nboot and nb are set to low numbers for fast execution in the example # In actual implementation, use higher numbers such as nboot=1000, nb=200
The function returns bias-corrected parmater estimators and Bias estimators based on the bootstrap
VAR.Boot(x, p, nb = 200, type = "const")VAR.Boot(x, p, nb = 200, type = "const")
x |
data matrix in column |
p |
AR order |
nb |
number of bootstrap iterations |
type |
"const" for the AR model with intercept only, "const+trend" for the AR model with intercept and trend |
Kilian's (1998) stationarity-correction is used for bias-correction
coef |
coefficient matrix |
resid |
matrix of residuals |
sigu |
residual covariance matrix |
Bias |
Bootstrap Bias Estimator |
Jae H. Kim
Kilian, L. (1998). Small sample confidence intervals for impulse response functions, The Review of Economics and Statistics, 80, 218 - 230.
data(dat) VAR.Boot(dat,p=2,nb=200,type="const")data(dat) VAR.Boot(dat,p=2,nb=200,type="const")
No Bias-correction is given
VAR.BPR(x, p, h, nboot = 500, type = "const", alpha = 0.95)VAR.BPR(x, p, h, nboot = 500, type = "const", alpha = 0.95)
x |
data matrix in column |
p |
AR order |
h |
forecasting period |
nboot |
number of bootstrap iterations |
type |
"const" for the AR model with intercept only, "const+trend" for the AR model with intercept and trend |
alpha |
100(1-alpha) percent prediction intervals |
Bootstrap Prediction Intervals for VAR(p) Model
Intervals |
Prediction Intervals |
Forecast |
Point Forecasts |
alpha |
Probability Content of Prediction Intervals |
No Bias-correction is given
Jae H. Kim
Kim, J. H. (2001). Bootstrap-after-bootstrap prediction intervals for autoregressive models, Journal of Business & Economic Statistics, 19, 117-128.
data(dat) VAR.BPR(dat,p=2,h=10,nboot=200,type="const",alpha=0.95) # nboot is set to a low number for fast execution in the example # In actual implementation, use higher number such as nboot=1000data(dat) VAR.BPR(dat,p=2,h=10,nboot=200,type="const",alpha=0.95) # nboot is set to a low number for fast execution in the example # In actual implementation, use higher number such as nboot=1000
This function returns least-squares estimation results for VAR(p) model
VAR.est(x, p, type = "const")VAR.est(x, p, type = "const")
x |
data matrix in column |
p |
AR order |
type |
"const" for the AR model with intercept only, "const+trend" for the AR model with intercept and trend |
VAR estimation
coef |
coefficient matrix |
resid |
matrix of residuals |
sigu |
residual covariance matrix |
zzmat |
data moment matrix |
zmat |
data moment matrix |
tratio |
matrix of tratio corresponding to coef matrix |
See Chapter 3 of Lutkepohl (2005)
Jae H. Kim
Lutkepohl, H. 2005, New Introduction to Multiple Time Series Analysis, Springer
#replicating Section 3.2.3 of of Lutkepohl (2005) data(dat) M=VAR.est(dat,p=2,type="const") print(M$coef) print(M$tratio)#replicating Section 3.2.3 of of Lutkepohl (2005) data(dat) M=VAR.est(dat,p=2,type="const") print(M$coef) print(M$tratio)
Generate point forecasts and prediction intervals
VAR.FOR(x, p, h, type = "const", alpha = 0.95)VAR.FOR(x, p, h, type = "const", alpha = 0.95)
x |
data matrix in column |
p |
VAR order |
h |
Forecasting Periods |
type |
"const" for the AR model with intercept only, "const+trend" for the AR model with intercept and trend |
alpha |
100(1-alpha) percent prediction intervals |
Prediction Intervals are based on normal approximation
Intervals |
Prediction Intervals, out-of-sample and dynamic |
Forecast |
Point Forecasts, out-of-sample and dynamic |
alpha |
Probability Content of Prediction Interva;s |
See Chapter 3 of Lutkepohl (2005)
Jae H. Kim
Lutkepohl, H. 2005, New Introduction to Multiple Time Series Analysis, Springer
#replicating Section 3.5.3 of Lutkepohl (2005) data(dat) VAR.FOR(dat,p=2,h=10,type="const",alpha=0.95)#replicating Section 3.5.3 of Lutkepohl (2005) data(dat) VAR.FOR(dat,p=2,h=10,type="const",alpha=0.95)
Generate point forecasts using the estimated VAR coefficient matrix
VAR.Fore(x, b, p, h, type = "const")VAR.Fore(x, b, p, h, type = "const")
x |
data matrix in column |
b |
matrix of coefficients from VAR.est or VAR.Rest |
p |
VAR order |
h |
Forecasting Periods |
type |
"const" for the AR model with intercept only, "const+trend" for the AR model with intercept and trend |
Generate point forecasts using the estimated VAR coefficient matrix
Fore |
Point Forecasts, out-of-sample and dynamic |
See Chapter 3 of Lutkepohl (2005)
Jae H. Kim
Lutkepohl, H. 2005, New Introduction to Multiple Time Series Analysis, Springer
#replicating Section 3.5.3 of Lutkepohl (2005) data(dat) b=VAR.est(dat,p=2,type="const")$coef VAR.Fore(dat,b,p=2,h=10,type="const")#replicating Section 3.5.3 of Lutkepohl (2005) data(dat) b=VAR.est(dat,p=2,type="const")$coef VAR.Fore(dat,b,p=2,h=10,type="const")
This function returns Orthogonalized impluse response functions
VAR.irf(b, p, sigu, h=10,graphs=FALSE)VAR.irf(b, p, sigu, h=10,graphs=FALSE)
b |
VAR coefficient matrix, from VAR.est or similar estimation function |
p |
VAR order |
sigu |
VAR residual covariance matrix, from VAR.est or similar estimation function |
h |
response horizon, the default is set to 10 |
graphs |
logical, if TRUE, show the impulse-response functions, the default is FALSE |
VAR impulse response functions
impmat |
matrix that contains orthogonalized impulse-responses |
See Lutkepohl (2005) for details
Jae H. Kim
Lutkepohl, H. 2005, New Introduction to Multiple Time Series Analysis, Springer
#replicating Table 3.4 and Figure 3.11 Lutkepohl (2005) data(dat) M=VAR.est(dat,p=2,type="const") b=M$coef; sigu=M$sigu VAR.irf(b,p=2,sigu,graphs=TRUE)#replicating Table 3.4 and Figure 3.11 Lutkepohl (2005) data(dat) M=VAR.est(dat,p=2,type="const") b=M$coef; sigu=M$sigu VAR.irf(b,p=2,sigu,graphs=TRUE)
Likelihood Ratio test for zero parameter restrictions based on system VAR estimation
Bootstrap option is available: iid bootstrap or wild bootstrap
Bootstrap is conducted under the null hypothesis using estimated GLS estimation: see Kim (2014)
VAR.LR(x, p, restrict0, restrict1, type = "const",bootstrap=0,nb=500)VAR.LR(x, p, restrict0, restrict1, type = "const",bootstrap=0,nb=500)
x |
data matrix in column |
p |
VAR order |
restrict0 |
Restriction matrix under H0 |
restrict1 |
Restriction matrix under H1, if "full", the full VAR is estimated under H1 |
type |
"const" for the AR model with intercept only, "const+trend" for the AR model with intercept and trend |
bootstrap |
0 for no bootstrap; 1 for iid bootstrap; 2 for wild bootstrap |
nb |
the number of bootstrap iterations |
Restriction matrix is of m by 3 matrix where m is the number of restrictions. A typical row of this matrix (k,i,j), which means that (i,j) element of Ak matrix is set to 0. Ak is a VAR coefficient matrix (k = 1,....p).
The bootstrap test is conducted using the GLS estimation under the parameter restrictions implied by the null hypothesis: see Kim (2014) for details.
Kim (2014) found that the bootstrap based on OLS can show inferior small sample properties.
There are two versions of the bootstrap: the first is based on the iid resampling and the second based on wild bootstrapping.
The Wild bootstrap is conducted with Mammen's two-point distribution.
LRstat |
LR test statistic |
pval |
p-value of the LR test |
Boot.pval |
p-value of the test based on bootstrapping |
See Chapter 4 of Lutkepohl (2005)
Jae H. Kim
Lutkepohl, H. 2005, New Introduction to Multiple Time Series Analysis, Springer
Kim, J.H. 2014, Testing for parameter restrictions in a stationary VAR model: a bootstrap alternative. Economic Modelling, 41, 267-273.
data(dat) #replicating Table 4.4 of Lutkepohl (2005) restrict1="full"; restrict0 = rbind(c(4,1,1), c(4,1,2), c(4,1,3), c(4,2,1), c(4,2,2),c(4,2,3),c(4,3,1),c(4,3,2),c(4,3,3)) VAR.LR(dat,p=4,restrict0,restrict1,type="const")data(dat) #replicating Table 4.4 of Lutkepohl (2005) restrict1="full"; restrict0 = rbind(c(4,1,1), c(4,1,2), c(4,1,3), c(4,2,1), c(4,2,2),c(4,2,3),c(4,3,1),c(4,3,2),c(4,3,3)) VAR.LR(dat,p=4,restrict0,restrict1,type="const")
The function returns bias-corrected parmater estimators and Bias estimators based on Pope's asymptotic formula
VAR.Pope(x, p, type = "const")VAR.Pope(x, p, type = "const")
x |
data matrix in column |
p |
AR order |
type |
"const" for the AR model with intercept only, "const+trend" for the AR model with intercept and trend |
Kilian's (1998) stationarity-correction is used for bias-correction
coef |
Bias-corrected coefficient matrix |
resid |
matrix of residuals |
sigu |
residual covariance matrix |
Bias |
Bias Estimate |
Jae H. Kim
Kim, J. H. 2004, Bias-corrected bootstrap prediction regions for Vector Autoregression, Journal of FOrecasting 23, 141-154.
Kilian, L. (1998). Small sample confidence intervals for impulse response functions, The Review of Economics and Statistics, 80, 218 - 230.
Nicholls DF, Pope AL. 1988, Bias in estimation of multivariate autoregression. Australian Journal of Statistics, 30A, 296-309.
Pope AL. 1990. Biases of estimators in multivariate non-Gaussian autoregression, Journal of Time Series Analysis 11, 249-258.
data(dat) VAR.Pope(dat,p=2,type="const")data(dat) VAR.Pope(dat,p=2,type="const")
Estimation of VAR with 0 restrictions on parameters
VAR.Rest(x, p, restrict, type = "const", method = "gls")VAR.Rest(x, p, restrict, type = "const", method = "gls")
x |
data matrix in column |
p |
VAR order |
restrict |
Restriction matrix under H0 |
type |
"const" for the AR model with intercept only, "const+trend" for the AR model with intercept and trend |
method |
"ols" for OLS estimation, "gls" for EGLS estimation |
Restriction matrix is of m by 3 matrix where m is the number of restrictions. A typical row of this matrix (k,i,j), which means that (i,j) element of Ak matrix is set to 0. Ak is a VAR coefficient matrix (k = 1,....p).
coef |
coefficient matrix |
resid |
matrix of residuals |
sigu |
residual covariance matrix |
zmat |
data matrix |
tstat |
matrix of tratio corresponding to coef matrix |
See Chapter 5 of Lutkepohl
Jae H. Kim
Lutkepohl, H. 2005, New Introduction to Multiple Time Series Analysis, Springer
data(dat) #replicating Section 5.2.10 of Lutkepohl (2005) restrict = rbind( c(1,1,2),c(1,1,3),c(1,2,1),c(1,2,2), c(1,3,1), c(2,1,1), c(2,1,2),c(2,1,3), c(2,2,2), c(2,2,3),c(2,3,1), c(2,3,3), c(3,1,1), c(3,1,2), c(3,1,3), c(3,2,1), c(3,2,2), c(3,2,3), c(3,3,1),c(3,3,3), c(4,1,2), c(4,1,3), c(4,2,1), c(4,2,2), c(4,2,3), c(4,3,1),c(4,3,2),c(4,3,3)) M= VAR.Rest(dat,p=4,restrict,type="const",method="gls") print(M$coef) print(M$tstat)data(dat) #replicating Section 5.2.10 of Lutkepohl (2005) restrict = rbind( c(1,1,2),c(1,1,3),c(1,2,1),c(1,2,2), c(1,3,1), c(2,1,1), c(2,1,2),c(2,1,3), c(2,2,2), c(2,2,3),c(2,3,1), c(2,3,3), c(3,1,1), c(3,1,2), c(3,1,3), c(3,2,1), c(3,2,2), c(3,2,3), c(3,3,1),c(3,3,3), c(4,1,2), c(4,1,3), c(4,2,1), c(4,2,2), c(4,2,3), c(4,3,1),c(4,3,2),c(4,3,3)) M= VAR.Rest(dat,p=4,restrict,type="const",method="gls") print(M$coef) print(M$tstat)
AIC, HQ, or SC can be used
VAR.select(x, type = "const", ic = "aic", pmax)VAR.select(x, type = "const", ic = "aic", pmax)
x |
data matrix in column |
type |
"const" for the AR model with intercept only, "const+trend" for the AR model with intercept and trend |
ic |
choose one of "aic", "sc", "hq" |
pmax |
the maximum VAR order |
Order Section Criterion
IC |
Values of information criterion for VAR models |
p |
AR order selected |
See Chapter 4 of Lutkepohl
JAe H. Kim
Lutkepohl, H. 2005, New Introduction to Multiple Time Series Analysis, Springer
data(dat) #replicating Section 4.3.1 of Lutkepohl (2005) VAR.select(dat,pmax=4,ic="aic")data(dat) #replicating Section 4.3.1 of Lutkepohl (2005) VAR.select(dat,pmax=4,ic="aic")
Wald test for zero parameter restrictions based on system VAR estimation
Bootstrap option is available: iid bootstrap or wild bootstrap
Bootstrap is conducted under the null hypothesis using estimated GLS estimation: see Kim (2014)
VAR.Wald(x, p, restrict, type = "const",bootstrap=0,nb=500)VAR.Wald(x, p, restrict, type = "const",bootstrap=0,nb=500)
x |
data matrix in column |
p |
VAR order |
restrict |
Restriction matrix under H0 |
type |
"const" for the AR model with intercept only, "const+trend" for the AR model with intercept and trend |
bootstrap |
0 for no bootstrap; 1 for iid bootstrap; 2 for wild bootstrap |
nb |
the number of bootstrap iterations |
Restriction matrix is of m by 3 matrix where m is the number of restrictions. A typical row of this matrix (k,i,j), which means that (i,j) element of Ak matrix is set to 0. Ak is a VAR coefficient matrix (k = 1,....p). Under H1, the model is full VAR.
The bootstrap test is conducted using the GLS estimation under the parameter restrictions implied by the null hypothesis: see Kim (2014) for details.
Kim (2014) found that the bootstrap based on OLS can show inferior small sample properties.
There are two versions of the bootstrap: the first is based on the iid resampling and the second based on wild bootstrapping.
The Wild bootstrap is conducted with Mammen's two-point distribution.
Fstat |
Wald test statistic |
pval |
p-value of the test based on F-distribution |
Boot.pval |
p-value of the test based on bootstrapping |
See Chapter 3 of Lutkepohl
Jae H. Kim
Lutkepohl, H. 2005, New Introduction to Multiple Time Series Analysis, Springer.
Kim, J.H. 2014, Testing for parameter restrictions in a stationary VAR model: a bootstrap alternative. Economic Modelling, 41, 267-273.
data(dat) #replicating Section 3.6.2 of Lutkepohl (2005) restrict = rbind( c(1,1,2),c(1,1,3), c(2,1,2),c(2,1,3)) VAR.Wald(dat,p=2,restrict,type="const")data(dat) #replicating Section 3.6.2 of Lutkepohl (2005) restrict = rbind( c(1,1,2),c(1,1,3), c(2,1,2),c(2,1,3)) VAR.Wald(dat,p=2,restrict,type="const")