# Dynare perfect foresight simulation - how do I access solution to endogenous variables?

**URL:** <https://discourse.julialang.org/t/dynare-perfect-foresight-simulation-how-do-i-access-solution-to-endogenous-variables/83905>\
**Category:** Finance and Economics\
**Tags:** question, dynare\
**Created:** [July 7, 2022, 3:25pm UTC](https://discourse.julialang.org/t/dynare-perfect-foresight-simulation-how-do-i-access-solution-to-endogenous-variables/83905 "2022-07-07T15:25:25Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![geekbear](https://avatars.discourse-cdn.com/v4/letter/g/c5a1d2/32.png) [@geekbear](https://discourse.julialang.org/u/geekbear)\
**Post date:** [July 7, 2022, 3:25pm UTC](https://discourse.julialang.org/t/dynare-perfect-foresight-simulation-how-do-i-access-solution-to-endogenous-variables/83905/1 "2022-07-07T15:25:25Z")

</div>

I ran the example1pf.mod from Dynare.jl on GitHub. I know output is stored in the .jld2 file in the “output” folder. But how do I actually access the solution to endogenous variables so that I can use them, e.g. plotting their time series? Many thanks!

---

<div class="post-metadata">

**Author:** ![MichelJuillard](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/micheljuillard/32/10555_2.png) [@MichelJuillard](https://discourse.julialang.org/u/MichelJuillard)\
**Post date:** [July 7, 2022, 4:50pm UTC](https://discourse.julialang.org/t/dynare-perfect-foresight-simulation-how-do-i-access-solution-to-endogenous-variables/83905/2 "2022-07-07T16:50:56Z")

</div>

There exist the following undocumented accessor functions:

- simulation(): returns a vector of simulation results
- simulation(1): returns the first simulation in a TimeDataFrame
- simulation(:Y): returns the simulated trajectory for variable Y
- simulation((:Y, :X))+ returns a TimeDataFrame with the simulated trajectory for variables Y and X
- irfs()+ returns a dictionary with an entry for each exogenous variable
- irfs(:e)+ returns a TimeDataFrame with IRFs for shock on variable e
- irfs(:e, :Y)+ returns a TimeDataFrame with IRFs for shock on variable e for endogenous variable Y
- irfs(:e, (:X, :Y))+ returns a TimeDataFrame with IRFs for shock on variable e for endogenous variable X and Y

---

<div class="post-metadata">

**Author:** ![geekbear](https://avatars.discourse-cdn.com/v4/letter/g/c5a1d2/32.png) [@geekbear](https://discourse.julialang.org/u/geekbear)\
**Post date:** [July 7, 2022, 5:56pm UTC](https://discourse.julialang.org/t/dynare-perfect-foresight-simulation-how-do-i-access-solution-to-endogenous-variables/83905/3 "2022-07-07T17:56:15Z")

</div>

Many many many thanks!!!

---

<div class="post-metadata">

**Author:** ![McNelis-CMML](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mcnelis-cmml/32/220056_2.png) [@McNelis-CMML](https://discourse.julialang.org/u/McNelis-CMML)\
**Post date:** [December 23, 2025, 2:33pm UTC](https://discourse.julialang.org/t/dynare-perfect-foresight-simulation-how-do-i-access-solution-to-endogenous-variables/83905/4 "2025-12-23T14:33:19Z")

</div>

Using julia dynare for the perfect foresight. Works perfectly in Matlab but in Julia I am getting a sparse matrix error. I loaded in suggested packages for using the perfect forsight, The initial context works well but when I do the command for the perfect foreseight solver in Julia I get the sparse matrix error Is this a bug (using Julia 12? Or is the model to large with T = 2000? Again it works in Matlab. Thanks

---

<div class="post-metadata">

**Author:** ![nilshg](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nilshg/32/2283_2.png) [@nilshg](https://discourse.julialang.org/u/nilshg)\
**Post date:** [December 23, 2025, 3:10pm UTC](https://discourse.julialang.org/t/dynare-perfect-foresight-simulation-how-do-i-access-solution-to-endogenous-variables/83905/5 "2025-12-23T15:10:51Z")

</div>

Please read [Please read: make it easier to help you](https://discourse.julialang.org/t/please-read-make-it-easier-to-help-you/14757)

- Make a new post rather than posting on old, only tangentially related threads
- Include a minimum working example to show people what you’ve done
- Include Julia and package versions so people can replicate your setup
