ms_dcf_estim: Markov switching model estimation by the Kim filter (Hamilton...

Description Usage Arguments Value Author(s) Examples

View source: R/package_functions.R

Description

Model priors (initial values) Parameter naming convention DCF AR coefficients: phi1 and phi2 only Error MA coefficients: psi_i1 to psi_i2 only for each series i Error standard deviation: sigma_i only for each series i Observation coefficient on DCF: First gamma (gamma_i, ..., gamma_n) only 1 index number, not i0 Any more gammas per equation: gamma_i1 to gamma_ik Markov switching growth rate: mu_d and mu_u Transition probabilities: p_dd, p_md (or p_mu), p_mm, p_md (or p_mu), p_uu, p_ud (or p_um)

Usage

1
2
3
4
5
6
ms_dcf_estim(y, freq = NULL, panelID = NULL, timeID = NULL,
  level = 0.01, log.vars = NULL, diff.vars = NULL,
  detect.formula = F, detect.growth = F, detect.diff = F,
  diff.lag = 1, n_states = 2, ms_var = F, prior = NULL,
  formulas = c("y ~ c + e.l1 + e.l2"), weighted = F,
  optim_methods = c("BFGS", "CG", "NM"), maxit = 1000, trace = F)

Arguments

y

Multivariate time series of data values. May also be a data frame containing a date column

freq

Seasonality of the data

panelID

Column name that identifies the cross section of the data

timeID

Column name that identifies the date

level

Significance level of statistical tests (0.01, 0.05, 0.1)

log.vars

Character vector of variables to be logged

diff.vars

Character vector of unit root variables to be differenced

detect.formula

Logical, detect lag length of the dynamic common factor to include in each observation equation using the cross correlation function up to a max of 3

detect.growth

Logical, detect which variables to log

detect.diff

Logical, detect which variables to difference

diff.lag

Integer, number of lags to use for differencing

n_states

Number of states to include in the Markov switching model

ms_var,

Logical, T for Markow switching variance, default is F

prior

"estimate", "uninformative" or vector of named prior parameter guesses: DCF AR coefficients: phi1 and phi2 only; Error MA coefficients: psi_i1 to psi_i2 only for each series i; Error standard deviation: sigma_i only for each series i; Observation coefficient on DCF with first gamma (gamma_i, ..., gamma_n) only 1 index number, not i0 and any more gammas per equation: gamma_i1 to gamma_ik; Markov switching growth rate: mu_d and mu_u; Transition probabilities: p_dd, p_md (or p_mu), p_mm, p_md (or p_mu), p_uu, p_ud (or p_um)

formulas

R formula describing the relationship between each data series, the unobserved dynamic common factor, and the erorr structure

weighted

Logical, use weighted maximum likelihood. Weights are the rescaled inverse of the determinant of the forecast error covariance matrix for each observation.

optim_methods

Vector of 1 to 3 optimization methods in order of preference ("NR", "BFGS", "CG", "BHHH", or "SANN")

maxit

Maximum number of iterations for the optimization

Value

List of estimated values including coefficients, convergence code, the panel and time ids, the variables in the data, the variable that were logged, and the variables that were differenced

Author(s)

Alex Hubbard (hubbard.alex@gmail.com)

Examples

1
ms_dcf_estim(y = DT[, c("date", "y")])

opendoor-labs/MarkovSwitchingDCF documentation built on Jan. 8, 2020, 12:24 p.m.