model_covariance: Model-implied covariance and correlation matrices

View source: R/model-covariance.R

model_covarianceR Documentation

Model-implied covariance and correlation matrices

Description

Computes the unconditional (model-implied) covariance and correlation matrices of observable variables from a solved or estimated DSGE model. These are the theoretical second moments implied by the model at the given parameter values.

Usage

model_covariance(x, variables = NULL, n_lags = 0L, ...)

Arguments

x

A fitted model ("dsge_fit", "dsge_bayes") or a solved model ("dsge_solution").

variables

Character vector of variable names to include. Default NULL returns all observable variables.

n_lags

Integer. If positive, also compute autocovariances at lags 1, ..., n_lags. Default 0 (contemporaneous only).

...

Additional arguments (currently unused).

Value

An object of class "dsge_covariance" containing:

covariance

Covariance matrix of selected variables.

correlation

Correlation matrix of selected variables.

std_dev

Standard deviations (square root of diagonal).

autocovariances

List of lagged autocovariance matrices (empty if n_lags = 0).

variables

Variable names.

n_lags

Number of autocovariance lags computed.

Examples

mod <- dsge_model(
  obs(pi ~ beta * lead(pi) + kappa * x),
  unobs(x ~ lead(x) - (r - lead(pi) - g)),
  obs(r ~ psi * pi + u),
  state(u ~ rhou * u),
  state(g ~ rhog * g),
  fixed = list(beta = 0.99),
  start = list(kappa = 0.1, psi = 1.5, rhou = 0.5, rhog = 0.5)
)
p <- list(kappa = 0.1, psi = 1.5, rhou = 0.5, rhog = 0.5)
s <- c(u = 0.5, g = 0.5)
sol <- solve_dsge(mod, params = p, shock_sd = s)
model_covariance(sol)


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