Simulation with a fixed path for a variable

Hi.
Let’s say that I have a calibrated model and I would like to do a simulation.
Normally, I would use the simult_ function with a matrix of shocks. But how can I proceed if I don’t know one of the shocks but instead, if I know the path of one endogenous variable?
One solution I can think of is to do a simulation with a guess of this shock and see if that specific variable has the value equal to the path that I know. If not, simulated again with another guess. And do this until I guess correctly. Then, I will repeat the process for the second period assuming the value that I guess for the previous periods and so on.
Is there a easier way to do that?

You seem to be describing what is known as a filtering/smoothing problem. In general, you can use different statistical filters to estimate the shocks consistent with your observed data, conditional on your model. In the case of linear models with normally distributed shocks, the Kalman Filter and Smoother provide efficient algorithms to solve this problem. You can employ the command calib_smoother in Dynare to use them on calibrated models.

If there is a one to one mapping, you can use the conditional_forecast command.

Thank you again, professor Pfeifer.