RLP {sovereign} | R Documentation |
Estimate regime-dependent local projections
Description
Estimate a regime-dependent local projection (i.e. a state-dependent LP), with an exogenous state indicator, of the specification:
Y_{t+h} = X_t \beta_{s_t} + \epsilon_t
where t is the time index, and s is a mutually exclusive state of the world observed at time t. When the regime vector is not supplied by the user, then a two-state regime series is estimated via random forest.
Usage
RLP(
data,
horizons = 1,
freq = "month",
type = "const",
p = 1,
lag.ic = NULL,
lag.max = NULL,
NW = FALSE,
NW_lags = NULL,
NW_prewhite = NULL,
regime = NULL,
regime.method = "rf",
regime.n = 2
)
Arguments
data |
data.frame, matrix, ts, xts, zoo: Endogenous regressors |
horizons |
int: forecast horizons |
freq |
string: frequency of data ('day', 'week', 'month', 'quarter', or 'year') |
type |
string: type of deterministic terms to add ('none', 'const', 'trend', or 'both') |
p |
int: lags |
lag.ic |
string: information criterion to choose the optimal number of lags ('AIC' or 'BIC') |
lag.max |
int: maximum number of lags to test in lag selection |
NW |
boolean: Newey-West correction on variance-covariance matrix |
NW_lags |
int: number of lags to use in Newey-West correction |
NW_prewhite |
boolean: TRUE prewhite option for Newey-West correction (see sandwich::NeweyWest) |
regime |
string: name or regime assignment vector in the design matrix (data) |
regime.method |
string: regime assignment technique ('rf', 'kmeans', 'EM', 'BP') |
regime.n |
int: number of regimes to estimate (applies to kmeans and EM) |
Value
list of lists, one list per regime, each regime with objects with elements data
, model
, forecasts
, residuals
;
if there is more than one forecast horizon estimated, then model
, forecasts
, residuals
will each be a list where each element corresponds to a single horizon
References
Jorda, Oscar "Estimation and Inference of Impulse Responses by Local Projections" 2005.
See Also
Examples
# simple time series
AA = c(1:100) + rnorm(100)
BB = c(1:100) + rnorm(100)
CC = AA + BB + rnorm(100)
date = seq.Date(from = as.Date('2000-01-01'), by = 'month', length.out = 100)
Data = data.frame(date = date, AA, BB, CC)
# add regime
Data = dplyr::mutate(Data, reg = dplyr::if_else(AA > median(AA), 1, 0))
# local projection forecasts
rlp =
sovereign::RLP(
data = Data,
regime = 'reg',
horizon = c(1:10),
freq = 'month',
p = 1,
type = 'const',
NW = TRUE,
NW_lags = 1,
NW_prewhite = FALSE)
# impulse response function
rirf = sovereign::rlp_irf(rlp)