Skip to content

Historical decomposition with varying identification #92

@nk027

Description

@nk027

The recently introduced function to compute historical decompositions is a bit lazy – it always defaults to identification via Cholesky (thanks to Rapolas for pointing this out). This should be an easy extension – for sign-restrictions something like this should work:

hist_decomp_sr <- function(x, type = c("mean", "quantile"), sign_restr, ...) {

  type <- match.arg(type)

  # Compare this to the IRF function:
  shock <- matrix(0, x[["meta"]][["K"]] - 1, x[["meta"]][["M"]])
  shock[seq(x[["meta"]][["M"]]), ] <- t(chol(vcov(x, type = type)))

  # Now we need an extra step for the sign restriction:
  shock[seq(x[["meta"]][["M"]]), ] <- BVAR:::sign_restr(
    sigma_chol = shock, sign_restr = sign_restr, M = x[["meta"]][["M"]])
  # (BVAR::: is needed to access the internal function)

  # And proceed as before:
  comp <- companion(x, type = type)
  eps <- solve(shock[seq(x[["meta"]][["M"]]), ], t(residuals(x, type = type)))

  # This will also be an internal function
  out <- BVAR:::compute_hd(x, shock, comp, eps)

  return(out)
}

Of course, the actual API should include this as an option instead of exposing another function.

hist_decomp.bvar <- function(x, type = c("mean", "quantile"), ...) {

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions