# Heterogeneous agent model

**URL:** <https://forum.dynare.org/t/heterogeneous-agent-model/16627>\
**Category:** General DSGE Modeling\
**Created:** [17 September 2020 06:52 UTC](https://forum.dynare.org/t/heterogeneous-agent-model/16627 "2020-09-17T06:52:55Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![QIU121180875](https://forum.dynare.org/user_avatar/forum.dynare.org/qiu121180875/32/10868_2.png) [@QIU121180875](https://forum.dynare.org/u/QIU121180875)\
**Post date:** [17 September 2020 06:52 UTC](https://forum.dynare.org/t/heterogeneous-agent-model/16627/1 "2020-09-17T06:52:56Z")

</div>

I’m working on a heterogeneous agent problem.I set up a lot of agents whose parameters are different. I want to solve the model under different parameters by changing this parameter in a loop, and then get the decision function of the corresponding agent. How to achieve this through the interaction between MATLAB and Dyanre?

---

<div class="post-metadata">

**Author:** ![jpfeifer](https://forum.dynare.org/user_avatar/forum.dynare.org/jpfeifer/32/5044_2.png) [@jpfeifer](https://forum.dynare.org/u/jpfeifer)\
**Post date:** [17 September 2020 12:31 UTC](https://forum.dynare.org/t/heterogeneous-agent-model/16627/2 "2020-09-17T12:31:12Z")

</div>

The big question is whether the model can be solved in Dynare. If yes, then it’s a simple matter of doing a loop.

---

<div class="post-metadata">

**Author:** ![QIU121180875](https://forum.dynare.org/user_avatar/forum.dynare.org/qiu121180875/32/10868_2.png) [@QIU121180875](https://forum.dynare.org/u/QIU121180875)\
**Post date:** [17 September 2020 12:52 UTC](https://forum.dynare.org/t/heterogeneous-agent-model/16627/3 "2020-09-17T12:52:08Z")

</div>

I just want to change the parameters of the model in each loop, and then extract the decision function, and I only need the first order approximation solution.Please tell me how to do it.Thank you very much.

---

<div class="post-metadata">

**Author:** ![jpfeifer](https://forum.dynare.org/user_avatar/forum.dynare.org/jpfeifer/32/5044_2.png) [@jpfeifer](https://forum.dynare.org/u/jpfeifer)\
**Post date:** [17 September 2020 13:04 UTC](https://forum.dynare.org/t/heterogeneous-agent-model/16627/4 "2020-09-17T13:04:10Z")

</div>

See

> [@Loop over parameters](https://forum.dynare.org/t/loop-over-parameters/3335/2):
>
> You are not actually setting the parameter. What you should do is use the the set\_param\_value command. Moreover, if you have an analytic steady state, use a steady\_state\_model block instead of initval. You can find an example for such a loop here: [[Need help to check Matlab compatibility](http://forum.dynare.org/t/need-help-to-check-matlab-compatibility/3192/1)). Basically, you need to write a Matlab m-file with the following parts: rhos = 0.8:0.05:1.05; first\_time = 1; for i=1:length(rhos) if first\_time set\_param\_value('rho',rhos(i)); dynare your\_…

---

<div class="post-metadata">

**Author:** ![QIU121180875](https://forum.dynare.org/user_avatar/forum.dynare.org/qiu121180875/32/10868_2.png) [@QIU121180875](https://forum.dynare.org/u/QIU121180875)\
**Post date:** [17 September 2020 13:21 UTC](https://forum.dynare.org/t/heterogeneous-agent-model/16627/5 "2020-09-17T13:21:01Z")

</div>

Thank you very much again.
