EC9D5 · Working with Dynare · Part 1
Interpreting Dynamic Variables in Log-Linear Macroeconomic Models
On this course, every variable in a Dynare model is a logarithm and every shock is measured in percent. A number in Dynare’s output can then be a log level, a deviation in percent, or, for an interest rate, a change in percentage points. This page explains what each object measures, how to move between levels, logs and percentages, and how to read Dynare’s steady state and impulse responses correctly.
1. Levels and Logs
Let \(Y_t^{\text{level}}\) denote output in period \(t\), measured in its natural units. Its (natural) logarithm, written with a lower-case letter, is
The logarithm turns a positive level into a log variable; the exponential reverses it. Throughout, \(\log\) is the natural logarithm, the same as log in Dynare and MATLAB. The same convention applies to every other variable: \(c_t\) is log consumption, \(i_t\) log investment, \(k_t\) log capital, and so on.
If output is 100, the model variable is
Conversely, if the model gives \(y_t=4.605\), output in levels is \(\exp(4.605)\approx 100\).
2. The Steady State in Levels and Logs
The same distinction applies to the steady state. If \(\bar Y^{\text{level}}\) is steady-state output, its logarithm is
If steady-state output is 100, then \(\bar Y^{\text{level}}=100\) and \(\bar y=\log(100)\approx4.605\). When a variable is written in logs in the model, its steady state is in logs too. The two representations carry the same information, but they must not be mixed.
In Dynare the steady state of y appears in two places, and both are log values:
- inside the
modelblock, the operatorSTEADY_STATE(y)stands for \(\bar y\); - after
steady;orstoch_simulhas run, the values are stored inoo_.steady_state, in the order of the variable names inM_.endo_names.
ybar = oo_.steady_state(strcmp(M_.endo_names, 'y')); % steady-state log output
Ybar = exp(ybar); % steady-state output in levels
The steady state is best written in closed form in a steady_state_model block, so that Dynare recomputes it exactly for every parameter draw during estimation. Compute it in levels with temporary variables (ending in _), then take logs:
steady_state_model;
// levels first (temporary variables end in _) ...
k_ = ...;
h_ = ...;
y_ = k_^alpha*h_^(1-alpha);
// ... then the model variables, in logs
k = log(k_);
h = log(h_);
y = log(y_);
A = 0;
end;
3. Three Ways to Measure a Deviation
Once the variable and its steady state are defined, we can measure how far the variable is from its steady state. There are three common measures. They answer the same question in different units, so the numbers differ. As a running example, output rises from its steady state of 100 to 102.
3.1. Deviation in levels
This is an absolute difference, in the units of the variable itself (a unit deviation). In the example, \(102-100=2\): output is 2 units above its steady state.
3.2. Log deviation
The log deviation is the difference between the log of the variable and the log of its steady state. Because the difference of two logs is the log of a ratio,
It therefore measures the relative difference between the variable and its steady state. In the example, \(\log(102)-\log(100)=\log(1.02)\approx0.0198\). This is not 0.0198 units of output: it is a difference between two logarithms, a pure number with no units.
3.3. Percentage deviation
In the example, \(100\times(102-100)/100=2\%\): output is 2% above its steady state. The percentage deviation can be computed from the log deviation alone. Taking the exponential of the log deviation gives the ratio \(Y_t^{\text{level}}/\bar Y^{\text{level}}=\exp(y_t-\bar y)\), so
3.4. The three measures side by side
| Measure | Formula | Units | Output 100 → 102 |
|---|---|---|---|
| Deviation in levels | \(Y_t^{\text{level}}-\bar Y^{\text{level}}\) | Units of the variable | 2 units |
| Log deviation | \(y_t-\bar y=\log(Y_t^{\text{level}}/\bar Y^{\text{level}})\) | Difference in logs (decimal) | 0.0198 |
| Percentage deviation | \(100\left[\exp(y_t-\bar y)-1\right]\) | Per cent | 2% |
4. Log Deviations and Percentages
For small deviations, the log deviation is approximately the percentage deviation written as a decimal. The reason is the first-order approximation \(\exp(x)\approx1+x\) for small \(x\). Applied to the exact formula of section 3.3,
This is why a log deviation of 0.01 is read as “about 1% above the steady state”. It is an approximation, and its accuracy depends on the size of the deviation:
| Log deviation \(x\) | Approximation \(100x\) | Exact \(100(e^{x}-1)\) | Error (points) |
|---|---|---|---|
| 0.01 | 1% | 1.005% | 0.005 |
| 0.0198 | 1.98% | 2.000% | 0.02 |
| 0.05 | 5% | 5.127% | 0.13 |
| 0.10 | 10% | 10.517% | 0.52 |
| 0.20 | 20% | 22.140% | 2.14 |
| −0.10 | −10% | −9.516% | 0.48 |
| −0.20 | −20% | −18.127% | 1.87 |
For business-cycle movements of a few per cent, the approximation is very close (the highlighted row is the running example). For large movements it is not: \(100x\) understates rises and overstates falls, and the error grows with the size of the deviation. A log deviation of 0.20 is a rise of about 22%, not 20%.
Log deviations are symmetric and add up over time. If output rises from 100 to 102 and then falls back to 100, the two log changes are \(+0.0198\) and \(-0.0198\), which sum to zero. In percentages the same path is \(+2\%\) and then \(-1.96\%\). Logs also turn products into sums, so a Cobb–Douglas production function becomes linear in logs (section 6).
5. Reading Dynare’s Output
5.1. Shocks in percent, deviations in percent
On this course, shock standard deviations are set in percent: stderr 0.89 means a 0.89% shock, not 0.0089. With a first-order approximation (stoch_simul(order = 1)), the solution is linear in the shocks, so scaling every shock by 100 scales every deviation from the steady state by 100. Dynare’s deviations of a log variable are then 100 times log deviations, that is, percentage deviations in the sense of section 4.
The response of y to the shock eps_A is stored in oo_.irfs.y_eps_A, as a deviation from the steady state. A value of 0.5 means output is about 0.5% above its steady state: no multiplication by 100 is needed. The same holds for simulated series minus their steady state, and for the moments Dynare reports.
order = 1. The rescaling works because the first-order solution is linear. At order = 2 or higher, the size of the shocks changes the solution itself (through risk terms such as the variance), so shocks must then be in log units.stderr 0.0089). Their impulse responses are then log deviations (0.005 for a 0.5% deviation), and must be multiplied by 100 before they are read as percentages. At order = 1 the two set-ups give the same economics; only the units differ.5.2. Interest rates and inflation
All endogenous variables are in logs, including gross rates: \(r_t=\log(1+R_t)\) for a net rate \(R_t\). Because \(\log(1+R_t)-\log(1+\bar R)\approx R_t-\bar R\), the deviation of a log gross rate is the change in the net rate itself. With shocks in percent it is read in percentage points per period, never as a percentage change of the rate.
In a quarterly model, the impulse response of the log gross interest rate is 0.25 on impact. The interest rate is 0.25 percentage points higher per quarter, or about \(4\times0.25=1\) percentage point higher at an annual rate. It is not 0.25% higher than its steady-state value.
5.3. Moments comparable with the data
The data on this course are HP-filtered cyclical components, in percent. Asking Dynare to HP-filter the model’s theoretical moments with the same smoothing parameter makes the two directly comparable:
stoch_simul(order = 1, irf = 40, hp_filter = 1600) y c inv h k A;
Impulse responses and standard deviations are then in percent, like the data: a standard deviation of 1.5 for y means output fluctuates by about 1.5% around its trend.
6. Writing the Model in Dynare
Every endogenous variable is declared in logs, and every equation is written in levels using exp(). The equations then read like the model in the notes, and Dynare’s first-order approximation is automatically in log deviations. Exogenous processes are log AR(1) processes, written directly in logs.
// ---------------------------------------------------------
// Variables
// ---------------------------------------------------------
var y // log output
k // log capital (end of period: k = log K_{t+1})
h // log hours
A; // log total factor productivity
varexo eps_A; // TFP shock, in percent
parameters alpha rhoA;
// ---------------------------------------------------------
// Model
// ---------------------------------------------------------
model;
// Production
exp(y) = exp(A)*exp(k(-1))^alpha*exp(h)^(1-alpha);
// TFP: log AR(1)
A = rhoA*A(-1) + eps_A;
// ... other equations
end;
// ---------------------------------------------------------
// Shocks (standard deviations in percent)
// ---------------------------------------------------------
shocks;
var eps_A; stderr 0.89; // a 0.89% TFP shock
end;
Capital follows Dynare’s end-of-period convention: k is \(\log K_{t+1}\), chosen in period \(t\), so production uses k(-1). With these conventions, each expression measures:
| Expression | What it measures |
|---|---|
y | Log output, \(y_t\) |
exp(y) | Output in levels, in the model equations |
STEADY_STATE(y) | Steady-state log output, \(\bar y\) |
exp(STEADY_STATE(y)) | Steady-state output in levels, \(\bar Y^{\text{level}}\) |
y - STEADY_STATE(y) | Deviation from the steady state: in percent at order = 1 with shocks in percent |
y - y(-1) | Growth of output from \(t-1\) to \(t\), in percent |
100* in front of y - STEADY_STATE(y): with shocks in percent, the deviation is already in percent, and the factor would put it in hundredths of a percent.6.1. Exact numbers after solving
Dynare’s percent deviations are 100 times log deviations, so the rule of thumb of section 4 applies. For large responses, or to report results in levels, convert them after the model has been solved. Do not write these conversions inside the model block: at order = 1, Dynare linearises every equation, so an “exact” formula there gives the same numbers as the approximate one.
ybar = oo_.steady_state(strcmp(M_.endo_names, 'y')); % steady-state log output
y_pct = oo_.irfs.y_eps_A; % deviation in percent (what Dynare reports)
y_pct_exact = 100*(exp(y_pct/100) - 1); % exact percentage deviation
y_level_dev = exp(ybar)*(exp(y_pct/100) - 1); % deviation in levels (units of output)
7. Rules to Remember
Whenever a model variable is the logarithm of a level, \(y_t=\log(Y_t^{\text{level}})\), distinguish the model variable from the economic quantity it represents, and know the units of the shocks.
yis log output;exp(y)is output in levels. Write the equations in levels withexp().STEADY_STATE(y)and the value inoo_.steady_stateare steady-state log output; their exponential is steady-state output in levels.- Shock standard deviations are in percent (
stderr 0.89for a 0.89% shock). Atorder = 1, every deviation, impulse response and moment is then in percent. - The deviation of a log gross rate is a change in the rate in percentage points per period; multiply by 4 to annualise a quarterly rate.
- The percent rescaling is valid only at
order = 1; at higher orders, shocks must be in log units. - Compute exact transformations after solving the model, not inside the model block.