sergiocorreia / ppmlhdfe

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

boottest error: Could not generate scores from ppmlhdfe with predict #4

Closed grlju closed 4 years ago

grlju commented 4 years ago

Hi Sergio,

Thanks a lot for your great work!

I am trying to get the boottest command to work but without much luck. Of course, I might be doing something wrong. Illustration using the sample data from the ppmlhdfe help file (I remove the interaction in the fixed effects because my use case has no interactions):

use "http://fmwww.bc.edu/RePEc/bocode/e/EXAMPLE_TRADE_FTA_DATA" if category=="TOTAL", clear egen imp = group(isoimp) egen exp = group(isoexp) ppmlhdfe trade fta, a(year imp exp) cluster(imp exp) d boottest fta

This is what I get:

. boottest fta (bootcluster(imp exp) assumed) Re-running regression with null imposed. option constraints not allowed Error imposing null. Perhaps ppmlhdfe does not accept the constraints(), from(), and iterate() options, as needed. r(198);

So I tried this:

boottest fta, nonull

And I get:

. boottest fta, nonull (bootcluster(imp exp) assumed) Could not generate scores from ppmlhdfe with predict.

Someone posted the same question on statalist, but did not get a response yet: https://www.statalist.org/forums/forum/general-stata-discussion/general/1500935-ppmlhdfe-and-bootstrap

Am I doing something wrong?

Thanks a lot, Greg

sergiocorreia commented 4 years ago

Hi Greg,

There's a way to run boottest after ppmlhdfe, but I'm not 100% sure of how correct is that; @droodman might be able to provide more informed advice. Anyways, you just need to make boottest think you are running reghdfe:

sysuse auto
ppmlhdfe price weight, a(turn)

* this fails
boottest weight, nograph

* this works
estadd local cmd = "reghdfe", replace
estadd scalar converged = ., replace
boottest weight, nograph

A few notes:

assert "`e(cmd)'" == "ppmlhdfe"
assert "`e(converged )'" == "1"
estadd local cmd = "reghdfe", replace
estadd scalar converged = ., replace
boottest weight, nograph
estadd local cmd = "ppmlhdfe", replace
estadd scalar converged = 1, replace

Best, Sergio

droodman commented 4 years ago

I had not heard of ppmlhdfe before this. It looks very cool and I was struck by the claim in the help file that it works with boottest.

In fact, I think I cannot give more informed advice as I am not fully versed in the methods of ppmlhdfe. Sergio, I think you are better positioned to say whether doing the wild bootstrap on the converged results from ppmlhdfe as if they were from OLS/reghdfe is equivalent to running the entire algorithm on wild-bootstrapped simulated data sets. I would be surprised if this is the case; at any rate, I am not in a position to be sure.

It does seem like if help file is going to say "can be used in combination with boottest" (which I certainly would like to be true) that it would be best to give users an example and maybe explain somewhere why this works.

After reghdfe with one-way fixed effects (which is all boottest can handle), boottest effectively reruns the OLS estimate itself, both for the original data and all the simulated data sets. Is that what's needed here? --David

grlju commented 4 years ago

Thanks, Sergio and David, for the clarifications.

It does solve the issue about how to run bootest after the command, thus I will close the issue.

In my use case, I don't think that estimating my models using OLS is appropriate, but I also have multiple fixed effects, so it will not work either way.

Thanks again, Greg

torinmcfarland commented 1 year ago

Hello,

The help file for ppmlhdfe at last check states boottest can be used, and various forums point to this thread as proof. Is this thread definitive / the help file correct, or is it correct to follow "boottest does not support ppmlhdfe" from Statalist? (https://www.statalist.org/forums/forum/general-stata-discussion/general/1648782-using-ppmlhdfe-with-control-function-approach-and-boottest). I would also like to adopt the ppmlhdfe control function approach with group clustering on individual data.

Thank you and best regards, Torin

droodman commented 1 year ago

Yeah, boottest does not support pplmhdfe. To support it, it would need to be able to re-run the estimator hundreds of times, and it can't.