Dear developers,

I’m trying to use the det_cond_forecast command to make a perfectly anticipated trajectory of interest rates. I’ve successfully retrieved the smoothed variables from my dataframe with the estimation command.

However, It throws an error that makes me question if I’m interpreting correctly the tool. I’ve successfully create the plan and call the det_cond_forecast function, where *smoothed_vars* is a dseries containing the last observation of smoothed variables in DR-order appended with the shocks (similar to the output of smoother2histval). The date of this dseries object is correctly assigned as 2024Q2.

*horizon = dates(‘2024Q3’):dates(‘2027Q4’)*

*fplan = init_plan(horizon);*

*fplan = flip_plan(fplan,‘i’,‘eps_i’,‘perfect_foresight’,horizon(1:7), [10.5, 10.5, 10.5, 10.5, 10.5, 10.5, 10.5]);*

*dset_forecast = det_cond_forecast(fplan, smoothed_vars, horizon);*

**Error using det_cond_forecast**

**the dseries smoothed_vars finish at time 2024Q2 before the last period of forecast 2027Q4**

Of course the dseries finishes before the last period of my desired forecast, isn’t that the whole point? I have a dseries that starts at 2024Q2 and I wish to use it as initial values for forecasting through 2024Q3:2027Q4.

The det_cond_forecast.m file seems to be expecting a datafile containing data within the forecast horizon periods (?). It seems that I’m not fully aware of the what this tool aims to provide, if so can someone give me more information?

Thanks in advance !

I also noted that inside *det_cond_forecast.m* code, it calls a function called “simul()”, which is deprecated accordingly to the manual. This function doesn’t exists in the *dynare* directory, therefore it throws the error: *“Unrecognized function or variable ‘simul’.”*

@stepan-a Could you please have a look?

Dear professor @jpfeifer, thanks for your reply. Is there a way to adapt your code in the *NK_linear_forwad_guidance.mod* with initial values different from the steady-state?

Maybe setting the first column of *oo_.endo_simul* to the desired values after the *perfect_foresight_setup* command and repeating the algorithm would work?

Yes, that would be feasible. What exactly are you trying to do?

Thanks again for your reply. I’m trying to use perfect foresight to simulate a path for all endogenous variables given an (previously announced) chosen path for interest rates set by monetary policy, represented by a Taylor rule.

The first thing is to find the perfectly anticipated monetary shocks necessary to give this path for interest rates, which your code provides a very elegant solution. I think *det_cond_forecast* along with *flip_plan* could do it, but I couldn’t find a working example.

What am I doing is to fill the first column of *oo_.endo_simul* by the smoothed values and the last column of *oo_.endo_simul* by steady-state values. The code runs successfully but I feel that terminal conditions are not correctly being taken into account.

I set *perfect_foresight_setup(periods = 20)*, fill *oo_.endo_simul* manually and run *perfectly_foresigh_solver*. Optimization works, paths correctly starts from the initial conditions, however I observe a large drop in *oo_.endo_simul* in the last period to the steady-state.

Setting the last column of *oo_.endo_simul* (column number *options_.periods* + 1) previously to running *perfectly_foresight_solver* is sufficient to establish the terminal conditions?

Can you provide your codes? Potentially via PM if proprietary.

Sure ! Thanks again Professor ! I’ll send you through PM. If I figure out what’s exactly happening, I post the complete explanation for anyone that may be having a similar problem and a simpler code illustrating.