This project is read-only.

Estimation

Topics: Models
Mar 31, 2014 at 3:34 AM
Hi Iris team,
I’m trying to estimate a basic new keynesian model but I’m having some problems. If I have a new Keynesian model with 3 equations, I have 3 forward looking variables and 3 unstable roots, to solve the model. But, when I introduce the measurement variables that is also a forward looking variable, this forward variable changes its nature and become backward looking. Then, when I try to estimate the model’s parameters the rank condition is not satisfied and I get the attached error message. When I estimate this using Dynare I have no problem. Can you explain me how to deal with this?
Is there any option I can use to attach the codes?
Thanks in advance for your kind attention.


Camila Londoño


??? Error using ==> getstack at 12
IRIS Toolbox Error :: model.
*** The model failed to updated new parameters.

Type x = model.failed(); to get the model object that failed to solve.

IRIS Toolbox Error :: model.
*** Solution not available. NaN in derivatives of this equation in #1: 'x=(x{1})-(1/sigma)*(i-(pi{1}))+dem;'.

Error in ==> error at 37
stack = utils.getstack();

Error in ==> model.failed at 55
utils.error('model',[...

Error in ==> model.myupdatemodel at 130
model.failed(This,sstateOk,chkSstateOk,sstateErrList, ...
Error in ==> model.objfunc at 31
[This,UpdateOk] = myupdatemodel(This,X,Pri,EstOpt,throwErr);
Error in ==> nlconst at 805
            f = feval(funfcn{3},x,varargin{:});
Error in ==> fmincon at 758
[X,FVAL,LAMBDA,EXITFLAG,OUTPUT,GRAD,HESSIAN]=...
Error in ==> estimateobj.myestimate at 45
            [PStar,ObjStar,~,~,LAMBDA,grad,Hess{1}] = ...
Error in ==> model.estimate at 395
[This,pStar,objStar,PCov,Hess] = myestimate(This,Data,pri,estOpt,likOpt);

Error in ==> estimate_3eq at 119
[est,pos,C,H,mest,v,~,~,delta,Pdelta] = ...
Mar 31, 2014 at 2:28 PM
Edited Mar 31, 2014 at 2:33 PM
Hi Camila

The problem you're having is actually not related to measurement equations or a rank condition. It simply means that during the numeric estimation, some parameter value or values move into a region where the equation derivatives cannot be evaluated; this is what this part of the error message says *** Solution not available. NaN in derivatives of this equation in #1: 'x=(x{1})-(1/sigma)*(i-(pi{1})) dem;'.

Let me me explain what's wrong, why IRIS behaves this way, and what options you have to fix the problem.

My guess is that it is the parameter sigma that causes troubles. You probably didn't set any lower and upper bounds on this parameter, or set the bounds so that, for instance, zero or negative values for this parameter were allowed. This means that during the estimation the numerical optimization procedure can assign zero or negative values to sigma. And if it's zero, the equation cannot be obviously evaluated because of the 1/sigma.

If something like this happens in IRIS, you can choose between two types of behavior using the option 'noSolution=' in the function estimate(...). By default, this option is set to 'error' meaning that whenever an equation, a derivative, or a solution cannot be evaluated, an error is thrown out. If this happens, you can actually access the particular parameterization that caused the troubles to see what exactly went wrong. The top of the error message says Type x = model.failed(); to get the model object that failed to solve. In other words, if you type the following command on the command line immediately after your code crashes
>> x = model.failed()
then the model object x will contain exactly those parameter values that resulted in the error. To review those parameters, simply type
>> get(x,'parameters')
You might probably see that sigma is zero or numerically close to zero...

Now, how to fix the problem?

First, you can set the option 'noSolution=' to 'penalty'. This means that should an error occur when the equations, derivatives, or a solution is being evaluated, then the estimation procedure does not stop, but simply that particular parameter set that caused the problem is penalized, i.e. assigned a very low likelihood. This effectively tells the optimization routine to stay away from that region. This is also the approach used in Dynare, and that's why you don't bump against the error there.

A much better and more robust approach (which you can or course combine with the above 'noSolution=' 'penalty') is though to carefully design the lower and upper bounds for (all of) your parameters to guarantee that during estimation, the parameter values stay in a region that makes sense both from an economic and technical point of view. The lower and upper bounds can be set as the second and third values, respectively, in the estimation struct (but you probably know this...).

One last comment. Trying to fit a purely forward looking model to real-world data is not a very good idea. Because of a lack of real-world persistence in the model, the model structure is way too much misspecified. Then, some of the parameters quickly lose their economic meaning, and are pushed into values that make little sense, and may cause the kinds of troubles you've experienced...

I hope this helps. Let me know if you need to know more...

Best,
Jaromir
Marked as answer by michaeljohnston on 4/4/2014 at 12:37 AM
Apr 11, 2014 at 3:13 PM
Edited Apr 11, 2014 at 3:20 PM
Thank you Jaromir, you are right. The model is estimating very well.