global_sensitivity: Global Sensitivity Analysis of a DSGE Model

View source: R/global-sensitivity.R

global_sensitivityR Documentation

Global Sensitivity Analysis of a DSGE Model

Description

Quantifies how much each free parameter contributes to variation in a chosen scalar model output, sampling from the prior space. Implements two complementary methods:

  • Sobol' (Saltelli 2010): estimates first-order and total-effect variance-based sensitivity indices. More expensive but quantitatively interpretable as "share of output variance attributable to parameter i".

  • Morris (1991) elementary effects: cheaper "screening" method that produces \mu^* (mean absolute elementary effect, ranking importance) and \sigma (spread, measuring nonlinearity / interactions).

Usage

global_sensitivity(
  model,
  priors,
  target,
  method = c("sobol", "morris"),
  n_samples = 200L,
  horizon = 20L,
  data = NULL,
  seed = NULL
)

Arguments

model

A dsge_model object.

priors

Named list of dsge_prior objects, one per free structural parameter (use the same priors you would for Bayesian estimation). Shock SDs default to inv_gamma(0.1, 2) if not supplied; pass them under names "sd_e.<shock>" to override.

target

A character string naming the scalar output to analyse:

  • "sd:<var>" – model-implied unconditional standard deviation of observable <var>.

  • "cor:<v1>:<v2>" – model-implied unconditional correlation between <v1> and <v2>.

  • "irf_max:<shock>:<response>" – maximum absolute impulse response of <response> to <shock> over horizon periods.

  • "loglik" – Kalman-filter log likelihood (requires data).

method

"sobol" (default) or "morris".

n_samples

Integer. Number of base samples (Sobol uses n_samples * (k + 2) model solves total; Morris uses n_samples * (k + 1)). Default 200.

horizon

Integer. IRF horizon when target starts with "irf_max:". Default 20.

data

Required when target = "loglik".

seed

Optional integer seed.

Value

An object of class "dsge_global_sensitivity" with the computed indices and metadata. For Sobol the key fields are S_first (first-order) and S_total (total-effect); for Morris, mu_star and sigma. All indices are named by parameter.

References

Saltelli, A. et al. (2010). Variance based sensitivity analysis of model output. Computer Physics Communications, 181: 259-270.

Morris, M.D. (1991). Factorial sampling plans for preliminary computational experiments. Technometrics, 33(2): 161-174.

Examples


nk <- dsge_model(
  obs(p ~ beta * lead(p) + kappa * x),
  unobs(x ~ lead(x) - (r - lead(p) - g)),
  obs(r ~ psi * p + u),
  state(u ~ rhou * u),
  state(g ~ rhog * g),
  fixed = list(beta = 0.99),
  start = list(kappa = 0.1, psi = 1.5, rhou = 0.7, rhog = 0.9))
priors <- list(
  kappa = prior("beta",   shape1 = 2,   shape2 = 8),
  psi   = prior("normal", mean   = 1.5, sd = 0.25),
  rhou  = prior("beta",   shape1 = 5,   shape2 = 2),
  rhog  = prior("beta",   shape1 = 5,   shape2 = 2))
gs <- global_sensitivity(nk, priors, target = "sd:p",
                         method = "sobol", n_samples = 100, seed = 1)
print(gs)



dsge documentation built on Sept. 25, 2026, 5:08 p.m.