# How to write a function which include integral sign inside the function

Hello, I am replicating a paper on search and matching with endogenous job separation. All value functions are included in equilibrium equations and there is integral with upper and lower limit in all value functions. Can anybody help me how to write these values functions with integral in dynare codes

The question is on what these integrals depend. If they depend on endogenous variables so that derivatives are required, then you may have to go for an external function. See e.g. Integration in Dynare 4

Thank you for your reply. I have 4 value functions which i have to write in my codes. Do i need external function of each of them or i can use one external function for all.

Thanking in anticipation

Without details, it is impossible to know. Often, you can define the whole object with the integral recursively as a separate variable so that integrals do not appear anywhere.

Hello,
Thank you for your reply. I am replicating paper of (Miyamoto et.al 2019) and following is the value function of filled job.
Jt=Atf(ktht)-(wtxtht)-rtkt-xt+SDF*((1-rho^x*(integralunderline(x)^(xbar(t+1))J(t+1)(x(t+1)*Gamma(x(t+1)+(1-(1-rho^(x))Gammaxbar(t+1))*V(t+1))

Can you please explain how i can write it recursilvey?
best

Which paper exactly is it?

This is the paper.
Fiscal Stimulus and Unemployment Dynamics.pdf (1012.0 KB)

Have you asked the authors how they did this? It may be the easiest to linearize the equations by hand.

Yes i have asked but they did not reply. Dynare can find the steady state and linearize the model if the i follow the restrictions on the parameters or is it necessary to linearize the model?

best

Hello,

These integrals are just showing the cumulative distribution with the range of (0,1). Do i still need to write integral as an external function?

best

Which integrals exactly are you referring to. Also, if you don’t know the distribution, then computing a CDF is hard…

Thank you for your reply. As you suggested i lineairzed the model and try to estimate it but i am facing following error in my estimation.
In evaluate_steady_state (line 263)
In steady_ (line 55)
In steady (line 81)
In linear_model (line 361)
In dynare (line 233)
In Untitled2 (line 3)
Warning: Matrix is singular to working precision.
STEADY: No steady state for your model could be found
STEADY: Check whether your model is truly linear. Put “resid(1);” before “steady;” to see the problematic equations.

Residuals of the static equations:

Equation number 1 : NaN
Equation number 2 : NaN
Equation number 3 : NaN
Equation number 4 : NaN
Equation number 5 : NaN
Equation number 6 : NaN
Equation number 7 : NaN
Equation number 8 : NaN
Equation number 9 : NaN
Equation number 10 : NaN
Equation number 11 : NaN
Equation number 12 : NaN
Equation number 13 : NaN
Equation number 14 : NaN
Equation number 15 : NaN
Equation number 16 : NaN
Equation number 17 : NaN
Equation number 18 : -85.0098
Equation number 19 : -75.01

Error using print_info (line 90)
The steady state contains NaN or Inf

Error in steady (line 104)
print_info(info,options_.noprint, options_);

Error in linear_model (line 361)

Error in dynare (line 233)
evalin(‘base’,fname) ;

Error in Untitled2 (line 3)
dynare linear_model.mod

Can you please help me how to solve this problem.
Thanking in anticipation.

linear_model.mod (7.2 KB)

Your linearization must be incorrect. Why are there constant terms showing up in your equations? E.g. in equation 3, why is there an `A` with value 0.75?

Thank you for your reply. Yes the value of A was incorrect as it is 1.00 but i think linearization of equation 3 is correct as this is production function and A is aggregate productivity. I put the correct value of A and now i have this error
The steadystate file did not compute the steady state

Error in steady (line 104)
print_info(info,options_.noprint, options_);

Error in linear_model (line 360)