
Generate the General Dynamic Treatment Effect (GDTE) for an autoregressive distributed lag (ADL) model, given Pulse Treatment Effects (PTEs)
Source:R/tseffects.R
GDTE.calculator.Rd
Generate the General Dynamic Treatment Effect (GDTE) for an autoregressive distributed lag (ADL) model, given Pulse Treatment Effects (PTEs)
Arguments
- d.x
the order of differencing of the x variable in the ADL model. (Generally, this is the same x variable used in
pte.calculator
)- d.y
the order of differencing of the y variable in the ADL model. (Generally, this is the same y variable used in
pte.calculator
)- n
an integer for the treatment history.
n
determines the counterfactual series that will be applied to the independent variable. -1 represents a Pulse Treatment Effect (PTE). 0 represents a Step Treatment Effect (STE). For others, see Vande Kamp, Jordan, and Rajan- limit
an integer for the number of periods to determine the GDTE (beginning at 0)
- pte
a list of PTEs used to construct the GDTE. We expect this will be provided by
pte.calculator
Details
GDTE.calculator
does no calculation. It generates a list of mpoly
formulae that contain variable names that represent the GDTE in each period. The expectation is that these will be evaluated using coefficients from an object containing an ADL model with corresponding variables. It is used as a subfunction in both ts.ci.adl.plot
and ts.ci.gecm.plot
. Note: mpoly
does not allow variable names with a .; variables passed to GDTE.calculator
should not include this character
Examples
# ADL(1,1)
x.lags <- c("x" = 0, "l_1_x" = 1) # lags of x
y.lags <- c("l_1_y" = 1)
h <- 5
PTEs <- pte.calculator(x.vrbl = x.lags, y.vrbl = y.lags, limit = h)
# Assume that both x and y are in levels and we want a pulse treatment
GDTEs.pte <- GDTE.calculator(d.x = 0, d.y = 0, n = -1, limit = h, pte = PTEs)
GDTEs.pte
#> $formulae
#> $formulae[[1]]
#> [1] "x "
#>
#> $formulae[[2]]
#> [1] "l_1_x + l_1_y * x "
#>
#> $formulae[[3]]
#> [1] "l_1_y * l_1_x + l_1_y**2 * x "
#>
#> $formulae[[4]]
#> [1] "l_1_y**2 * l_1_x + l_1_y**3 * x "
#>
#> $formulae[[5]]
#> [1] "l_1_y**3 * l_1_x + l_1_y**4 * x "
#>
#> $formulae[[6]]
#> [1] "l_1_y**4 * l_1_x + l_1_y**5 * x "
#>
#>
#> $binomials
#> $binomials[[1]]
#> [1] 1
#>
#> $binomials[[2]]
#> [1] 1 0
#>
#> $binomials[[3]]
#> [1] 1 0 0
#>
#> $binomials[[4]]
#> [1] 1 0 0 0
#>
#> $binomials[[5]]
#> [1] 1 0 0 0 0
#>
#> $binomials[[6]]
#> [1] 1 0 0 0 0 0
#>
#>
# Apply a step treatmentr
GDTEs.ste <- GDTE.calculator(d.x = 0, d.y = 0, n = 0, limit = h, pte = PTEs)
GDTEs.ste
#> $formulae
#> $formulae[[1]]
#> [1] "x "
#>
#> $formulae[[2]]
#> [1] "l_1_x + l_1_y * x + x "
#>
#> $formulae[[3]]
#> [1] "l_1_y * l_1_x + l_1_y**2 * x + l_1_x + l_1_y * x + x "
#>
#> $formulae[[4]]
#> [1] "l_1_y**2 * l_1_x + l_1_y**3 * x + l_1_y * l_1_x + l_1_y**2 * x + l_1_x + l_1_y * x + x "
#>
#> $formulae[[5]]
#> [1] "l_1_y**3 * l_1_x + l_1_y**4 * x + l_1_y**2 * l_1_x + l_1_y**3 * x + l_1_y * l_1_x + l_1_y**2 * x + l_1_x + l_1_y * x + x "
#>
#> $formulae[[6]]
#> [1] "l_1_y**4 * l_1_x + l_1_y**5 * x + l_1_y**3 * l_1_x + l_1_y**4 * x + l_1_y**2 * l_1_x + l_1_y**3 * x + l_1_y * l_1_x + l_1_y**2 * x + l_1_x + l_1_y * x + x "
#>
#>
#> $binomials
#> $binomials[[1]]
#> [1] 1
#>
#> $binomials[[2]]
#> [1] 1 1
#>
#> $binomials[[3]]
#> [1] 1 1 1
#>
#> $binomials[[4]]
#> [1] 1 1 1 1
#>
#> $binomials[[5]]
#> [1] 1 1 1 1 1
#>
#> $binomials[[6]]
#> [1] 1 1 1 1 1 1
#>
#>