DeclareDesign / estimatr

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

Starprep list #339

Closed jaspercooper closed 4 years ago

jaspercooper commented 4 years ago

Thanks to @notanastronomer for the heads up on this! I've edited her MWE below a bit.

People often like to carry around lists of lm fits, e.g. using lapply over a list of formulas. Currently, these are not handled by starprep().

library(estimatr)
library(stargazer)
a <- lm(mpg ~ cyl, mtcars)
b <- lm(mpg ~ cyl + disp, mtcars)
c <- lm(mpg ~ cyl + disp + hp, mtcars)

abc <- list(a, b, c)
ab <- list(a, b)

# Works
starprep(a,b,c)
# Breaks
starprep(abc)
# Works
starprep(a,b)
# Breaks
starprep(ab)

This behavior worries me a bit, as I can see people doing something like this:

stargazer(a, b, se = starprep(ab), type = "text")

Expecting to get this:

stargazer(a, b, se = starprep(a,b), type = "text")

I've written an admittedly very quick and dirty fix in this PR, in case it's helpful to build off.

jaspercooper commented 4 years ago

@nfultz addressed the two comments on last commit, please lmk if this seems clearer and less error-prone

graemeblair commented 4 years ago

Requesting review @nfultz @lukesonnet. I merged in Luke's PR to this one.

nfultz commented 4 years ago

LGTM.