sergiocorreia / ppmlhdfe

Poisson pseudo-likelihood regression with multiple levels of fixed effects
http://scorreia.com/software/ppmlhdfe/
MIT License
63 stars 13 forks source link

error 9003 in Stata, mu has infinite values on iteration 10; #13

Closed alessiolombini closed 3 years ago

alessiolombini commented 3 years ago

Dear Sergio Correia,

I am trying to run the manual RESET Test and I keep getting the following error:

.  qui asdoc ppmlhdfe gvc_total regulatory_distance applied_tariff dist_w rta if exp
> !=imp, a(exp_time imp_time pair_id) vce(cluster pair_id) replace

. predict fit, xb
(222,075 missing values generated)

. generate fit2 = fit^2
(222,075 missing values generated)

.  asdoc ppmlhdfe gvc_total regulatory_distance applied_tariff dist_w rta fit2  
> if exp!=imp, a(exp_time imp_time pair_id) vce(cluster pair_id) replace
warning: dependent variable takes very low values after standardizing (4.3599e-2
> 1)
Iteration 1:   deviance = 1.6027e+11  eps = .         iters = 6    tol = 1.0e-04
>   min(eta) =  -6.95  P   
Iteration 2:   deviance = 5.8990e+10  eps = 1.72e+00  iters = 9    tol = 1.0e-04
>   min(eta) =  -9.40      
Iteration 3:   deviance = 2.1738e+10  eps = 1.71e+00  iters = 8    tol = 1.0e-04
>   min(eta) = -12.59      
Iteration 4:   deviance = 8.0361e+09  eps = 1.71e+00  iters = 8    tol = 1.0e-04
>   min(eta) = -14.38      
Iteration 5:   deviance = 4.2509e+43  eps = 5.29e+33  iters = 8    tol = 1.0e-04
>   min(eta) = -274.18      
Iteration 6:   deviance = 1.5638e+43  eps = 1.72e+00  iters = 43   tol = 1.0e-04
>   min(eta) = -275.69      
Iteration 7:   deviance = 1.2081e+44  eps = 6.73e+00  iters = 32   tol = 1.0e-04
>   min(eta) = -46.21   S  
Iteration 8:   deviance = 4.4444e+43  eps = 1.72e+00  iters = 47   tol = 1.0e-04
>   min(eta) = -47.68      
Iteration 9:   deviance = 0.0000e+00  eps = 0.00e+00  iters = 162  tol = 1.0e-04
>   min(eta) =      .      
mu has infinite values on iteration 10; aborting
r(9003);

Would you know the reason why this error occurs? Thank you in advance for your time

tomzylkin commented 3 years ago

Try adding one of the following options:

If I had to guess, the issue looks like bad starting values. Using "guess(ols)" or "start_inner_tol(1e-2)" seem like the most likely fixes, but the others are worth trying. If none of these works, you could try sharing (some of) your data so we can replicate the issue and figure out a fix.

alessiolombini commented 3 years ago

Dear Mr Tom,

Thank you very much for your prompt reply and your help. They are both appreciated. I tried the approaches you suggested, but unfortunately, none of them seems to fix the problem. If it is still possible, I share the data in dropbox since they are quite heavy.

https://www.dropbox.com/s/y3hindyo0xr69yk/Thesis%20Stata-dataset%20WIP%20-%20bilateral.zip?dl=0

Would you please tell me if you think you can do something or whether other approaches are available? Thank you in advance for your time and your patience

tomzylkin commented 3 years ago

I found the solution. I did not realize this but step halving is not turned on by default. To activate it, add "use_step_halving(1)" as an option. Based on my tests it solves the problem.

I also have two questions about the variable dist_w

alessiolombini commented 3 years ago

Dear Tom,

I sincerely thank you, this issue has been puzzling me for days. You are right, I admittedly did not notice that dist_w was collinear with the pair FE. Therefore, I replace it with the log of bilateral distance multiplied with years dummies (obtaining the ln_distance_2005 ... ln_distance_2015). I saw that some papers included distance measurement in this way and it does not get collinear with fixed effects.

Thank you again for your valuable help Wishing you a pleasant and productive day