Collect shocks to calculate second steady state

I have a model with an initial and a final steady states, initialized with initval and endval. I use a separated file to calculate the steady states. From an initial given money supply, the model has shocks to money supply. Money supply grows over time.

I would like to collect the shocks to money supply to obtain the final money supply. Given the final money supply, I can then calculate the price level and other variables.

I can do this with perfect foresight, as I know the values of the money supply shocks over time. How can I do this with a stochastic simulation? In the mod file, I tried to access the relevant variables in oo_.exo_simul to use them as input in the endval declaration, but oo_.exo_simul was empty, as it seems that oo_ is only created after the simulation is made. How can I collect the simulated shocks and use them as input to the endval block?

I am not sure I understand. What do you mean with

in this context? Do you want to do an arbitrary stochastic simulation?

My idea was to have access to the shocks simulated with a stochastic simulation and use them as input to a second steady state defined by endval. However, the stochastic simulation is made around the first steady state. So, apparently, I cannot use use endval with a stochastic simulation. Can I use endval with a stochastic simulation to change a variable defined with varexo_det?

I still don’t understand what endval is supposed to do here. With stochastic simulations, you can only specify terminal conditions for something that is completely exogenous.

Correct. The endval is to be used to change an exogenous variable present in the model. However, I want to include stochastic shocks to the model. Is it possible to have endval in a model solved with stochastic simulation?

Note: I thought about the problem and found another solution that does not require this change in an exogenous variable. I will focus on the second steady state. In any case, I would like to know about the possibility of using endval in this context.

I think in this case you should use the shocks block to control the values of the exogenous variables. endval is not applicable here.

That is fine. Thank you.