dsgenl_model: Define a Nonlinear DSGE Model

View source: R/dsgenl-model.R

dsgenl_modelR Documentation

Define a Nonlinear DSGE Model

Description

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).

Usage

dsgenl_model(
  ...,
  observed = character(0),
  unobserved = character(0),
  exo_state,
  endo_state = character(0),
  fixed = list(),
  start = list(),
  ss_guess = NULL,
  ss_function = NULL
)

Arguments

...

Character strings, each defining one model equation. Use VAR(+1) to denote the one-period-ahead value of variable VAR.

observed

Character vector of observed control variable names.

unobserved

Character vector of unobserved control variable names. Default is character(0).

exo_state

Character vector of exogenous state variable names. These have shocks attached. There must be at least as many exogenous states as observed controls (more observables than shocks would make the likelihood singular).

endo_state

Character vector of endogenous (predetermined) state variable names. These have no shocks. Default is character(0).

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 NULL, defaults to 1 for all variables.

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.

Details

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).

Value

An object of class "dsgenl_model".

Examples

# 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)
)


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