# How to use perfect foresight in Dynare Julia

**URL:** <https://discourse.julialang.org/t/how-to-use-perfect-foresight-in-dynare-julia/134716>\
**Category:** Package Management\
**Tags:** question, package, dynare\
**Created:** [December 24, 2025, 3:07am UTC](https://discourse.julialang.org/t/how-to-use-perfect-foresight-in-dynare-julia/134716 "2025-12-24T03:07:28Z")\
**Posts on this page:** 2\
**Page:** 1

<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 24, 2025, 3:07am UTC](https://discourse.julialang.org/t/how-to-use-perfect-foresight-in-dynare-julia/134716/1 "2025-12-24T03:07:28Z")

</div>

Using Dynare.jl for solving a perfect foresight. The model runs under stochastic simulations, so that the .mod file is correct. I am using Julia 1.12 and latest Dynare version. I post this code: Dynare.perfect\_foresight!(  
context = context,  
periods = 1000,  
datafile = “shocks\_RBC6.csv”,  
display = true,  
maxit = 50, mcp = true,  
tolf = 1e-5, tolx = 1e-5)

and get the following error: ArgumentError: Invalid buffers for SparseMatrixCSC construction n=72, colptr=75-element Vector{Int64}, rowval=90-element Vector{Int64}, nzval=90-element Vector{Float64}

Stacktrace:  
[1] SparseMatrixCSC  
@ C:\Users\Saint.julia\juliaup\julia-1.12.3+0.x64.w64.mingw32\share\julia\stdlib\v1.12\SparseArrays\src\sparsematrix.jl:29 [inlined]  
[2] SparseArrays.SparseMatrixCSC(m::Int64, n::Int64, colptr::Vector{Int64}, rowval::Vector{Int64}, nzval::Vector{Float64})  
@ SparseArrays C:\Users\Saint.julia\juliaup\julia-1.12.3+0.x64.w64.mingw32\share\julia\stdlib\v1.12\SparseArrays\src\sparsematrix.jl:44  
[3] Dynare.DynamicWs(endogenous\_nbr::Int64, exogenous\_nbr::Int64, tmp\_nbr::Int64, colptr::Vector{Int64}, rowval::Vector{Int64}; order::Int64)  
@ Dynare C:\Users\Saint.julia\packages\Dynare\TkH8b\src\model.jl:24

Using the perfect foresight version of Dynare in Matlab works fine. I have also added in the PATHsolver and the Pardiso packages which are needed for this.

---

<div class="post-metadata">

**Author:** ![ufechner7](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ufechner7/32/51363_2.png) [@ufechner7](https://discourse.julialang.org/u/ufechner7)\
**Post date:** [December 24, 2025, 6:59am UTC](https://discourse.julialang.org/t/how-to-use-perfect-foresight-in-dynare-julia/134716/2 "2025-12-24T06:59:59Z")

</div>

Small remark: If you share code or stack traces, please enclose them in triple back-ticks, like ``` for readability.

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