
Generate the (im)pulse formulae for a dynamic linear model
Source:R/tseffects.R
pulse.calculator.RdGenerate the (im)pulse effect formulae for a given autoregressive distributed lag (ADL) model. This is the Impulse Response Function (a one-unit, one-period increase) for the supplied lag structure, assumed to be from a dynamic linear model
Arguments
- x.vrbl
a named numeric vector in which the names correspond to an independent variable and its lags and the numbers correspond to the specific lag order of each variable
- y.vrbl
a named numeric vector in which the names correspond to lags of the dependent variable and the numbers correspond to the specific lag order of each variable. Can be
NULLif the model has no lagged dependent variables- limit
an integer representing the number of periods after the initial shock (s) to calculate the Impulse Response Function
Details
pulse.calculator does no calculation. It generates a list of mpoly formulae that contain variable names that represent the pulse effect in each period. The expectation is that these will be evaluated using coefficients from an object containing an ADL model with corresponding variables. Note: avoid passing characters not allowed by mpoly
Examples
# ADL(1,1)
x.lags <- c("x" = 0, "l_1_x" = 1) # lags of x
y.lags <- c("l_1_y" = 1)
s <- 5
pulses <- pulse.calculator(x.vrbl = x.lags, y.vrbl = y.lags, limit = s)
pulses
#> [[1]]
#> x
#>
#> [[2]]
#> l_1_x + l_1_y x
#>
#> [[3]]
#> l_1_y l_1_x + l_1_y^2 x
#>
#> [[4]]
#> l_1_y^2 l_1_x + l_1_y^3 x
#>
#> [[5]]
#> l_1_y^3 l_1_x + l_1_y^4 x
#>
#> [[6]]
#> l_1_y^4 l_1_x + l_1_y^5 x
#>
# Will also handle finite dynamics
x.lags <- c("x" = 0, "l_1_x" = 1) # lags of x
finite.pulses <- pulse.calculator(x.vrbl = x.lags, limit = s)