| Title: | Dynamic Stochastic General Equilibrium Models |
|---|---|
| Description: | Specify, solve, and estimate dynamic stochastic general equilibrium (DSGE) models by maximum likelihood and Bayesian methods. Supports both linear models via an equation-based formula interface and nonlinear models via string-based equations with first-order perturbation (linearization around deterministic steady state). Solution uses the method of undetermined coefficients (Klein, 2000 <doi:10.1016/S0165-1889(99)00045-7>). Likelihood evaluated via the Kalman filter. Bayesian estimation uses adaptive Random-Walk Metropolis-Hastings with prior specification. Additional tools include Kalman smoothing, historical shock decomposition, local identification diagnostics, parameter sensitivity analysis, second-order perturbation, occasionally binding constraints, impulse-response functions, forecasting, and robust standard errors. |
| Authors: | Mustapha Wasseja Mohammed [aut, cre] |
| Maintainer: | Mustapha Wasseja Mohammed <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 1.0.0 |
| Built: | 2026-06-02 07:27:35 UTC |
| Source: | https://github.com/cran/dsge |
Estimates the parameters of a DSGE model using Random-Walk Metropolis-Hastings (RWMH) with adaptive proposal covariance. Supports both linear models (dsge_model) and nonlinear models (dsgenl_model). For nonlinear models, the steady state is re-solved and the model re-linearized at each candidate parameter vector.
bayes_dsge( model, data, priors, chains = 2L, iter = 5000L, warmup = floor(iter/2), thin = 1L, proposal_scale = 0.1, demean = TRUE, seed = NULL )bayes_dsge( model, data, priors, chains = 2L, iter = 5000L, warmup = floor(iter/2), thin = 1L, proposal_scale = 0.1, demean = TRUE, seed = NULL )
model |
A |
data |
A data frame, matrix, or |
priors |
Named list of |
chains |
Integer. Number of MCMC chains. Default is 2. |
iter |
Integer. Total iterations per chain (warmup + sampling). Default is 5000. |
warmup |
Integer. Number of warmup iterations. Default is
|
thin |
Integer. Thinning interval. Default is 1. |
proposal_scale |
Numeric. Initial proposal standard deviation scale. Default is 0.1. |
demean |
Logical. If |
seed |
Integer. Random seed for reproducibility. If |
The sampler operates in unconstrained space with appropriate transformations (log for positive parameters, logit for unit-interval parameters) and Jacobian corrections. The proposal covariance is adapted during warmup to target approximately 25\
Chains are initialized by drawing from the prior. If any draw yields a non-finite log-posterior, the starting values are jittered until a valid point is found.
For nonlinear models (dsgenl_model), each posterior evaluation
involves: (1) solving the deterministic steady state at the candidate
parameters, (2) computing a first-order linearization, (3) solving
the resulting linear system, and (4) evaluating the Kalman filter
likelihood. If any stage fails (e.g., steady-state non-convergence,
Blanchard-Kahn violation), the proposal is safely rejected. This is
computationally more expensive than linear Bayesian estimation.
An object of class "dsge_bayes" containing posterior draws
and diagnostics. For nonlinear models, the result also includes
solve_failures, the number of parameter draws where steady-state,
linearization, or solution failed.
m <- dsge_model( obs(y ~ z), state(z ~ rho * z), start = list(rho = 0.5) ) set.seed(42) z <- numeric(200); for (i in 2:200) z[i] <- 0.8 * z[i-1] + rnorm(1) dat <- data.frame(y = z) fit <- bayes_dsge(m, data = dat, priors = list(rho = prior("beta", shape1 = 2, shape2 = 2)), chains = 2, iter = 2000, seed = 1) summary(fit)m <- dsge_model( obs(y ~ z), state(z ~ rho * z), start = list(rho = 0.5) ) set.seed(42) z <- numeric(200); for (i in 2:200) z[i] <- 0.8 * z[i-1] + rnorm(1) dat <- data.frame(y = z) fit <- bayes_dsge(m, data = dat, priors = list(rho = prior("beta", shape1 = 2, shape2 = 2)), chains = 2, iter = 2000, seed = 1) summary(fit)
Assesses local identification by computing the Jacobian of the mapping from structural parameters to model-implied autocovariance moments. Uses an SVD decomposition to detect rank deficiency (non-identification) and near-collinearity (weak identification).
check_identification(x, ...) ## S3 method for class 'dsge_fit' check_identification(x, n_lags = 4L, tol = 1e-06, ...) ## S3 method for class 'dsge_bayes' check_identification(x, n_lags = 4L, tol = 1e-06, ...)check_identification(x, ...) ## S3 method for class 'dsge_fit' check_identification(x, n_lags = 4L, tol = 1e-06, ...) ## S3 method for class 'dsge_bayes' check_identification(x, n_lags = 4L, tol = 1e-06, ...)
x |
A |
... |
Additional arguments (currently unused). |
n_lags |
Integer. Number of autocovariance lags to include in the moment vector. Default is 4. |
tol |
Numeric. Singular values below |
The identification check constructs the moment vector
where is the autocovariance of observables at lag k,
implied by the state-space solution. The Jacobian
is computed numerically.
A parameter is locally identified if the Jacobian has full column rank. If the rank is deficient, some linear combination of parameters cannot be distinguished from the data.
Per-parameter identification strength is measured by the norm of the corresponding Jacobian column: parameters with small column norms have little influence on the moments and may be weakly identified.
The condition number of J flags near-collinearity: a large condition number indicates that some parameter combinations are hard to distinguish.
An object of class "dsge_identification" containing:
The Jacobian matrix (n_moments x n_params).
SVD decomposition of the Jacobian.
Numerical rank of the Jacobian.
Logical: are all parameters locally identified?
Vector of singular values.
Per-parameter identification strength (norm of corresponding Jacobian column).
Condition number of the Jacobian.
Character vector of parameter names.
Data frame with per-parameter diagnostics.
m <- dsge_model( obs(y ~ z), state(z ~ rho * z), start = list(rho = 0.5) ) set.seed(1) z <- numeric(100); for (i in 2:100) z[i] <- 0.8*z[i-1]+rnorm(1) fit <- estimate(m, data = data.frame(y = z)) id <- check_identification(fit) print(id)m <- dsge_model( obs(y ~ z), state(z ~ rho * z), start = list(rho = 0.5) ) set.seed(1) z <- numeric(100); for (i in 2:100) z[i] <- 0.8*z[i-1]+rnorm(1) fit <- estimate(m, data = data.frame(y = z)) id <- check_identification(fit) print(id)
Constructs a linear DSGE model object from a set of equations.
Each equation is wrapped in obs(), unobs(), or state() to
indicate the role of the left-hand-side variable.
dsge_model(..., fixed = list(), start = list())dsge_model(..., fixed = list(), start = list())
... |
Equation specifications created by |
fixed |
Named list of parameter values to hold fixed (constrained) during estimation. |
start |
Named list of starting values for free parameters. |
A linear DSGE model is specified as a system of equations in which variables enter linearly but parameters may enter nonlinearly.
Use lead(x) or E(x) within formulas to denote the one-period-ahead
model-consistent expectation of variable x.
The number of exogenous state variables (those with shocks) must equal the number of observed control variables.
An object of class "dsge_model" containing:
List of parsed equation objects.
List with elements observed, unobserved,
exo_state, endo_state.
Character vector of all parameter names.
Character vector of free (estimable) parameter names.
Named list of fixed parameter values.
Named list of starting values.
# Simple New Keynesian model 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.96), start = list(kappa = 0.1, psi = 1.5, rhou = 0.7, rhog = 0.9) )# Simple New Keynesian model 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.96), start = list(kappa = 0.1, psi = 1.5, rhou = 0.7, rhog = 0.9) )
Constructs a nonlinear DSGE model from string-based equations.
Each equation is a character string of the form "LHS = RHS".
State equations are detected automatically when the left-hand side
is of the form VAR(+1).
dsgenl_model( ..., observed = character(0), unobserved = character(0), exo_state, endo_state = character(0), fixed = list(), start = list(), ss_guess = NULL, ss_function = NULL )dsgenl_model( ..., observed = character(0), unobserved = character(0), exo_state, endo_state = character(0), fixed = list(), start = list(), ss_guess = NULL, ss_function = NULL )
... |
Character strings, each defining one model equation.
Use |
observed |
Character vector of observed control variable names. |
unobserved |
Character vector of unobserved control variable names.
Default is |
exo_state |
Character vector of exogenous state variable names. These have shocks attached. The number of exogenous states must equal the number of observed controls. |
endo_state |
Character vector of endogenous (predetermined) state
variable names. These have no shocks. Default is |
fixed |
Named list of parameter values to hold fixed during estimation. |
start |
Named list of starting values for free parameters. |
ss_guess |
Named numeric vector of initial guesses for steady-state
solving. If |
ss_function |
Optional function that computes the steady state analytically. Must accept a named parameter vector and return a named numeric vector of steady-state variable values. |
Equations are written in standard mathematical notation with = as
the equality sign and VAR(+1) for leads. For example:
"1/C = beta / C(+1) * (alpha * K^(alpha-1) + 1 - delta)"
State equations must have exactly one lead variable on the left-hand side
(e.g., "K(+1) = K^alpha - C + (1 - delta) * K"). Control equations
are all remaining equations.
Control equations must be provided in the order matching the controls vector (observed first, then unobserved).
An object of class "dsgenl_model".
# Simple RBC model rbc <- dsgenl_model( "1/C = beta / C(+1) * (alpha * exp(Z) * K^(alpha-1) + 1 - delta)", "K(+1) = exp(Z) * K^alpha - C + (1 - delta) * K", "Z(+1) = rho * Z", observed = "C", endo_state = "K", exo_state = "Z", fixed = list(alpha = 0.33, beta = 0.99, delta = 0.025), start = list(rho = 0.9) )# Simple RBC model rbc <- dsgenl_model( "1/C = beta / C(+1) * (alpha * exp(Z) * K^(alpha-1) + 1 - delta)", "K(+1) = exp(Z) * K^alpha - C + (1 - delta) * K", "Z(+1) = rho * Z", observed = "C", endo_state = "K", exo_state = "Z", fixed = list(alpha = 0.33, beta = 0.99, delta = 0.025), start = list(rho = 0.9) )
A user-friendly alias for lead(x, 1). Represents the one-period-ahead
model-consistent expectation of variable x.
E(x)E(x)
x |
A variable name (unquoted) within a DSGE equation formula. |
E(x) is equivalent to lead(x, 1). The parser translates E(x) to
lead(x, 1) internally.
This function is not meant to be called directly; it always
throws an error. It is recognized as a syntactic marker by the
equation parser inside dsge_model().
Estimates the parameters of a linear DSGE model by maximizing the log-likelihood computed via the Kalman filter.
estimate( model, data, start = NULL, fixed = NULL, method = "BFGS", control = list(), shock_start = NULL, demean = TRUE, hessian = TRUE )estimate( model, data, start = NULL, fixed = NULL, method = "BFGS", control = list(), shock_start = NULL, demean = TRUE, hessian = TRUE )
model |
A |
data |
A data frame, matrix, or |
start |
Named list of starting values for free parameters. Overrides any starting values specified in the model. |
fixed |
Named list of fixed parameter values. Overrides any fixed values specified in the model. |
method |
Optimization method passed to |
control |
Control list passed to |
shock_start |
Named numeric vector of starting values for shock
standard deviations. If |
demean |
Logical. If |
hessian |
Logical. If |
The estimator optimizes over the structural parameters and the log standard deviations of the shocks. Shock standard deviations are parameterized in log-space to ensure positivity.
If the optimizer encounters parameter values for which the model is
not saddle-path stable, the log-likelihood is set to -Inf.
An object of class "dsge_fit".
# Define a simple AR(1) model m <- dsge_model( obs(y ~ z), state(z ~ rho * z), start = list(rho = 0.5) ) # Simulate some data set.seed(42) e <- rnorm(200) z <- numeric(200) for (i in 2:200) z[i] <- 0.8 * z[i-1] + e[i] dat <- data.frame(y = z) fit <- estimate(m, data = dat) summary(fit)# Define a simple AR(1) model m <- dsge_model( obs(y ~ z), state(z ~ rho * z), start = list(rho = 0.5) ) # Simulate some data set.seed(42) e <- rnorm(200) z <- numeric(200) for (i in 2:200) z[i] <- 0.8 * z[i-1] + e[i] dat <- data.frame(y = z) fit <- estimate(m, data = dat) summary(fit)
Returns filtered fitted values of observed variables (using all information up to and including time t).
## S3 method for class 'dsge_fit' fitted(object, ...)## S3 method for class 'dsge_fit' fitted(object, ...)
object |
A |
... |
Additional arguments (currently unused). |
A matrix of fitted values with columns named by observed variables.
Generic function for forecasting from estimated DSGE models.
forecast(object, ...)forecast(object, ...)
object |
A fitted model object. |
... |
Additional arguments passed to methods. |
A forecast object.
Produces dynamic multi-step forecasts from a fitted DSGE model. Forecasts are generated by iterating the state-space solution forward from the last filtered state.
## S3 method for class 'dsge_fit' forecast(object, horizon = 12L, ...)## S3 method for class 'dsge_fit' forecast(object, horizon = 12L, ...)
object |
A |
horizon |
Integer. Number of periods to forecast ahead. Default is 12. |
... |
Additional arguments (currently unused). |
An object of class "dsge_forecast" containing:
Data frame with columns period, variable, value.
The forecast horizon.
Matrix of forecasted state vectors.
Computes Geweke's (1992) convergence diagnostic, which compares the means of the first and last portions of each chain using a z-test.
geweke_test(object, ...)geweke_test(object, ...)
object |
A |
... |
Additional arguments passed to methods (e.g., |
An object of class "dsge_geweke" with z-scores and
p-values for each parameter and chain.
Computes impulse-response functions using the second-order solution. These differ from first-order IRFs because responses depend on the initial state and shock sign.
irf_2nd_order(sol, shock, size = 1, periods = 40L, initial = NULL)irf_2nd_order(sol, shock, size = 1, periods = 40L, initial = NULL)
sol |
A |
shock |
Character. Name of the shock. |
size |
Numeric. Shock size in standard deviations. Default 1. |
periods |
Integer. Number of IRF periods. Default 40. |
initial |
Named numeric vector of initial state deviations. Default is zero (ergodic mean under second-order). |
A data frame with columns: period, variable, response, type.
Computes the impulse-response functions (IRFs) from a fitted or solved DSGE model. An IRF traces the dynamic response of control and state variables to a one-standard-deviation shock.
## S3 method for class 'dsge_bayes' irf( x, periods = 20L, impulse = NULL, response = NULL, se = TRUE, level = 0.95, n_draws = 200L, ... ) irf( x, periods = 20L, impulse = NULL, response = NULL, se = TRUE, level = 0.95, ... )## S3 method for class 'dsge_bayes' irf( x, periods = 20L, impulse = NULL, response = NULL, se = TRUE, level = 0.95, n_draws = 200L, ... ) irf( x, periods = 20L, impulse = NULL, response = NULL, se = TRUE, level = 0.95, ... )
x |
A |
periods |
Integer. Number of periods to compute. Default is 20. |
impulse |
Character vector of shock names. If |
response |
Character vector of variable names. If |
se |
Logical. If |
level |
Confidence level for bands. Default is 0.95. |
n_draws |
Integer. Number of posterior draws to use for IRF
computation. Default is 200. Set to |
... |
Additional arguments passed to methods. |
An object of class "dsge_irf" containing a data frame with
columns: period, impulse, response, value, and optionally
se, lower, upper.
irf(dsge_bayes): Compute posterior IRFs from a Bayesian DSGE fit.
Returns pointwise posterior median and credible bands.
m <- dsge_model( obs(y ~ z), state(z ~ rho * z), start = list(rho = 0.5) ) sol <- solve_dsge(m, params = c(rho = 0.8)) irfs <- irf(sol, periods = 10)m <- dsge_model( obs(y ~ z), state(z ~ rho * z), start = list(rho = 0.5) ) sol <- solve_dsge(m, params = c(rho = 0.8)) irfs <- irf(sol, periods = 10)
Marks a variable as a one-period-ahead model-consistent expectation in a DSGE equation formula. This is the core primitive for forward-looking variables.
lead(x, k = 1L)lead(x, k = 1L)
x |
A variable name (unquoted) within a DSGE equation formula. |
k |
Integer lead horizon. Currently only |
lead(x) in a DSGE equation represents the expectation of variable x
one period ahead, conditional on the model. In the literature, this
corresponds to .
This function is not meant to be called directly. It is recognized by
the equation parser inside dsge_model().
This function is not meant to be called directly; it always
throws an error. It is recognized as a syntactic marker by the
equation parser inside dsge_model().
E() for a user-friendly alias, dsge_model()
Computes a first-order Taylor expansion of the nonlinear model around its deterministic steady state and returns the structural matrices in the canonical linear form.
linearize(model, steady_state, params = NULL)linearize(model, steady_state, params = NULL)
model |
A |
steady_state |
A |
params |
Named numeric vector of parameter values. If |
A list of structural matrices (A0, A1, A2, A3, A4, B0, B1, B2, B3, C, D) plus the steady-state values. A4 captures lead-state coefficients in control equations (often zero).
Estimates the log marginal likelihood using the modified harmonic mean estimator (Geweke, 1999). This provides a practical Bayesian model comparison tool via Bayes factors: BF12 = exp(logML1 - logML2).
marginal_likelihood(object, ...)marginal_likelihood(object, ...)
object |
A |
... |
Additional arguments passed to methods (e.g., |
The harmonic mean estimator is known to be numerically unstable in some cases. The modified version (with truncation parameter tau) reduces this instability. Results should be interpreted with caution and compared across models only when both use similar MCMC settings.
An object of class "dsge_marginal_likelihood".
Comprehensive MCMC diagnostic summary combining ESS, R-hat, Geweke, and acceptance rate information.
mcmc_diagnostics(object, ...)mcmc_diagnostics(object, ...)
object |
A |
... |
Additional arguments passed to |
An object of class "dsge_mcmc_summary".
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.
model_covariance(x, variables = NULL, n_lags = 0L, ...)model_covariance(x, variables = NULL, n_lags = 0L, ...)
x |
A fitted model ( |
variables |
Character vector of variable names to include.
Default |
n_lags |
Integer. If positive, also compute autocovariances at lags 1, ..., n_lags. Default 0 (contemporaneous only). |
... |
Additional arguments (currently unused). |
An object of class "dsge_covariance" containing:
Covariance matrix of selected variables.
Correlation matrix of selected variables.
Standard deviations (square root of diagonal).
List of lagged autocovariance matrices
(empty if n_lags = 0).
Variable names.
Number of autocovariance lags computed.
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)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)
Specifies an inequality constraint for use with simulate_occbin.
obc_constraint(variable, type = ">=", bound = 0, shock = NULL)obc_constraint(variable, type = ">=", bound = 0, shock = NULL)
variable |
Character. Name of the constrained variable (must be a control variable in the model). |
type |
Character. Either |
bound |
Numeric. The constraint bound. For models with steady state, this is in levels; for linear models, in deviations. |
shock |
Character or |
An obc_constraint object.
# Zero lower bound on nominal interest rate obc_constraint("r", ">=", 0) # Upper bound on debt ratio obc_constraint("b", "<=", 0.6)# Zero lower bound on nominal interest rate obc_constraint("r", ">=", 0) # Upper bound on debt ratio obc_constraint("b", "<=", 0.6)
Wraps a formula to mark it as an equation for an observed control variable in a linear DSGE model.
obs(formula)obs(formula)
formula |
A formula of the form |
A list with class "dsge_equation" containing the parsed equation
and its type.
unobs(), state(), dsge_model()
Evaluates the sensitivity of key model outputs to one-at-a-time parameter perturbations. For each free parameter, the model is re-solved at theta +/- delta, and changes in the log-likelihood, impulse responses, steady state, and policy matrix are recorded.
parameter_sensitivity(x, ...) ## S3 method for class 'dsge_fit' parameter_sensitivity( x, what = c("loglik", "irf"), delta = 0.01, irf_horizon = 20L, ... ) ## S3 method for class 'dsge_bayes' parameter_sensitivity( x, what = c("loglik", "irf"), delta = 0.01, irf_horizon = 20L, ... )parameter_sensitivity(x, ...) ## S3 method for class 'dsge_fit' parameter_sensitivity( x, what = c("loglik", "irf"), delta = 0.01, irf_horizon = 20L, ... ) ## S3 method for class 'dsge_bayes' parameter_sensitivity( x, what = c("loglik", "irf"), delta = 0.01, irf_horizon = 20L, ... )
x |
A |
... |
Additional arguments (currently unused). |
what |
Character vector specifying which outputs to assess.
Any subset of |
delta |
Numeric. Perturbation size as a fraction of the parameter value. Default is 0.01 (1 percent). |
irf_horizon |
Integer. Number of IRF periods. Default is 20. |
For each parameter , the model is solved at
and .
The numerical derivative is approximated as a central difference.
Elasticities are reported as ,
representing the percentage change in the output for a 1 percent change
in the parameter.
An object of class "dsge_sensitivity" containing:
Data frame of log-likelihood sensitivities (if requested).
Data frame of IRF sensitivities (if requested).
Data frame of steady-state sensitivities (if requested).
Data frame of policy matrix sensitivities (if requested).
Character vector of parameter names.
Perturbation fraction used.
m <- dsge_model( obs(y ~ z), state(z ~ rho * z), start = list(rho = 0.5) ) set.seed(1) z <- numeric(100); for (i in 2:100) z[i] <- 0.8*z[i-1]+rnorm(1) fit <- estimate(m, data = data.frame(y = z)) sa <- parameter_sensitivity(fit) print(sa)m <- dsge_model( obs(y ~ z), state(z ~ rho * z), start = list(rho = 0.5) ) set.seed(1) z <- numeric(100); for (i in 2:100) z[i] <- 0.8*z[i-1]+rnorm(1) fit <- estimate(m, data = data.frame(y = z)) sa <- parameter_sensitivity(fit) print(sa)
Simulate deterministic transition paths for DSGE models under perfect foresight. Supports temporary shocks, permanent shocks, and initial condition experiments using the linearized solution.
perfect_foresight( x, shocks = NULL, initial = NULL, horizon = 40L, params = NULL, shock_sd = NULL, in_sd = FALSE )perfect_foresight( x, shocks = NULL, initial = NULL, horizon = 40L, params = NULL, shock_sd = NULL, in_sd = FALSE )
x |
A solved DSGE model object. Can be a |
shocks |
Deterministic shock specification. Can be:
Shock values are in units of the shock variable (not standard deviations).
If |
initial |
Named numeric vector of initial state deviations from steady
state. Names must match state variable names. Unspecified states default
to zero. Default is |
horizon |
Integer. Number of periods to simulate. Default 40. |
params |
Named numeric vector of parameters. Required only when
|
shock_sd |
Named numeric vector of shock standard deviations. Used
only when |
in_sd |
Logical. If |
The deterministic transition path is computed using the linearized state-space representation:
where are state deviations from steady state, are
control deviations, and are deterministic shocks.
This uses the first-order linearized solution, so results are approximate for large shocks. For small to moderate shocks, the linearized paths are accurate.
An object of class "dsge_perfect_foresight" containing:
Matrix (horizon x n_states) of state deviations from SS
Matrix (horizon x n_controls) of control deviations
Matrix of state levels (SS + deviation), if SS available
Matrix of control levels, if SS available
Named numeric vector of steady-state values
Matrix (horizon x n_shocks) of applied shocks
Named vector of initial state deviations
Integer horizon
Character vector of state names
Character vector of control names
Character vector of shock names
State transition matrix used
Policy matrix used
Shock impact matrix used
# Simple AR(1) model mod <- dsge_model( obs(p ~ x), state(x ~ rho * x), start = list(rho = 0.9) ) sol <- solve_dsge(mod, params = list(rho = 0.9), shock_sd = c(x = 0.01)) # One-time shock at period 1 pf <- perfect_foresight(sol, shocks = list(x = 0.01), horizon = 40) plot(pf) # Displaced initial condition pf2 <- perfect_foresight(sol, initial = c(x = 0.05), horizon = 40) plot(pf2)# Simple AR(1) model mod <- dsge_model( obs(p ~ x), state(x ~ rho * x), start = list(rho = 0.9) ) sol <- solve_dsge(mod, params = list(rho = 0.9), shock_sd = c(x = 0.01)) # One-time shock at period 1 pf <- perfect_foresight(sol, shocks = list(x = 0.01), horizon = 40) plot(pf) # Displaced initial condition pf2 <- perfect_foresight(sol, initial = c(x = 0.05), horizon = 40) plot(pf2)
Produces diagnostic plots for posterior draws from a Bayesian DSGE fit.
## S3 method for class 'dsge_bayes' plot( x, type = c("trace", "density", "prior_posterior", "running_mean", "acf", "pairs", "all", "irf"), pars = NULL, ... )## S3 method for class 'dsge_bayes' plot( x, type = c("trace", "density", "prior_posterior", "running_mean", "acf", "pairs", "all", "irf"), pars = NULL, ... )
x |
A |
type |
Character. Plot type:
|
pars |
Character vector of parameter names to include. If |
... |
Additional arguments. For |
All plot types except pairs and irf handle any number of parameters
by paginating across multiple plot pages (up to 4 parameters per page).
In interactive sessions, devAskNewPage() is used to prompt between pages.
For the "pairs" plot, at most 1000 draws are used to keep the plot
readable. The correlation matrix is printed to the console.
Forecast plotting is not currently supported for Bayesian fits.
Use irf() for posterior impulse-response analysis.
Invisibly returns the dsge_bayes object x. Called for the
side effect of producing diagnostic plots on the active graphics device.
m <- dsge_model( obs(y ~ z), state(z ~ rho * z), start = list(rho = 0.5) ) set.seed(42) z <- numeric(200); for (i in 2:200) z[i] <- 0.8 * z[i-1] + rnorm(1) fit <- bayes_dsge(m, data = data.frame(y = z), priors = list(rho = prior("beta", shape1 = 2, shape2 = 2)), chains = 2, iter = 2000, seed = 1) plot(fit, type = "trace") plot(fit, type = "density") plot(fit, type = "prior_posterior") plot(fit, type = "running_mean") plot(fit, type = "acf") plot(fit, type = "all") # Parameter selection plot(fit, type = "trace", pars = "rho")m <- dsge_model( obs(y ~ z), state(z ~ rho * z), start = list(rho = 0.5) ) set.seed(42) z <- numeric(200); for (i in 2:200) z[i] <- 0.8 * z[i-1] + rnorm(1) fit <- bayes_dsge(m, data = data.frame(y = z), priors = list(rho = prior("beta", shape1 = 2, shape2 = 2)), chains = 2, iter = 2000, seed = 1) plot(fit, type = "trace") plot(fit, type = "density") plot(fit, type = "prior_posterior") plot(fit, type = "running_mean") plot(fit, type = "acf") plot(fit, type = "all") # Parameter selection plot(fit, type = "trace", pars = "rho")
Creates a stacked bar chart showing the contribution of each structural shock to the observed variables over time.
## S3 method for class 'dsge_decomposition' plot(x, which = NULL, ...)## S3 method for class 'dsge_decomposition' plot(x, which = NULL, ...)
x |
A |
which |
Which observable(s) to plot. Integer or character. Default is all. |
... |
Additional arguments (currently unused). |
No return value, called for the side effect of producing stacked bar charts of the historical shock decomposition on the active graphics device.
Plots forecast paths for observed variables.
## S3 method for class 'dsge_forecast' plot(x, ...)## S3 method for class 'dsge_forecast' plot(x, ...)
x |
A |
... |
Additional arguments passed to base plotting functions. |
No return value, called for the side effect of producing forecast path plots on the active graphics device.
Creates a multi-panel plot of impulse-response functions with optional confidence bands.
## S3 method for class 'dsge_irf' plot(x, impulse = NULL, response = NULL, ci = TRUE, ...)## S3 method for class 'dsge_irf' plot(x, impulse = NULL, response = NULL, ci = TRUE, ...)
x |
A |
impulse |
Character vector of impulse variables to plot.
If |
response |
Character vector of response variables to plot.
If |
ci |
Logical. If |
... |
Additional arguments passed to base plotting functions. |
No return value, called for the side effect of producing a multi-panel impulse-response plot on the active graphics device.
Plot OccBin Simulation Results
## S3 method for class 'dsge_occbin' plot(x, vars = NULL, compare = TRUE, shade = TRUE, max_panels = 9L, ...)## S3 method for class 'dsge_occbin' plot(x, vars = NULL, compare = TRUE, shade = TRUE, max_panels = 9L, ...)
x |
A |
vars |
Character vector of variable names to plot. Default: constrained variables plus a few others. |
compare |
Logical. If |
shade |
Logical. If |
max_panels |
Integer. Maximum panels per page. Default 9. |
... |
Additional arguments (unused). |
No return value, called for the side effect of producing OccBin simulation plots on the active graphics device. Constrained and unconstrained paths are shown, with shaded regions where constraints bind.
Plot the deterministic transition paths from a perfect_foresight
result.
## S3 method for class 'dsge_perfect_foresight' plot(x, vars = NULL, type = "deviation", max_panels = 9L, ...)## S3 method for class 'dsge_perfect_foresight' plot(x, vars = NULL, type = "deviation", max_panels = 9L, ...)
x |
A |
vars |
Character vector of variable names to plot. If |
type |
Character. One of |
max_panels |
Integer. Maximum number of panels per plot page. Default 9. |
... |
Additional arguments (currently unused). |
No return value, called for the side effect of producing transition path plots on the active graphics device.
Plot Smoothed States
## S3 method for class 'dsge_smoothed' plot(x, which = NULL, type = c("states", "fit"), ...)## S3 method for class 'dsge_smoothed' plot(x, which = NULL, type = c("states", "fit"), ...)
x |
A |
which |
Which states to plot. Integer vector, character vector of
state names, or |
type |
Either |
... |
Additional arguments passed to |
No return value, called for the side effect of producing smoothed state or fit plots on the active graphics device.
Returns the policy matrix G from a fitted or solved DSGE model.
The policy matrix maps state variables to control variables:
.
policy_matrix(x, se = TRUE, level = 0.95)policy_matrix(x, se = TRUE, level = 0.95)
x |
A |
se |
Logical. If |
level |
Confidence level for intervals. Default is 0.95. |
If se = FALSE, returns the G matrix. If se = TRUE, returns
a list with matrix, se, lower, upper, and a data frame table.
Simulates data from the posterior predictive distribution and compares summary statistics (variance, autocorrelation) with the observed data. This helps assess whether the estimated model can reproduce key features of the data.
posterior_predictive(object, ...)posterior_predictive(object, ...)
object |
A |
... |
Additional arguments passed to methods (e.g., |
An object of class "dsge_ppc" with posterior predictive
distributions and p-values for each statistic.
Computes one-step-ahead predictions or filtered state estimates from a fitted DSGE model.
## S3 method for class 'dsge_fit' predict( object, type = c("observed", "state"), method = c("onestep", "filter"), newdata = NULL, ... )## S3 method for class 'dsge_fit' predict( object, type = c("observed", "state"), method = c("onestep", "filter"), newdata = NULL, ... )
object |
A |
type |
Character. |
method |
Character. |
newdata |
Optional new data for prediction. If |
... |
Additional arguments (currently unused). |
A matrix of predictions or state estimates.
Computes root mean squared error (RMSE), mean absolute error (MAE), and mean error (bias) of one-step-ahead predictions.
prediction_accuracy(object, ...)prediction_accuracy(object, ...)
object |
A |
... |
Additional arguments (currently unused). |
An object of class "dsge_prediction_accuracy" containing:
Named numeric vector of RMSE by variable.
Named numeric vector of MAE by variable.
Named numeric vector of mean error by variable.
Number of observations.
Variable names.
m <- dsge_model( obs(y ~ z), state(z ~ rho * z), start = list(rho = 0.5) ) set.seed(1) z <- numeric(100); for (i in 2:100) z[i] <- 0.8 * z[i-1] + rnorm(1) fit <- estimate(m, data = data.frame(y = z)) acc <- prediction_accuracy(fit) print(acc)m <- dsge_model( obs(y ~ z), state(z ~ rho * z), start = list(rho = 0.5) ) set.seed(1) z <- numeric(100); for (i in 2:100) z[i] <- 0.8 * z[i-1] + rnorm(1) fit <- estimate(m, data = data.frame(y = z)) acc <- prediction_accuracy(fit) print(acc)
Computes point predictions and prediction intervals using the one-step-ahead innovation variance from the Kalman filter.
prediction_interval(object, level = 0.95, ...)prediction_interval(object, level = 0.95, ...)
object |
A |
level |
Confidence level for prediction intervals (default 0.95). |
... |
Additional arguments passed to |
An object of class "dsge_prediction_interval" with
components fit, lower, upper, se,
level, and variables.
m <- dsge_model( obs(y ~ z), state(z ~ rho * z), start = list(rho = 0.5) ) set.seed(1) z <- numeric(100); for (i in 2:100) z[i] <- 0.8 * z[i-1] + rnorm(1) fit <- estimate(m, data = data.frame(y = z)) pi <- prediction_interval(fit, level = 0.95) print(pi)m <- dsge_model( obs(y ~ z), state(z ~ rho * z), start = list(rho = 0.5) ) set.seed(1) z <- numeric(100); for (i in 2:100) z[i] <- 0.8 * z[i-1] + rnorm(1) fit <- estimate(m, data = data.frame(y = z)) pi <- prediction_interval(fit, level = 0.95) print(pi)
Creates a prior distribution object for use in Bayesian DSGE estimation.
prior(distribution, ...)prior(distribution, ...)
distribution |
Character string specifying the distribution family.
One of |
... |
Distribution parameters (see Details). |
Distribution parameterizations:
mean, sd
shape1, shape2 (alpha, beta parameters)
shape, rate
min, max
shape, scale — density:
An object of class "dsge_prior".
prior("normal", mean = 0, sd = 1) prior("beta", shape1 = 2, shape2 = 2) prior("inv_gamma", shape = 0.01, scale = 0.01)prior("normal", mean = 0, sd = 1) prior("beta", shape1 = 2, shape2 = 2) prior("inv_gamma", shape = 0.01, scale = 0.01)
Computes diagnostics measuring how informative the data was for each parameter, by comparing the posterior distribution to the prior.
prior_posterior_update(x, ...) ## S3 method for class 'dsge_bayes' prior_posterior_update(x, ...)prior_posterior_update(x, ...) ## S3 method for class 'dsge_bayes' prior_posterior_update(x, ...)
x |
A |
... |
Additional arguments (currently unused). |
For each estimated parameter, the following diagnostics are computed:
Ratio of posterior SD to prior SD. Values near 1 indicate the data was uninformative (posterior tracks the prior). Values much less than 1 indicate strong data information.
Absolute difference between posterior mean and prior mean, measured in units of prior SD. Large shifts indicate the data substantially updated beliefs.
Classification: "strong" if sd_ratio < 0.5 or
mean_shift > 2; "moderate" if sd_ratio < 0.8 or mean_shift > 1;
"weak" otherwise (posterior closely resembles the prior).
The SD ratio is the primary indicator of data informativeness. A parameter with sd_ratio close to 1 and small mean_shift is effectively determined by the prior, not the data.
An object of class "dsge_prior_posterior" containing:
Data frame with per-parameter diagnostics including prior mean/sd, posterior mean/sd, SD ratio, mean shift, and update classification.
Character vector of parameter names.
m <- dsge_model( obs(y ~ z), state(z ~ rho * z), start = list(rho = 0.5) ) set.seed(1) z <- numeric(100); for (i in 2:100) z[i] <- 0.8*z[i-1]+rnorm(1) fit <- bayes_dsge(m, data = data.frame(y = z), priors = list(rho = prior("beta", shape1 = 2, shape2 = 2)), chains = 2, iter = 2000, seed = 1) pp <- prior_posterior_update(fit) print(pp)m <- dsge_model( obs(y ~ z), state(z ~ rho * z), start = list(rho = 0.5) ) set.seed(1) z <- numeric(100); for (i in 2:100) z[i] <- 0.8*z[i-1]+rnorm(1) fit <- bayes_dsge(m, data = data.frame(y = z), priors = list(rho = prior("beta", shape1 = 2, shape2 = 2)), chains = 2, iter = 2000, seed = 1) pp <- prior_posterior_update(fit) print(pp)
Returns one-step-ahead prediction errors.
## S3 method for class 'dsge_fit' residuals(object, ...)## S3 method for class 'dsge_fit' residuals(object, ...)
object |
A |
... |
Additional arguments (currently unused). |
A matrix of prediction errors.
Computes the sandwich (Huber-White) variance-covariance matrix for ML-estimated DSGE model parameters. This provides standard errors that are robust to model misspecification.
robust_vcov(object, ...)robust_vcov(object, ...)
object |
A |
... |
Additional arguments passed to methods (e.g., |
The sandwich estimator is: V_robust = inv(H) B inv(H), where H is the Hessian of the negative log-likelihood and B is the outer product of the per-observation score vectors.
An object of class "dsge_robust_vcov" containing:
Robust variance-covariance matrix.
Robust standard errors.
Conventional (Hessian-based) standard errors for comparison.
Parameter names.
m <- dsge_model( obs(y ~ z), state(z ~ rho * z), start = list(rho = 0.5) ) set.seed(1) z <- numeric(100); for (i in 2:100) z[i] <- 0.8 * z[i-1] + rnorm(1) fit <- estimate(m, data = data.frame(y = z)) rv <- robust_vcov(fit) print(rv)m <- dsge_model( obs(y ~ z), state(z ~ rho * z), start = list(rho = 0.5) ) set.seed(1) z <- numeric(100); for (i in 2:100) z[i] <- 0.8 * z[i-1] + rnorm(1) fit <- estimate(m, data = data.frame(y = z)) rv <- robust_vcov(fit) print(rv)
Decomposes the observed variables into the contributions of each structural shock. At each time t, the observed deviation from steady state is written as a sum of contributions from current and past shocks plus the initial condition contribution.
shock_decomposition(x, ...) ## S3 method for class 'dsge_fit' shock_decomposition(x, ...) ## S3 method for class 'dsge_bayes' shock_decomposition(x, ...)shock_decomposition(x, ...) ## S3 method for class 'dsge_fit' shock_decomposition(x, ...) ## S3 method for class 'dsge_bayes' shock_decomposition(x, ...)
x |
A |
... |
Additional arguments (currently unused). |
The state-space solution gives:
The historical decomposition partitions the observed variables
into the contribution of each structural shock
accumulated through the propagation mechanism.
The sum of all contributions (including the initial condition term)
reproduces the smoothed observables exactly.
An object of class "dsge_decomposition" containing:
A 3D array with dimensions
[T, n_obs, n_shocks + 1]. The last slice contains the initial
condition contribution.
Character vector of observed variable names.
Character vector of shock names (plus "initial").
T x n_obs matrix of observed data (deviations).
m <- dsge_model( obs(y ~ z), state(z ~ rho * z), start = list(rho = 0.5) ) set.seed(1) e <- rnorm(100) z <- numeric(100); for (i in 2:100) z[i] <- 0.8*z[i-1]+e[i] fit <- estimate(m, data = data.frame(y = z)) hd <- shock_decomposition(fit) plot(hd)m <- dsge_model( obs(y ~ z), state(z ~ rho * z), start = list(rho = 0.5) ) set.seed(1) e <- rnorm(100) z <- numeric(100); for (i in 2:100) z[i] <- 0.8*z[i-1]+e[i] fit <- estimate(m, data = data.frame(y = z)) hd <- shock_decomposition(fit) plot(hd)
Simulates sample paths using the pruned second-order approximation following Kim, Kim, Schaumburg, and Sims (2008).
simulate_2nd_order(sol, n = 200L, n_burn = 100L, seed = NULL)simulate_2nd_order(sol, n = 200L, n_burn = 100L, seed = NULL)
sol |
A |
n |
Integer. Number of periods to simulate. |
n_burn |
Integer. Burn-in periods to discard. Default 100. |
seed |
Random seed. |
A list with states, controls, state_levels,
control_levels matrices (n x n_vars).
Computes deterministic transition paths under piecewise-linear occasionally binding constraints using an iterative shadow-shock method.
simulate_occbin( x, constraints, shocks = NULL, initial = NULL, horizon = 40L, max_iter = 100L, tol = 1e-08, in_sd = FALSE )simulate_occbin( x, constraints, shocks = NULL, initial = NULL, horizon = 40L, max_iter = 100L, tol = 1e-08, in_sd = FALSE )
x |
A solved DSGE model object ( |
constraints |
A list of constraints. Each element can be:
|
shocks |
Deterministic shock specification (as in
|
initial |
Named numeric vector of initial state deviations from
steady state. Default |
horizon |
Integer. Simulation horizon. Default 40. |
max_iter |
Integer. Maximum OccBin iterations. Default 100. |
tol |
Numeric. Convergence tolerance for shadow shocks. Default 1e-8. |
in_sd |
Logical. If |
The algorithm iteratively:
Simulates the path with current shadow shocks
Identifies periods where constraints are violated
Computes shadow shocks to enforce constraints at binding periods
Removes shadow shocks at non-binding periods
Repeats until the binding regime stabilises
This captures the feedback effect of constraint enforcement on future dynamics through the state transition.
An object of class "dsge_occbin" containing:
Matrix of state deviations (constrained path)
Matrix of control deviations (constrained path)
Matrix of state deviations (unconstrained path)
Matrix of control deviations (unconstrained path)
Logical matrix (horizon x n_constraints) of binding indicators
Matrix of shadow shocks applied
Number of OccBin iterations to convergence
Logical: did the algorithm converge?
List of constraint objects
Steady state values if available
Simulation horizon
State variable names
Control variable names
# Simple NK model with ZLB nk <- 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, kappa = 0.1, psi = 1.5), start = list(rhou = 0.5, rhog = 0.5) ) sol <- solve_dsge(nk, params = list(rhou = 0.5, rhog = 0.5), shock_sd = c(u = 0.5, g = 0.5)) obc <- simulate_occbin(sol, constraints = list("r >= 0"), shocks = list(g = -0.05), horizon = 40) plot(obc)# Simple NK model with ZLB nk <- 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, kappa = 0.1, psi = 1.5), start = list(rhou = 0.5, rhog = 0.5) ) sol <- solve_dsge(nk, params = list(rhou = 0.5, rhog = 0.5), shock_sd = c(u = 0.5, g = 0.5)) obc <- simulate_occbin(sol, constraints = list("r >= 0"), shocks = list(g = -0.05), horizon = 40) plot(obc)
Recovers the structural shocks from the smoothed states using the state
transition equation:
where is the Moore-Penrose pseudo-inverse of M.
smooth_shocks(x, ...) ## S3 method for class 'dsge_fit' smooth_shocks(x, ...) ## S3 method for class 'dsge_bayes' smooth_shocks(x, ...)smooth_shocks(x, ...) ## S3 method for class 'dsge_fit' smooth_shocks(x, ...) ## S3 method for class 'dsge_bayes' smooth_shocks(x, ...)
x |
A |
... |
Additional arguments (currently unused). |
From the state transition ,
the smoothed innovation is . The structural
shocks are recovered by projecting onto M:
.
An object of class "dsge_smoothed_shocks" containing:
(T-1) x n_shocks matrix of smoothed structural shocks.
Character vector of shock names.
Computes the Rauch-Tung-Striebel (RTS) smoother to produce optimal state estimates using all available observations. Compared to the filtered states (which only use past data), smoothed states also incorporate future observations.
smooth_states(x, ...) ## S3 method for class 'dsge_fit' smooth_states(x, ...) ## S3 method for class 'dsge_bayes' smooth_states(x, ...)smooth_states(x, ...) ## S3 method for class 'dsge_fit' smooth_states(x, ...) ## S3 method for class 'dsge_bayes' smooth_states(x, ...)
x |
A |
... |
Additional arguments (currently unused). |
The smoother uses the state-space representation:
where . The smoothed states are the expectation of the
state vector conditional on all observations: .
For Bayesian models, the smoother is evaluated at the posterior mean.
An object of class "dsge_smoothed" containing:
T x n_s matrix of smoothed state estimates.
T x n_s matrix of filtered state estimates.
T x n_obs matrix of smoothed observable fits.
T x n_obs matrix of observation residuals.
Character vector of state variable names.
Character vector of observed variable names.
Steady-state values (if available).
m <- dsge_model( obs(y ~ z), state(z ~ rho * z), start = list(rho = 0.5) ) set.seed(1) e <- rnorm(100) z <- numeric(100); for (i in 2:100) z[i] <- 0.8 * z[i-1] + e[i] fit <- estimate(m, data = data.frame(y = z)) sm <- smooth_states(fit)m <- dsge_model( obs(y ~ z), state(z ~ rho * z), start = list(rho = 0.5) ) set.seed(1) e <- rnorm(100) z <- numeric(100); for (i in 2:100) z[i] <- 0.8 * z[i-1] + e[i] fit <- estimate(m, data = data.frame(y = z)) sm <- smooth_states(fit)
Computes the state-space solution of a DSGE model using the
Klein (2000) method. Accepts both linear models (dsge_model) and
nonlinear models (dsgenl_model). For nonlinear models, the steady
state is computed and the model is linearized automatically.
solve_dsge(model, params = NULL, shock_sd = NULL, tol = 1e-06, order = 1L)solve_dsge(model, params = NULL, shock_sd = NULL, tol = 1e-06, order = 1L)
model |
A |
params |
Named numeric vector of parameter values. If |
shock_sd |
Named numeric vector of shock standard deviations.
If |
tol |
Tolerance for classifying eigenvalues as stable (|lambda| < 1 + tol). Default is 1e-6. |
order |
Integer. Approximation order: 1 (default) for first-order,
2 for second-order perturbation. Second-order is only available for
nonlinear models ( |
The method forms a companion system from the structural matrices and solves via undetermined coefficients iteration. Saddle-path stability requires that all eigenvalues of H have modulus less than 1.
For nonlinear models, the solver first computes the deterministic steady state, then linearizes the model via first-order Taylor expansion, and finally solves the resulting linear system.
An object of class "dsge_solution" containing:
Policy matrix (n_controls x n_states).
State transition matrix (n_states x n_states).
Shock coefficient matrix (n_states x n_shocks).
Observation selection matrix.
Complex vector of eigenvalues.
Logical: is the system saddle-path stable?
Number of stable eigenvalues.
The parameter values used.
Reference to the model object.
Checks saddle-path stability of the model by examining eigenvalues. A model is stable when the number of eigenvalues with modulus less than 1 equals the number of state variables.
stability(x)stability(x)
x |
A |
A list of class "dsge_stability" with:
Logical: is the system saddle-path stable?
Complex eigenvalue vector.
Moduli of eigenvalues.
Character vector: "stable" or "unstable" for each.
Number of stable eigenvalues.
Number of state variables (required stable count).
Wraps a formula to mark it as an equation for a state variable in a linear DSGE model. State equations describe the evolution of state variables one period ahead.
state(formula, shock = TRUE)state(formula, shock = TRUE)
formula |
A formula of the form |
shock |
Logical. If |
A list with class "dsge_equation" containing the parsed equation
and its type.
Finds the steady-state values of all model variables by solving the system of nonlinear equations with all leads set equal to current values.
steady_state(model, ...) ## S3 method for class 'dsgenl_model' steady_state( model, params = NULL, guess = NULL, maxiter = 200L, tol = 1e-10, ... )steady_state(model, ...) ## S3 method for class 'dsgenl_model' steady_state( model, params = NULL, guess = NULL, maxiter = 200L, tol = 1e-10, ... )
model |
A |
... |
Additional arguments (currently unused). |
params |
Named numeric vector of parameter values. If |
guess |
Named numeric vector of initial guesses for variable values.
Overrides the model's |
maxiter |
Maximum Newton-Raphson iterations. Default is 200. |
tol |
Convergence tolerance. Default is 1e-10. |
An object of class "dsgenl_steady_state" with:
Named numeric vector of steady-state values.
Equation residuals at the solution.
Parameter values used.
Logical: did the solver converge?
Number of iterations used.
Summary of Perfect Foresight Transition
## S3 method for class 'dsge_perfect_foresight' summary(object, ...)## S3 method for class 'dsge_perfect_foresight' summary(object, ...)
object |
A |
... |
Additional arguments (unused). |
Invisibly returns the dsge_perfect_foresight object. Called
for the side effect of printing impact effects, peak deviations,
and convergence diagnostics to the console.
Returns the transition matrix H from a fitted or solved DSGE model.
The transition matrix describes state evolution:
.
transition_matrix(x, se = TRUE, level = 0.95)transition_matrix(x, se = TRUE, level = 0.95)
x |
A |
se |
Logical. If |
level |
Confidence level for intervals. Default is 0.95. |
Same structure as policy_matrix().
Wraps a formula to mark it as an equation for an unobserved control variable in a linear DSGE model.
unobs(formula)unobs(formula)
formula |
A formula of the form |
A list with class "dsge_equation" containing the parsed equation
and its type.
When type = "robust" is passed to vcov(), returns the
sandwich variance-covariance matrix.
## S3 method for class 'dsge_fit' vcov(object, type = c("conventional", "robust"), ...)## S3 method for class 'dsge_fit' vcov(object, type = c("conventional", "robust"), ...)
object |
A |
type |
Character. |
... |
Passed to |
Variance-covariance matrix.