The model I am using includes a variable (1) that is the expected discounted sum of another endogenous variable (2). When using the instruction ‘forecast’ with the second order approximation, the forecasted path of variable (1) increases, while variable (2) at time 1 decreases. This seems odd since variable (2) is just the expected discounted sum of (1), written as a difference equation.
The forecast with the first order approximation delivers instead the expected result (it is easy to check analitycally). Is there something conceptually different in computing forecast with the second order approximation? Has the loop in simultxdet.m been tested for the sceond order forecast?

Also, when using forecast with second order, I have to set the ‘periods’ option in forecast at a value quite larger than the number of periods for which I supply values for the exogenous deterministic shock, else the forecast is computed ignoring a portion of the supplied values.

Regarding the loop for second order forecast, after consultation with Michel and Ondra, we found out that in simultexdet.m the following line (probably #82 in code):

for j=1:min(iter+ykmin_-i-M_.ex_det_length+1,M_.ex_det_length)

should be changed to:
for j=1:min(ykmin_-i+M_.ex_det_length+1,M_.ex_det_length)

The corrected code is in attachment. Does it solve your problem? simultxdet.m (4.19 KB)

a) the main problem still is unaffected, I obtain exactly the same numbers as with the earlier code. {which makes me think there is something amiss, since the loop in simultxdet.m is clearly changed}:

“” The model I am using includes a variable (1) that is the expected discounted sum of another endogenous variable (2). When using the instruction ‘forecast’ with the second order approximation, the forecasted path of variable (1) increases, while variable (2) at time 1 decreases. This seems odd since variable (2) is just the expected discounted sum of (1), written as a difference equation.
The forecast with the first order approximation delivers instead the expected result (it is easy to check analitycally). Is there something conceptually different in computing forecast with the second order approximation? Has the loop in simultxdet.m been tested for the sceond order forecast? “”

any other idea? I am still very puzzled.

b) The new simultxdet.m does solve this second issue I mentioned:

“” Also, when using forecast with second order, I have to set the ‘periods’ option in forecast at a value quite larger than the number of periods for which I supply values for the exogenous deterministic shock, else the forecast is computed ignoring a portion of the supplied values. “”

Note that in a forecast based on 2nd order approximation, the forecast doesn’t converge back to the deterministic steady state because of the shift effect from taking into account future volatility.

I include a modification of the Dynare sample RBC model where a deterministic productivity shock ‘ebs’ has been added, a variable ‘ut’ describes the value of the istantaneous utility, a variable ‘v’ describes the expected discounted sum of instantaneous utility.

What happens using FORECAST with two sample paths for deterministic productivity shock, one of 50 periods and one of 100 periods. 2nd order:

I compared the path of ‘ut’ in the two forecasts. I have to revise my earlier statement - in this sample model ‘ut’ for the 100 period forecast is not uniformely above the path for the 50 periods forecast; so it may very well occur that ‘v’ is larger in the 50 periods forecast.

Here is where I am puzzled (or simply something very basic is just escaping my mind): since ‘v’ is the objective function to be optimized, I would expect it to be larger when productivity is above steady state for a longer period. The opposite occurs in the Forecast exercise.

Using a first order approximation, ‘v’ is indeed higher when productivity is above steady state for a longer period. Why is the result reversed using the second order approximation? I am thinking that up to first order certainty-equivalence ensures the result, while at second order I am using a stochastic model to determine the outcome of a determinist shock - the correct experiment would be to simulate the model including stochastic shocks together with the deterministic shock.
Yet when setting the variance of the shocks to zero and repeating the exercise, I still obtain the same puzzling result with the second order approximation, and I cannot explain this. example2_modified.mod (3.37 KB)

This is a bit puzzling. One observes however, that when productivity goes back to the original steady state after 50 or 100 periods, there is a huge increase in period utility because agents work less and start depleting the stock of capital accumulated during the productivity boom. Of course, this occurs closer to now in the 50 period case than in the 100 period one and accounts more in welfare (current value of future utility).
Now, I can’t explain why it works in one direction in the linear approximation case and in the other in the 2nd order. Nor can I say which of the two is the better approximation. Remember that a 2nd order approximation isn’t always a better approximation than a 1st order one, particularily when on gets further from the steady state.
It is challenging to remark that it is indeed still difficult to rank from a welfare point of view the two rather simple scenarios that you are proposing.

Thanks for your reply. I agree on all counts - and on your puzzlement at the results.

The last question which is left unanswered is why DYNARE predicts that in a RBC model welfare improves when productivity is above steady state for a shorter, rather than longer, period of time.

That seems to run against basic intuition. Here is where my intuition could be flawed, and I would like to know your opinion, or the one of other forum participants. The problem I have in mind when building intuition is the one of an infinite horizon recursive model. Therefore if the expected value of productivity were higher, DYNARE should predict a higher welfare. But when running the FORECAST exercise I am basically looking at a finite horizon problem (solved, I assume, by backward induction). Therefore the policy function is not recursive. Since the terminal condition implies a large increase in utility when productivity goes back to steady state, there is no reason to expect that welfare should be higher when productivity is above steady state for a longer period.

The fact that discounted sum of per-period utility is larger when productivity is above steady state for a shorter period does not imply that this plan is available when productivity is above steady state for a longer period.