Type: | Package |
Title: | Robust Econometric Inference |
Version: | 1.1.0 |
Description: | Drawing statistical inference on the coefficients of a short- or long-horizon predictive regression with persistent regressors by using the IVX method of Magdalinos and Phillips (2009) <doi:10.1017/S0266466608090154> and Kostakis, Magdalinos and Stamatogiannis (2015) <doi:10.1093/rfs/hhu139>. |
License: | GPL-3 |
URL: | https://github.com/kvasilopoulos/ivx |
BugReports: | https://github.com/kvasilopoulos/ivx/issues |
Depends: | R (≥ 3.1) |
Imports: | methods, Rcpp (≥ 0.12.18) |
Suggests: | covr (≥ 3.2.1), forecast (≥ 8.12), spelling (≥ 2.1), testthat (≥ 2.1.1), lmtest |
Enhances: | texreg |
LinkingTo: | Rcpp (≥ 1.0.1), RcppArmadillo (≥ 0.9.300.2.0) |
Encoding: | UTF-8 |
Language: | en-US |
LazyData: | true |
RoxygenNote: | 7.1.1 |
NeedsCompilation: | yes |
Packaged: | 2020-11-24 12:52:58 UTC; T460p |
Author: | Kostas Vasilopoulos [cre, aut], Efthymios Pavlidis [aut] |
Maintainer: | Kostas Vasilopoulos <k.vasilopoulo@gmail.com> |
Repository: | CRAN |
Date/Publication: | 2020-11-24 13:50:02 UTC |
Robust Econometric Inference
Description
Drawing statistical inference on the coefficients of a short- or long-horizon predictive regression with persistent regressors by using the IVX method of Magdalinos and Phillips (2009) and Kostakis, Magdalinos and Stamatogiannis (2015).
Author(s)
Maintainer: Kostas Vasilopoulos k.vasilopoulo@gmail.com
Authors:
Efthymios Pavlidis e.pavlidis@lancaster.ac.uk
See Also
Useful links:
Autocorrelation tests
Description
Autocorrelation tests
Usage
ac_test(x, lag_max = 5)
Arguments
x |
the residuals or an |
lag_max |
the maximum length of lags. |
Examples
obj <- ivx(hpi ~ cpi + def + int + log(res), data = ylpc)
lmtest::bgtest(hpi ~ cpi + def + int + log(res), data = ylpc)
ac_test(obj, 5)
Tests for autocorrelation
Description
-
ac_test_wald
: Wald test -
ac_test_lb
: Ljung-Box -
ac_test_bp
: Box-Pierce -
ac_test_bg
: Breusch-Godfrey
Usage
ac_test_wald(x, lag)
ac_test_lb(x, lag)
ac_test_bp(x, lag)
ac_test_bg(x, order, type, fill)
Arguments
x |
an |
lag |
the number of lags. |
order |
lag TODO |
type |
the type of test statistic to be returned. Either "Chisq" for the Chi-squared test statistic or "F" for the F test statistic. |
fill |
starting values for the lagged residuals in the auxiliary regression. By default 0 but can also be set to NA. |
Details
#' If p-value < 0.051: You can reject the null hypothesis assuming a 5% chance of making a mistake. So you can assume that your values are showing dependence on each other.
Value
a numeric scalar or numeric vector.
See Also
Box.test
lmtest::bgtest
Examples
mdl <- ivx(hpi ~ cpi + inv, data = ylpc)
ac_test_wald(mdl)
Calculate the delta coefficient
Description
Computes the long-run correlation coefficient between the residuals of the predictive regression and the autoregressive model for the regressor.
Usage
delta(object)
Arguments
object |
on object of class "ivx" |
Value
A vector of the estimated correlation coefficients. This should have row and column names corresponding to the parameter names given by the coef method.
Examples
mod <- ivx(Ret ~ LTY, data = monthly)
delta(mod)
extract
method for ivx
objects
Description
extract
method for ivx
objects
Usage
extract.ivx(
model,
include.wald = TRUE,
include.nobs = TRUE,
include.aic = FALSE,
include.bic = FALSE,
include.rsquared = FALSE,
include.adjrs = FALSE,
...
)
extract.ivx_ar(
model,
include.wald = TRUE,
include.nobs = TRUE,
include.aic = FALSE,
include.bic = FALSE,
include.rsquared = FALSE,
include.adjrs = FALSE,
...
)
Arguments
model |
A statistical model object. |
include.wald |
Report the Wald statistic. |
include.nobs |
Report the number of observations in the GOF block? |
include.aic |
Report Akaike's Information Criterion (AIC) in the GOF block? |
include.bic |
Report the Bayesian Information Criterion (BIC) in the GOF block? |
include.rsquared |
Report the R-squared. |
include.adjrs |
Report the Adjusted R-squared. |
... |
Custom parameters, which are handed over to subroutines. Currently not in use. |
Fitting IVX Models
Description
ivx fits predictive regression models. The method allows standard chi-square testing for regressors with different degrees of persistence, from stationary to mildly explosive, and can be used for both short- and long-horizon predictive regressions.
Usage
ivx(
formula,
data,
horizon,
na.action,
weights,
contrasts = NULL,
offset,
model = TRUE,
x = FALSE,
y = FALSE,
...
)
## S3 method for class 'ivx'
print(x, digits = max(3L, getOption("digits") - 3L), ...)
Arguments
formula |
an object of class "formula" (or one that can be coerced to that class): a symbolic description of the model to be fitted. |
data |
n optional data frame, list or environment (or object coercible by
|
horizon |
is the horizon (default horizon = 1 corresponds to a short-horizon regression). |
na.action |
a function which indicates what should happen when the data
contain NAs. The default is set by the na.action setting of |
weights |
an optional vector of weights to be used in the fitting process.
Should be |
contrasts |
an optional list. See the |
offset |
this can be used to specify an a priori known component to be included in the linear predictor during fitting. This should be NULL or a numeric vector or matrix of extents matching those of the response. One or more offset terms can be included in the formula instead or as well, and if more than one are specified their sum is used. See model.offset |
model |
logical. If |
x |
an object of class "ivx", usually, a result of a call to ivx. |
y |
logical. If |
... |
additional arguments to be passed to the low level regression fitting functions (see lm). |
digits |
the number of significant digits to use when printing. |
Value
an object of class "ivx".
References
Magdalinos, T., & Phillips, P. (2009). Limit Theory for Cointegrated Systems with Moderately Integrated and Moderately Explosive Regressors. Econometric Theory, 25(2), 482-526.
Kostakis, A., Magdalinos, T., & Stamatogiannis, M. P. (2014). Robust econometric inference for stock return predictability. The Review of Financial Studies, 28(5), 1506-1553.
Examples
# Univariate
ivx(Ret ~ LTY, data = kms)
# Multivariate
ivx(Ret ~ LTY + TBL, data = kms)
# Longer horizon
ivx(Ret ~ LTY + TBL, data = kms, horizon = 4)
wt <- runif(nrow(kms))
ivx(Ret ~ LTY, data = kms, weights = wt)
Fitting IVX-AR Models
Description
ivx_ar implements the Yang et al (2020) new instrumental variable based Wald statistic (IVX-AR) which accounts for serial correlation and heteroscedasticity in the error terms of the linear predictive regression model.
Usage
ivx_ar(
formula,
data,
horizon,
ar = "auto",
ar_ic = c("bic", "aic", "aicc"),
ar_max = 5,
ar_grid = function(x) seq(x - 0.3, x + 0.3, by = 0.02),
na.action,
contrasts = NULL,
offset,
model = TRUE,
x = FALSE,
y = FALSE,
...
)
## S3 method for class 'ivx_ar'
print(x, digits = max(3L, getOption("digits") - 3L), ...)
Arguments
formula |
an object of class "formula" (or one that can be coerced to that class): a symbolic description of the model to be fitted. |
data |
n optional data frame, list or environment (or object coercible by
|
horizon |
is the horizon (default horizon = 1 corresponds to a short-horizon regression). |
ar |
Method to include the autoregressive terms. "auto" find the optimal
ar order by using the information criteria. |
ar_ic |
Information criterion to be used in model selection. |
ar_max |
Maximum ar order of model to fit. |
ar_grid |
The ar grid sequence of which to iterate. |
na.action |
a function which indicates what should happen when the data
contain NAs. The default is set by the na.action setting of |
contrasts |
an optional list. See the |
offset |
this can be used to specify an a priori known component to be included in the linear predictor during fitting. This should be NULL or a numeric vector or matrix of extents matching those of the response. One or more offset terms can be included in the formula instead or as well, and if more than one are specified their sum is used. See model.offset |
model |
logical. If |
x |
an object of class "ivx_ar", usually, a result of a call to ivx_ar. |
y |
logical. If |
... |
additional arguments to be passed to the low level regression fitting functions (see lm). |
digits |
the number of significant digits to use when printing. |
References
Yang, B., Long, W., Peng, L., & Cai, Z. (2020). Testing the Predictability of US Housing Price Index Returns Based on an IVX-AR Model. Journal of the American Statistical Association, 1-22. DOI: doi: 10.1080/01621459.2019.1686392
Examples
ivx_ar(hpi ~ log(res) + cpi, ylpc)
ivx_ar(hpi ~ log(res) + cpi, ylpc, ar_ic = "aic")
ivx_ar(hpi ~ log(res) + cpi, ylpc, ar = 1)
Fitter Functions for IVX-AR Models
Description
Basic function called by ivx_ar
to fit predictive models.
These should only be used directly by experienced users.
Usage
ivx_ar_fit(
y,
x,
horizon = 1,
offset = NULL,
ar = "auto",
ar_max = 5,
ar_ic = "bic",
ar_grid = function(x) seq(x - 0.3, x + 0.3, by = 0.02),
...
)
Arguments
y |
vector of observations of length |
x |
design matrix of dimension |
horizon |
is the horizon (default horizon = 1 corresponds to a short-horizon regression). |
offset |
(numeric of length |
ar |
Method to include the autoregressive terms. "auto" find the optimal
ar order by using the information criteria. |
ar_max |
Maximum ar order of model to fit. |
ar_ic |
Information criterion to be used in model selection. |
ar_grid |
The ar grid sequence of which to iterate. |
... |
Further arguments passed to the function which is fitting the best AR model.
If |
Examples
ivx_ar_fit(monthly$Ret, as.matrix(monthly$LTY))
ivx_ar_fit(monthly$Ret, as.matrix(monthly$LTY), ar = 1)
Fitter Functions for IVX Models
Description
Basic function called by ivx
to fit predictive models.
These should only be used directly by experienced users.
Usage
ivx_fit(y, x, horizon = 1, offset = NULL, ...)
ivx_wfit(y, x, w, horizon = 1, offset = NULL, ...)
Arguments
y |
vector of observations of length |
x |
design matrix of dimension |
horizon |
is the horizon (default horizon = 1 corresponds to a short-horizon regression). |
offset |
(numeric of length |
... |
currently disregarded. |
w |
vector of weights (length |
Examples
ivx_fit(monthly$Ret, as.matrix(monthly$LTY))
KMS Monthly data
Description
The dataset that was used in Kostakis et al (2015), containing a range of financial variables.
Date: year-month-date (monthly frequency)
DE: dividend payout ratio
LTY: long-term yield
DY: dividend yield
DP: dividend-price ratio
TBL: T-bill rate
EP: earnings-price ratio
BM: book-to-market value ratio
INF: inflation rate
DFY: default yield spread
NTIS: net equity expansion
TMS: term spread
Ret: S&P 500 value-weighted log excess returns
Usage
kms
Format
A data.frame with 13 variables and 1,033 observations.
Source
https://drive.google.com/open?id=1FdT2STHO2Lnlweom4AwICVf-rpVMfgV4
KMS Quarterly data
Description
The dataset that was used in Kostakis et al (2015), containing a range of financial variables.
Date: year-month-date
DE: dividend payout ratio
LTY: long-term yield
DY: dividend yield
DP: dividend-price ratio
TBL: T-bill rate
EP: earnings-price ratio
BM: book-to-market value ratio
INF: inflation rate
DFY: default yield spread
NTIS: net equity expansion
TMS: term spread
Ret: S&P 500 value-weighted log excess returns
Usage
kms_quarterly
Format
A data.frame with 13 variables and 345 observations.
Source
https://drive.google.com/open?id=1FdT2STHO2Lnlweom4AwICVf-rpVMfgV4
Monthly dataset of KMS
Description
Monthly dataset of KMS
Usage
monthly
Format
An object of class tbl_df
(inherits from tbl
, data.frame
) with 1033 rows and 13 columns.
Quarterly dataset of KMS
Description
Quarterly dataset of KMS
Usage
quarterly
Format
An object of class tbl_df
(inherits from tbl
, data.frame
) with 345 rows and 13 columns.
Summarizing IVX Model Fits
Description
summary method for class "ivx".
Usage
## S3 method for class 'ivx'
summary(object, ...)
## S3 method for class 'summary.ivx'
print(
x,
digits = max(3L, getOption("digits") - 3L),
signif.stars = getOption("show.signif.stars"),
...
)
Arguments
object |
object of class "ivx", usually, a result of a call to ivx. |
... |
further arguments passed to or from other methods. |
x |
an object of class |
digits |
the number of significant digits to use when printing. |
signif.stars |
logical. If |
Examples
mod <- ivx(Ret ~ LTY, data = monthly)
summary(mod)
Summarizing IVX-AR Model Fits
Description
summary method for class "ivx".
Usage
## S3 method for class 'ivx_ar'
summary(object, ...)
## S3 method for class 'summary.ivx_ar'
print(
x,
digits = max(3L, getOption("digits") - 3L),
signif.stars = getOption("show.signif.stars"),
...
)
Arguments
object |
object of class "ivx_ar", usually, a result of a call to ivx_ar. |
... |
further arguments passed to or from other methods. |
x |
an object of class |
digits |
the number of significant digits to use when printing. |
signif.stars |
logical. If |
Examples
mod <- ivx_ar(Ret ~ LTY, data = kms)
summary(mod)
Calculate Variance-Covariance Matrix for a Fitted Model Object
Description
Calculate Variance-Covariance Matrix for a Fitted Model Object
Usage
## S3 method for class 'ivx'
vcov(object, complete = TRUE, ...)
## S3 method for class 'summary.ivx'
vcov(object, complete = TRUE, ...)
Arguments
object |
a fitted ivx and summary.ivx object. |
complete |
logical indicating if the full variance-covariance matrix should be returned. When complete = TRUE, vcov() is compatible with coef(). |
... |
additional arguments for method functions. |
Value
A matrix of the estimated covariances between the parameter estimates of the model. This should have row and column names corresponding to the parameter names given by the coef method.
Examples
mod <- ivx(Ret ~ LTY, data = monthly)
vcov(mod)
YLPC Quarterly data
Description
The dataset that was used in ..., containing a range of variables.
Usage
ylpc
Format
An object of class spec_tbl_df
(inherits from tbl_df
, tbl
, data.frame
) with 174 rows and 12 columns.