estimatr
estimatr copied to clipboard
intercept only w/ fixed effects
When you want to run a model with fixed effects and no covariates, it works if you run in the outcome formula but not with an intercept in the outcome formula and the FE defined in fixed_effects
. Is this expected? At least a better error seems called for.
library(DeclareDesign)
dat <- fabricate(
countries = add_level(N = 150, country_fe = runif(N, 1, 10)),
years = add_level(N = 25, year_shock = runif(N, 1, 10), nest = FALSE),
obs = cross_levels(
by = join(countries, years),
y = country_fe + year_shock + rnorm(N, 0, 2)
)
)
fit <- lm_robust(y ~ 1, fixed_effects = ~ as.factor(countries), data = dat)
Error in dimnames(x) <- dn :
length of 'dimnames' [2] not equal to array extent
This can definitely be improved, but currently it would return no coefficients, so it would be a bunch of infrastructure to return a bunch of empty objects. Do we want to support this use case?
Decision: can I just have a smarter error?
I don't really want to support this.