DeclareDesign / estimatr

estimatr: Fast Estimators for Design-Based Inference
https://declaredesign.org/r/estimatr
Other
131 stars 20 forks source link

Clusters & Fixed effects sometimes crashes R #362

Open NickCH-K opened 4 years ago

NickCH-K commented 4 years ago

I was preparing a class example and came across the following issue:

library(wooldridge)
data(mathpnl)

# This works fine
fe_cluster <- lm_robust(math4 ~ expp + lunch, fixed_effects = ~distid, data = mathpnl)

# This works fine
fe_cluster <- lm_robust(math4 ~ expp + lunch, clusters = distid, data = mathpnl)

# This refuses to converge, takes up a quickly-expanding amount of memory, and if allowed to run for long enough, crashes the computer
fe_cluster <- lm_robust(math4 ~ expp + lunch, fixed_effects = ~distid, clusters = distid, data = mathpnl)

Since clusters & FE works fine in other cases, I'm guessing there's something data-specific about why this isn't converging. I haven't been able to pin down exactly what that is, but still it is quite odd.

I've had estimatr-crashes-R errors in a few contexts (as in previous issues I've filed); it would be nice if there was some sort of nonconvergence catcher so that estimatr would let itself give up rather than leaking and crashing R/the computer.

nfultz commented 4 years ago

One thing I would also add for usability