RBC Baseline Model in Dynare: Deterministic vs Stochastic Simulations
Channel: Willi Mutschler
Date: 2021-06-08

This video is part of a series of videos on the baseline Real Business Cycle model and its implementation in Dynare. In this video I focus on simulations and discuss the difference between the deterministic and stochastic model framework of Dynare. I provide intuition how Dynare "solves" or "simulates" these different model frameworks and guidance on when to run either deterministic or stochastic simulations. Then I show how to simulate various scenarios in the baseline RBC model. 

In the **deterministic** case (i.e. under perfect foresight), this videos covers
- unexpected or pre-announced temporary shocks
- unexpected or pre-announced permanent shocks
- return to equilibrium
by using Dynare's `perfect_foresight_setup` and `perfect_foresight_solver` (i.e. the old `simul`) commands and the `shocks`, `initval`, `endval` and `histval` blocks. I show what happens in MATLAB's workspace and to Dynare's output structure `oo_`.

In the **stochastic** case, this videos covers
- impulse-response-functions (irf)
- variance decompositions
- theoretical vs. simulated moments
- data simulation
by using Dynare's `stoch_simul` command and the `shocks` block. I show what happens in MATLAB's workspace and to Dynare's output structures `oo_` and `oo_.dr`. Lastly, the difference between Dynare's *declaration* and *DR* (decision-rule) ordering of variables is covered.

Slides, notes and codes: https://mutschler.eu/dynare/intro-dsge-dynare/rbc_video_simulation/

**Timestamps**

*Theory*
01:06 - Deterministic vs. stochastic model framework
08:01 - When to use which framework?

*Deterministic Simulation in Dynare*
11:47 - Overview of Dynare commands for deterministic simulations
13:58 - Getting ready in Dynare
15:00 - Scenario 1: Unexpected temporary TFP shock
15:25 - What does `perfect_foresight_setup do?
17:39 - What does `perfect_foresight_solver` do?
19:12 - What happens in MATLAB's workspace?
19:54 - What happens in Dynare's output structure `oo_`?
21:43 - `Simulated_time_series` is a *dseries* object
22:51 - Scenario 2: Sequence of temporary pre-announced shocks
24:56 - Why `simul` is a depreciated syntax; better use `perfect_foresight_setup` and `perfect_foresight_solver`!
26:20 - `dsample` command
27:14 - Scenario 3: Unexpected permanent shock
28:47 - Values of 0 can cause errors as log(0) is inf; double check your `initval` and `endval` blocks!
30:45 - Don't forget to adjust steady-state computations to be dependent on value of exogenous variables (if they are different than 0)
32:27 - Scenario 4: Pre-announced permanent shock
34:07 - Scenario 5: Return to Equilibrium

*Stochastic Simulation in Dynare*
36:26 - Overview of Dynare commands for stochastic simulations
38:28 - Impulse-Response-Function (IRF) of TFP shock
39:39 - Adding a preference shock to the model
41:38 - Impulse-Response-Function (IRF) of preference shock
42:08 - What happens in MATLAB's console?
42:35 - Theoretical moments with `periods=0` option
43:06 - What happens in Dynare's `oo_` structure 
43:51 - What happens in Dynare's `oo_.dr` structure
44:53 - Difference between declaration and DR (decision rule) order
46:07 - Simulate data and simulated moments with `periods` option

*Outro & References*
47:01 - Outro
47:52 - References

**Hints & Corrections**
- Don't save you mod files on cloud storage or network drives

Checkout https://mutschler.eu/dynare for more stuff on DSGE models and Dynare.