# 8. Examples

Dynare comes with a database of example `.mod` files, which are designed to show a broad range of Dynare features, and are taken from academic papers for most of them. They are distributed in the `examples` subdirectory.

Here is a short list of the examples included. For a more complete description, please refer to the comments inside the files themselves.

## 8.1. Stochastic simulations

`stochastic_simulations/collard_2001_theoretical_moments.mod` `stochastic_simulations/collard_2001_simulated_moments.mod`

> Two examples of a small RBC model in a stochastic setup, presented in Collard (2001) (see the file `guide.pdf` which comes with Dynare), both using `stoch_simul`. Both use numerical steady state computation. The first one uses theoretical moments, the second one uses simulated moments.

`stochastic_simulations/collard_2001_analytical_steady_state.mod`

> A small RBC model in a stochastic setup, presented in Collard (2001) using `stoch_simul`. The steady state is solved analytically using the `steady_state_model` block and a helper function to call a solver.

`stochastic_simulations/schorfheide_2000_nonstationary.mod`

> The cash-in-advance model of Schorfheide (2000) (same as `estimation/schorfheide_2000.mod`) written in non-stationary form. Detrending of the equations is done by Dynare.

`stochastic_simulations/aguiar_gopinath_2007_trend.mod`

> Small open economy RBC model with shocks to the growth trend, presented in Aguiar and Gopinath (2007).

`stochastic_simulations/nk_baseline.mod`

> Baseline New Keynesian Model estimated in Fernández-Villaverde (2010). It demonstrates how to use an explicit steady state file to update parameters and call a numerical solver.

## 8.2. Estimation

`estimation/schorfheide_2000.mod`

> A cash-in-advance model, estimated by Schorfheide (2000). The file shows how to use the `estimation` command.

`estimation/gali_2015.mod`

> Basic New Keynesian model of Galí (2015), Chapter 3 showing how to i) use “system prior”-type prior restrictions as in Andrle and Plašil (2018) and ii) run prior/posterior-functions.

`estimation/rbc_irf_matching.mod`

> Baseline RBC model with government spending shocks estimated via impulse response function (IRF) matching using `method_of_moments`. Both Frequentist (Maximum Likelihood) and Bayesian (Slice Sampling) approaches are presented. Additionally, it is shown how to estimate an AR(2)-process by working with the roots of the autoregressive process instead of the coefficients.

## 8.3. Perfect foresight

`perfect_foresight/perfect_foresight_rbc.mod`

> An elementary real business cycle (RBC) model, simulated in a perfect foresight setup using `perfect_foresight_setup` and `perfect_foresight_solver`.

`perfect_foresight/perfect_foresight_expectation_errors.mod`

> Elementary RBC model (same as `perfect_foresight/perfect_foresight_rbc.mod`), simulated in perfect foresight with expectation errors using `perfect_foresight_with_expectation_errors_setup` and `perfect_foresight_with_expectation_errors_solver`: agents behave as under perfect foresight, but they can still be surprised by unexpected shocks, and thus recompute their optimal plans when such an unexpected shock happens.

## 8.4. Optimal policy

`optimal_policy/nk_ramsey_osr.mod`

> File demonstrating how to conduct optimal policy experiments in a simple New Keynesian model either under commitment (`ramsey_model`) or using optimal simple rules (`osr`). Based on Christiano et al. (2007).

`optimal_policy/nk_ramsey_steady_file.mod`

> File demonstrating how to conduct optimal policy experiments in a simple New Keynesian model under commitment (`ramsey_model`) with a user-defined conditional steady state file. Based on Christiano et al. (2007).

## 8.5. Heterogeneity

`heterogeneity/krusell_smith_1998.mod`

> Krusell and Smith (1998) model with heterogeneous households. Demonstrates loading a pre-computed steady state via `heterogeneity_load_steady_state`, solving the model with `heterogeneity_solve`, and computing impulse response functions.

`heterogeneity/krusell_smith_1998_steady_state.mod`

> Krusell and Smith (1998) model with heterogeneous households. Demonstrates computing the steady state numerically using `heterogeneity_compute_steady_state`.

`heterogeneity/hank_one_asset.mod`

> One-asset HANK model. Demonstrates loading a pre-computed steady state via `heterogeneity_load_steady_state`, solving with `heterogeneity_solve`, and running stochastic simulations with `heterogeneity_simulate`.

`heterogeneity/hank_one_asset_steady_state.mod`

> One-asset HANK model. Demonstrates computing the steady state with parameter calibration using `heterogeneity_compute_steady_state`.

`heterogeneity/hank_two_assets.mod`

> Two-asset HANK model with liquid and illiquid assets. Demonstrates loading a pre-computed steady state via `heterogeneity_load_steady_state` and simulating news shocks.

`heterogeneity/hank_two_assets_steady_state.mod`

> Two-asset HANK model. Demonstrates computing the steady state with multi-parameter calibration using `heterogeneity_compute_steady_state`.

## 8.6. OccBin

`occbin/rbc_occbin.mod`

> RBC model with two occasionally binding constraints. Demonstrates how to set up OccBin using `occbin_setup` and `occbin_solver`. Based on Guerrieri and Iacoviello (2015).

## 8.7. Macroprocessor

`macroprocessor/bkk_1992.mod`

> Multi-country RBC model with time to build, presented in Backus et al. (1992). The file shows how to use Dynare’s macro processor.

## 8.8. Reporting

`reporting/collard_2001_reporting.mod`

> Example of Dynare’s reporting features using the Collard (2001) RBC model.

## 8.9. Semistructural

`semistructural/pac_model.mod`

> Example of a semi-structural model employing PAC (polynomial adjustment cost) specification.