I have a Bellman Equation and I am trying to estimate its expected value, EV, by iteration. My first guess for this value is EV=0, and from that I am supposed to estimate another guess as follows:
And iterate until convergence. Here, x and i are endogenous variables (with x being continuous and i a dummy with value either 0 or 1), y is the future value of x and j the future value of i. θ is the set of parameters, which is known. Function u is also known and is linear. P is a four by four transition matrix, composed of some of the parameters included in θ. I am trying to code this in Dynare:
parameters beta RC theta_11 theta_30 theta_31 theta_32 theta_33;
beta = 0.9999;
RC = 9.7687;
theta_11 = 1.3428;
P = [1 1 1 1; 1 1 1 1; 1 1 1 1; 1 1 1 1];
EV = integral(log(exp(-theta_11x + betaEV(+1))+exp(-RC + betaEV(+1))))P;
EV = 0;
However, I run into a number of problems with this:
- Dynare won’t create matrix P so I think I will need to add P in matlab and then multiplicate the function. This is fine by me, but if someone has a simpler approach, I would love to hear it.
- As you can see from the intitial equation, EV is a function of i and x and I don’t think the simplified version in my code is capturing this correctly, but it’s the best I knew how to do. Does anyone know how to make the value function depend on two values?
- MOST IMPORTANTLY: when I run this code in Dynare, an error occurs reading “To use an external function (integral) within the model block, you must first declare it via the external_function() statement.” I tried to solve this by using
And putting it at different places throughout the code. However, the error message or a similar one always shows up. Does anyone know what to do?
Thanks in advance!