Summarises response half-lives from posterior draws
Source:R/response-summary.R
half_life_response.RdTransforms posterior draws of impulse responses or cumulative dynamic multipliers into summaries of the first horizon at which a response falls to a chosen fraction of its initial or peak level.
Usage
half_life_response(object, ...)
# Default S3 method
half_life_response(object, ...)
# S3 method for class 'PosteriorIR'
half_life_response(
object,
variables = NULL,
shocks = NULL,
variable = NULL,
shock = NULL,
fraction = 0.5,
baseline = c("peak", "initial"),
absolute = TRUE,
probability = 0.9,
model = "model1",
...
)
# S3 method for class 'PosteriorBSVAR'
half_life_response(
object,
horizon = NULL,
type = c("irf", "cdm"),
variables = NULL,
shocks = NULL,
variable = NULL,
shock = NULL,
fraction = 0.5,
baseline = c("peak", "initial"),
absolute = TRUE,
probability = 0.9,
model = "model1",
scale_by = c("none", "shock_sd"),
scale_var = NULL,
...
)
# S3 method for class 'PosteriorBSVARMIX'
half_life_response(
object,
horizon = NULL,
type = c("irf", "cdm"),
variables = NULL,
shocks = NULL,
variable = NULL,
shock = NULL,
fraction = 0.5,
baseline = c("peak", "initial"),
absolute = TRUE,
probability = 0.9,
model = "model1",
scale_by = c("none", "shock_sd"),
scale_var = NULL,
...
)
# S3 method for class 'PosteriorBSVARMSH'
half_life_response(
object,
horizon = NULL,
type = c("irf", "cdm"),
variables = NULL,
shocks = NULL,
variable = NULL,
shock = NULL,
fraction = 0.5,
baseline = c("peak", "initial"),
absolute = TRUE,
probability = 0.9,
model = "model1",
scale_by = c("none", "shock_sd"),
scale_var = NULL,
...
)
# S3 method for class 'PosteriorBSVARSV'
half_life_response(
object,
horizon = NULL,
type = c("irf", "cdm"),
variables = NULL,
shocks = NULL,
variable = NULL,
shock = NULL,
fraction = 0.5,
baseline = c("peak", "initial"),
absolute = TRUE,
probability = 0.9,
model = "model1",
scale_by = c("none", "shock_sd"),
scale_var = NULL,
...
)
# S3 method for class 'PosteriorBSVART'
half_life_response(
object,
horizon = NULL,
type = c("irf", "cdm"),
variables = NULL,
shocks = NULL,
variable = NULL,
shock = NULL,
fraction = 0.5,
baseline = c("peak", "initial"),
absolute = TRUE,
probability = 0.9,
model = "model1",
scale_by = c("none", "shock_sd"),
scale_var = NULL,
...
)
# S3 method for class 'PosteriorBSVARSIGN'
half_life_response(
object,
horizon = NULL,
type = c("irf", "cdm"),
variables = NULL,
shocks = NULL,
variable = NULL,
shock = NULL,
fraction = 0.5,
baseline = c("peak", "initial"),
absolute = TRUE,
probability = 0.9,
model = "model1",
scale_by = c("none", "shock_sd"),
scale_var = NULL,
...
)
# S3 method for class 'PosteriorCDM'
half_life_response(
object,
variables = NULL,
shocks = NULL,
variable = NULL,
shock = NULL,
fraction = 0.5,
baseline = c("peak", "initial"),
absolute = TRUE,
probability = 0.9,
model = "model1",
...
)Arguments
- object
A posterior model object,
PosteriorIR, orPosteriorCDM.- ...
Additional arguments passed to computation methods.
- variables
Response variables to include (character or integer vector).
- shocks
Structural shocks to include (character or integer vector).
- variable
Deprecated. Use
variablesinstead.- shock
Deprecated. Use
shocksinstead.- fraction
Fraction of the reference level used to define the half-life.
- baseline
Reference level:
"peak"uses the largest response over the available horizons,"initial"uses the horizon-0 response.- absolute
If
TRUE, search for the largest absolute response.- probability
Probability mass of the equal-tailed credible interval.
- model
Label identifying the model specification.
- horizon
Maximum horizon used when
objectis a posterior model object.- type
Response type for posterior model objects:
"irf"or"cdm".- scale_by
Optional scaling mode for CDMs.
- scale_var
Optional scaling variable specification.
Value
A bsvar_post_tbl with columns model,
object_type, variable, shock, fraction,
baseline, mean_half_life, median_half_life,
sd_half_life, lower_half_life, upper_half_life,
and reached_prob.
Details
reached_prob is the fraction of stored draws with a defined
half-life within the available horizon. A draw has no defined half-life
when its reference response is nonpositive or it never reaches the target.
Timing summaries condition on draws with a defined half-life; they are
NA when none qualify. The standard deviation is NA with one qualifying
draw. Missing or nonfinite input responses are rejected.
Examples
data(us_fiscal_lsuw, package = "bsvars")
spec <- bsvars::specify_bsvar$new(us_fiscal_lsuw, p = 1)
#> The identification is set to the default option of lower-triangular structural matrix.
post <- bsvars::estimate(spec, S = 5, show_progress = FALSE)
hl <- half_life_response(post, horizon = 3)
print(hl)
#> # A tibble: 9 × 22
#> model object_type variable shock fraction baseline mean_half_life
#> <chr> <chr> <chr> <chr> <dbl> <chr> <dbl>
#> 1 model1 half_life_irf ttr ttr 0.5 peak NA
#> 2 model1 half_life_irf ttr gs 0.5 peak NA
#> 3 model1 half_life_irf ttr gdp 0.5 peak 1
#> 4 model1 half_life_irf gs ttr 0.5 peak NA
#> 5 model1 half_life_irf gs gs 0.5 peak NA
#> 6 model1 half_life_irf gs gdp 0.5 peak NA
#> 7 model1 half_life_irf gdp ttr 0.5 peak NA
#> 8 model1 half_life_irf gdp gs 0.5 peak NA
#> 9 model1 half_life_irf gdp gdp 0.5 peak NA
#> # ℹ 15 more variables: median_half_life <dbl>, sd_half_life <dbl>,
#> # lower_half_life <dbl>, upper_half_life <dbl>, reached_prob <dbl>,
#> # analysis_type <chr>, interval_probability <dbl>, interval_method <chr>,
#> # scale_by <chr>, scale_var <chr>, scale_factor <dbl>, units <chr>,
#> # source_package <chr>, source_version <chr>, n_draws <int>