How to keep an endogenous variable at constant value

Hi, I have two problems while trying to replicate the baseline model in Sami Alpanda and Serdar Kabaca (2020) which studies the spillovers of FED’s QE policy. The problems may sound easy but I can’t find solutions from Dynare handbook and search engines.

The first is how to keep an endogenous variable at certain constant value for some periods. In this case short-term policy rate(R) is constrained to zero in the beginning 4 periods to resemble ZLB during QE after 2008. The code provided by authors didn’t cover this setting. I tried to define a new shock, like


var test ; periods 1:4, 5:40 ;values 0,1;


And I multiply test with R in Taylor rule. However the results show R remains at 0 for all 40 periods. I’m wondering why and R remains at 0 even when test is set to 1 for all 40 periods.

The second is the code use model (linear); command to begin their equations which means we don’t have to calculate the steady state. Is there anywhere or by any command I can get the steady state value of the variables? Because I want to set shocks at defined size, like a bond supply shock with the size of 4% amount of GDP to bond holdings on market.

Thanks so much in advance!

  1. I would need to see the file, but model(linear) is incorrect as the multiplication with test is clearly nonlinear.
  2. If the model is linearized, you cannot back out the levels from Dynare. You would need to compute them your self (unless they already enter as parameters)

The code provided publicly by authors is for estimation which can’t produce the exact IRFs in the paper. I removed the parameter estimation part and set the parameters the same value as the calibration and estimation results in the paper. Next I tried two modifications. The first is the shocks in code are all set like var eps_b; stderr 0;. So I changed the bond supply shock eps_b in the shocks; to a determined shock to describe the shock is the size of 21% amount of steady state value of bond supply. You can find in line 251. The second is multiply R with test_shock. You can find in line 250, 350, 434. Finally I use simul(periods=40); and rplot to replace stoch_simul to get IRFs. The IRFs my code yields have basic resemblance of IRFs from the paper but still have some problems like ①short-term policy rate(R) stays at 0. ②real exchange rate(rer) going to exactly opposite direction. ③inflation(pic) and long-term rate(RL) look good but low in magnitude, and R has the same problem as pic and RL if I don’t multiply R with test_shock.
1.mod is my version after modification and the zip is downloaded from paper’s website which contains the original code.
Thank you so much Prof. Pfeifer1.mod|attachment (21.5 KB) (944.6 KB)

looks like 1.mod failed uploading. I try again1.mod (21.5 KB)

And for your reply2. Does command model(linear) skip the computation of steady state values? So you can only use stoch_simul rather than simul?

According to the manual:

Declares the model as being linear. It spares oneself from having to declare initial values
for computing the steady state of a stationary linear model. This option can’t be used with
non-linear models, it will NOT trigger linearization of the model.

AFAIK, Dynare will skip the computation of the steady state and assume a zero steady state for all variables if you specify the linear option, e.g. model(linear);

Thank you, Max. I think you are right about linear options assuming a zero steady state for all variables. The original code use standard deviation(var eps_b; stderr 0.01;) as shock and can yield IRFs, but is it possible to set a shock with determined size(e.g. 10% deviation of a variable’s steady state value) since steady state for all variables are zero? And also, is it possible to constrain an endogenous variable at certain value for certain periods with model declared being linear?

  1. Yes, setting a pre-specified percentage change of a variable is straightforward. By the way, you are confusing the steady state of the variable in the linearized model, which is in percentage deviations from steady state and the steady state of the original level variable. A linearized model allows to directly specify deviations from steady state.
  2. How do you want to


Thank you Prof. Pfeifer.

  1. So Max1 and I are wrong about linearized model assuming a zero steady state for all variables. If steady state of the variable in the linearized model is percentage deviations from steady state, so the steady states for original model and linearized model are totally different from each other? And if I want to set a e.g. 10% shock on bond supply, it is in fact 10% of the deviation from original steady state, or 10% of steady state in linearized model, but not 10% of steady state of original level?

And I was attempting use periods and values command e.g. var eps; periods 1:4, 5:8, 9:40; values -0.25, 0.25, 0; to set a pre-specified shock. My question is 0.25 the real value of the shock or 0.25% of steady state in linearized model?

  1. As I said in very beginning, I basically add some code in order to multiply R(policy rate, endogenous variable) with a newly-set variable test whose value is 0 in first periods and 1 in rest periods to try to set constraints on R. And I’ve uploaded in earlier post. And you said it is wrong. Is it because I only changed the deviation of R to 0, not real value to 0? And do you have any suggestions on achieving this?

Thanks again!