Integration in Dynare 4

Hello everyone! I am currently writing my master thesis and I would like to build a search and matching model in Matlab with the help of Dynare. I found a paper that built a similar model, but with version 3 of Dynare. As there is an integral used in the model, this does not work with version 4. Could you please help me in solving the problem?

Figure7_a-2.mod (1.4 KB)
afa4.m (144 Bytes)

It seems you need to define an external_function. Search the forum.

I already did, but I could not figure out how to define the external function in my case. So I have to define an external function for the integral function right? But after that can I still refer to my function which is saved as afa4.m?

An example is at https://git.dynare.org/Dynare/dynare/blob/master/tests/external_function/no_deriv_fcns_provided.mod

Thanks for your help. But I don’t understand what is done in the example. What kind of function does he define with the external function? Do I need to specify the function in a separate m file?

Yes, the separate m-file is at https://git.dynare.org/Dynare/dynare/tree/master/tests/external_function

Okay, thanks. But what do I do If I need to specify both a function (afa4) and the integral function (Quad), which Dynare does not know. Do I need two separate m files then?

Could you please elaborate on what you exactly need to do. What are the things you need to compute in your model and on what do the functions you need to compute depend (which parameters and variables)

I want to create impulse response functions. In the model section I need to compute the integral of a function, which is saved in a separate m.file (afa4.m, I uploaded it earlier). In the original mod file, the authors calculated the integral as follow: quad(@afa4, vk,vf) (line 47 of Figure7_b.mod). But because version 4 of Dynare does not accept the quad function, I need to specify an external function. Do I have to save the function (afa4) and the quad function (of afa4) in the same m-file? I will upload the Figure7_b.mod file, so you can have a look at it (line 47).Figure7_b.mod (2.2 KB)

Do you have any suggestions for how to solve this problem? Thank you in advance.

Attached is a working version:
stw5_EU_calib_noQI_fc0225_Co0.csv (459 Bytes) Figure7_b_4.mod (2.6 KB) quad_afa4.m (174 Bytes) quad_afa5.m (177 Bytes)
It eliminates the global variable as well.