Thanks you so much. I got the point now. But I am a bit confused about what kind of calibration will make the model non-linear. Can you please explain a bit? Can you please provide me any example? Or will you refer me to any book or material to be able to understand this point.

# 3rd order perturbation closing devices Uribe

**jpfeifer**#12

Just have a look at the first order conditions. You will see which parts are not linear and what governs the degree of nonlinearity. Take the Euler equation. There you often have c_t^{-\sigma}. Here it clearly is \sigma.

**sfaf**#14

Hi Johannes,

I have been reading about pruning in others discussion at this forum. Though, I got some basic idea about it. I am using portfolio adjustment model from SGU 2003 and calibrating the model for emerging countries. With 3rd order perturbation and standard deviation of productivity is 0.0214. And without pruning option moments are better matched with empirical. Can I remove pruning option why and why not.?

**jpfeifer**#15

Pruning is a technical fix to prevent explosive simulations. If your simulations do not explode, you can remove it.

**sfaf**#16

Thanks a lot. Yes Simulation in PAC model do not explode,

stoch_simul(order=3,periods = 500000, drop= 200, irf=50)

Similarly Internal discount factor without internalization discount factor(IDF) and External discount factor without internalization(EDF) do not explode too.

However, Debt elastic models(both, External Debt Elastic Interest Rate Model (EDEIR) and Internal Elastic Interest Rate Model (IDEIR)) are exploding I get NaN ….

I could not find reason why there is difference. I am using the same parameters values across these models.

**jpfeifer**#17

Those are different models. If you want to stay comparable across models, you should use pruning.

**sfaf**#18

Thanks, I found the solution, I play around for a while, with the debt friction value for IDEIR and EDEIR model. They both work well without pruning too. I don’t get the explosive in simulation and also GIRFs are fine too.

**sfaf**#20

I am using different values of parameters than SGU2003. so model is non-linear and 1st order and 3rd order perturbation give different moments. 3rd order give better moments than 1st.

**sfaf**#22

But you mentioned in this notes that a whether model is linear or not linear depends on the values of the parameters.

**jpfeifer**#23

@sfaf I don’t understand the question. A model can be highly nonlinear, but when you solve it at first order, you are doing a linear approximation, i.e. you will turn it into a linear model.

**sfaf**#24

Sorry Johannes, I thought that above notes is from you. I don’t have any question. As I had cleared my concept in the beginning of this conversion.

Thanks.

**sfaf**#25

stochastic.mod (5.7 KB)

Hello Professor Johannes,

Please find attached codes IDEIR SGU 2003, I build these based on your codes for **Basu_Bundick_2017** and **Ambrogio Cesa-Bianchi** I want find two things, one to stochastic steady state as you did for Risk matters. Second, to find IRFs starting at the stochastic steady state. I could not figure out how to get stochastic steady state/risky steady state. Though these codes are working fine but IRFs are awkward. something wrong. Please help.

**jpfeifer**#26

Setting

```
shock_mat(1+burnin,strmatch('eps_sigma_a',M_.exo_names,'exact'))= 1;
```

does not work, because there is no shock named `eps_sigma_a`

in your model.

Risky steady state for SGU 2003

**sfaf**#27

Thanks you so much it worked for me I replied to you on another post. I have learned a lot from you and from this forum in the last few months. I am greatly thankful to you.

PAC2.mod (3.5 KB)

Please find attached codes for PAC model as one of the closing devices (SGU 2003). I am using now your codes of Risk matters. For me these are a bit complicated to understand than for Basu/Bundick. First, I would like to confirm that, as in your paper, Erg. Mean(SS) given in Appendix F are the same as **ergodicmean_no_shocks** that I get from dynare output.

Can I get **(IRFs) from the ergodic mean in the absence of shocks**

**(EMAS)**? from the codes I have attached. Lastly, I want to find the second moments PAC model from this pruning scheme. I could not yet figure out. Please help me on this.

Best Regards,

Shafi

**sfaf**#28

PAC2.mod (6.1 KB)

Hi Professor Johannes,

This is in continuation of the above post. Please find attached updated version of PAC2. Trying to build IRFs based on your codes for Risk matter for using pruning scheme of Andreasen et al. (2013). I think something still wrong with IRFs.

I used PruninngDynare4.4 of Martin Andreasen

https://sites.google.com/site/mandreasendk/home-1/Codes/Dynare44Pruning.zip?attredirects=0&d=1 It gives me very similar second moments as when I do it Dynare using pruning option. Is dynare pruning scheme is same as by Martin Andreasen. I am copying from Dyanre Manual " **Discard higher order terms when iteratively computing simulations of the solution. At second order, Dynare uses the algorithm of Kim, Kim, Schaumburg and Sims (2008), while at third order its generalization by Andreasen, Fern´andez-Villaverde and Rubio-Ram´ırez (2013) is used."** It means they are same as Dynare pruning scheme. However, difference in IRFs Dynare gives us based on simlulation while Andreasen analytical GIRFs. Right?

**jpfeifer**#29

Hi,

Dynare uses the same pruning scheme, but Andreasen reports GIRFs, i.e. generalized IRFs. If you want to write paper, please use the Basu/Bundick codes for generating IRFs at the stochastic steady state/EMAS. The Risk matters codes had to follow the original AER paper and are less than ideal.