Saturday, September 5, 2020

Problem with ml model with panel data and misclassification error

Dear all,

I'm trying to implement Hausman et al (1998) misclassification error for binary choice model with panel data. ml check give me an error : Two different coefficient vectors resulted in equal log likelihood values r(9). I don't know how I can fix it. Do you have any suggestions? Many thanks and best regards,

Code:
program drop _all
program define mrpr
    version 16.1
    args   todo  b lnfj  
    tempvar mylnf xb alpha0 alpha1 last 

    mleval `xb'=`b', eq(1)
    mleval `alpha0'=`b', eq(2) scalar
    mleval `alpha1'=`b', eq(3) scalar
    scalar `alpha0'=invlogit(`alpha0')/2
    scalar `alpha1'=invlogit(`alpha1')/2

    local by $My_panel
   sort `by'
   by `by'    : gen `last'=(_n==_N)

   gen double `mylnf'=0
   replace `mylnf'= $ML_y1 *ln(`alpha0'+(1-`alpha0'-`alpha1')*normal(`xb')) +(1-$ML_y1 )*ln((1-`alpha0')-(1-`alpha0'-`alpha1')*normal(`xb')) if  `last'==1

    mlsum `lnfj'=`mylnf'

     *if (`todo'==0 |`lnfj'>=.)  exit
end


global My_panel personid
ml model d0 mrpr (xb: yvar= `covariates' ) /alpha0 /alpha 


.ml check

Test 1:  Calling mrpr to check if it computes log likelihood and
         does not alter coefficient vector...
         Passed.

Test 2:  Calling mrpr again to check if the same log likelihood value is
         returned...
         Passed.

Test 3:  Calling mrpr to check if 1st derivatives are computed...
         test not relevant for type d0 evaluators.

Test 4:  Calling mrpr again to check if the same 1st derivatives are
         returned...
         test not relevant for type d0 evaluators.

Test 5:  Calling mrpr to check if 2nd derivatives are computed...
         test not relevant for type d0 evaluators.

Test 6:  Calling mrpr again to check if the same 2nd derivatives are
         returned...
         test not relevant for type d0 evaluators.

------------------------------------------------------------------------------
Searching for alternate values for the coefficient vector to verify that mrpr
returns different results when fed a different coefficient vector:

Searching...
initial:       log likelihood =     -<inf>  (could not be evaluated)
searching for feasible values +

feasible:      log likelihood = -39456.325
improving initial values ++++......
improve:       log likelihood = -37414.699

continuing with tests...
------------------------------------------------------------------------------

Test 7:  Calling mrpr to check log likelihood at the new values...
         FAILED.
         Two different coefficient vectors resulted in equal log likelihood
         values of -37414.699.
         This does not prove there is a problem, but it suggests it.

two coefficient vectors:
           xb:        xb:        xb:        xb:        xb:        xb:         /:         /:
          did       sexe    mdefipc   agegroup  educgroup      _cons  alpha0  alpha1
r1          0          0          0          0          0   67.07219   69.31779   35.76148
r2          0          0          0          0          0          0          0          0
r(9);

No comments:

Post a Comment