# How to use set\_param\_value

**URL:** https://forum.dynare.org/t/how-to-use-set-param-value/20448
**Category:** Stochastic simulations
**Created:** [29 May 2022 14:44 UTC](https://forum.dynare.org/t/how-to-use-set-param-value/20448 "2022-05-29T14:44:08Z")
**Posts on this page:** 15
**Page:** 1

<div class="post-metadata">

### Author: ![Nakatuma](https://forum.dynare.org/letter_avatar_proxy/v4/letter/n/8797f3/32.png) [@Nakatuma](https://forum.dynare.org/u/Nakatuma)
#### Post date: [29 May 2022 14:44 UTC](https://forum.dynare.org/t/how-to-use-set-param-value/20448/1 "2022-05-29T14:44:09Z")

</div>

Hi guys, I met some problem when trying to loop over a parameter by command ‘set\_param\_value’.  
I want to set the param ‘Phi\_Pi\_star = 1.2’, and here’s how I did:

set\_param\_value(‘Phi\_Pi\_star’,1.2);  
dynare baseline noclearall;

But I found the value of Phi\_Pi\_star would be covered by calibrate mod file. Then I deleted the ‘Phi\_Pi = x;’ from the calibrate mod file and did it again, but this time the steady state got NaN (I used a log-linearize model, and pretty sure the problem is not from the model).

I check the “Looping over Parameters”, but still have no idea what I done wrong.

---

<div class="post-metadata">

### Author: ![punnoosejacob](https://forum.dynare.org/user_avatar/forum.dynare.org/punnoosejacob/32/5976_2.png) [@punnoosejacob](https://forum.dynare.org/u/punnoosejacob)
#### Post date: [29 May 2022 20:19 UTC](https://forum.dynare.org/t/how-to-use-set-param-value/20448/2 "2022-05-29T20:19:36Z")

</div>

I use the set\_param\_value function within the dynare mod file, and it works fine. I don’t think we can use that function outside the mod file as you have. Dynare would simply overwrite it: somebody please correct me if I am wrong.

Cheers  
Reuben

---

<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: [30 May 2022 09:06 UTC](https://forum.dynare.org/t/how-to-use-set-param-value/20448/3 "2022-05-30T09:06:36Z")

</div>

@punnoosejacob Is correct. `set_param_value` will rely on a global variable that will not yet exists before calling Dynare the first time. Also you may overwrite the contents.

---

<div class="post-metadata">

### Author: ![Nakatuma](https://forum.dynare.org/letter_avatar_proxy/v4/letter/n/8797f3/32.png) [@Nakatuma](https://forum.dynare.org/u/Nakatuma)
#### Post date: [30 May 2022 10:06 UTC](https://forum.dynare.org/t/how-to-use-set-param-value/20448/4 "2022-05-30T10:06:51Z")

</div>

Thanks a lot, it helps!

---

<div class="post-metadata">

### Author: ![Nakatuma](https://forum.dynare.org/letter_avatar_proxy/v4/letter/n/8797f3/32.png) [@Nakatuma](https://forum.dynare.org/u/Nakatuma)
#### Post date: [30 May 2022 10:12 UTC](https://forum.dynare.org/t/how-to-use-set-param-value/20448/5 "2022-05-30T10:12:55Z")

</div>

I have tried another way by using ‘set\_param\_value’ inside the mod file, it works well!  
Moreover I wondering if I can use stoch\_simul in a matlab file after calling dynare once? (I have seen your comments in another discussion, but I still couldn’t figure out the routine).  
And I do know Dynare can compute the SpectralDensity, if it is possible way to compute the cross-spectral density?

---

<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: [30 May 2022 13:13 UTC](https://forum.dynare.org/t/how-to-use-set-param-value/20448/6 "2022-05-30T13:13:51Z")

</div>

An example is at [Parameter loop in Dynare 5.x - #3 by jpfeifer](https://forum.dynare.org/t/parameter-loop-in-dynare-5-x/20293/3)  
And no, the cross-spectra are not computed by Dynare.

---

<div class="post-metadata">

### Author: ![Nakatuma](https://forum.dynare.org/letter_avatar_proxy/v4/letter/n/8797f3/32.png) [@Nakatuma](https://forum.dynare.org/u/Nakatuma)
#### Post date: [30 May 2022 14:36 UTC](https://forum.dynare.org/t/how-to-use-set-param-value/20448/7 "2022-05-30T14:36:11Z")

</div>

Thanks!  
If there’s any precedents on calculating cross-spectral density or maybe some advice?  
And if there’s possible way to get the coefficient matrix of the linear equation system like Sims(2002)/Klein/B&K suggest to?  
I am trying to replicate the method of Sargent and Surico (2011, AER) and Kliem et al(2016,EER) by Dynare.  
Great thanks for answering so many question!

---

<div class="post-metadata">

### Author: ![Nakatuma](https://forum.dynare.org/letter_avatar_proxy/v4/letter/n/8797f3/32.png) [@Nakatuma](https://forum.dynare.org/u/Nakatuma)
#### Post date: [30 May 2022 15:35 UTC](https://forum.dynare.org/t/how-to-use-set-param-value/20448/8 "2022-05-30T15:35:07Z")

</div>

As for  
"  
And if there’s possible way to get the coefficient matrix of the linear equation system like Sims(2002)/Klein/B&K suggest to?  
"  
It that the “oo\_.dr.ghx”?

---

<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: [30 May 2022 15:40 UTC](https://forum.dynare.org/t/how-to-use-set-param-value/20448/9 "2022-05-30T15:40:32Z")

</div>

Which linear equation system do you mean? The state space representation?

---

<div class="post-metadata">

### Author: ![Nakatuma](https://forum.dynare.org/letter_avatar_proxy/v4/letter/n/8797f3/32.png) [@Nakatuma](https://forum.dynare.org/u/Nakatuma)
#### Post date: [30 May 2022 15:45 UTC](https://forum.dynare.org/t/how-to-use-set-param-value/20448/10 "2022-05-30T15:45:03Z")

</div>

Yes

---

<div class="post-metadata">

### Author: ![Nakatuma](https://forum.dynare.org/letter_avatar_proxy/v4/letter/n/8797f3/32.png) [@Nakatuma](https://forum.dynare.org/u/Nakatuma)
#### Post date: [30 May 2022 15:47 UTC](https://forum.dynare.org/t/how-to-use-set-param-value/20448/11 "2022-05-30T15:47:03Z")

</div>

![image](https://forum.dynare.org/uploads/default/original/2X/e/ee1ebed269363538a53d7ef2f2aaba5cace964b5.png)

---

<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: [30 May 2022 15:53 UTC](https://forum.dynare.org/t/how-to-use-set-param-value/20448/12 "2022-05-30T15:53:38Z")

</div>

Have a look at [DSGE\_mod/ABCD\_test.m at master · JohannesPfeifer/DSGE\_mod · GitHub](https://github.com/JohannesPfeifer/DSGE_mod/blob/master/FV_et_al_2007/ABCD_test.m)

---

<div class="post-metadata">

### Author: ![Nakatuma](https://forum.dynare.org/letter_avatar_proxy/v4/letter/n/8797f3/32.png) [@Nakatuma](https://forum.dynare.org/u/Nakatuma)
#### Post date: [30 May 2022 15:57 UTC](https://forum.dynare.org/t/how-to-use-set-param-value/20448/13 "2022-05-30T15:57:52Z")

</div>

Many thanks in advance!

---

<div class="post-metadata">

### Author: ![Nakatuma](https://forum.dynare.org/letter_avatar_proxy/v4/letter/n/8797f3/32.png) [@Nakatuma](https://forum.dynare.org/u/Nakatuma)
#### Post date: [30 May 2022 16:08 UTC](https://forum.dynare.org/t/how-to-use-set-param-value/20448/14 "2022-05-30T16:08:57Z")

</div>

Is control toolbox means the control system toolbox?

---

<div class="post-metadata">

### Author: ![Nakatuma](https://forum.dynare.org/letter_avatar_proxy/v4/letter/n/8797f3/32.png) [@Nakatuma](https://forum.dynare.org/u/Nakatuma)
#### Post date: [30 May 2022 16:10 UTC](https://forum.dynare.org/t/how-to-use-set-param-value/20448/15 "2022-05-30T16:10:24Z")

</div>

problem solved, thanks a lot
