estimatr icon indicating copy to clipboard operation
estimatr copied to clipboard

intercept only w/ fixed effects

Open graemeblair opened this issue 5 years ago • 2 comments

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 

graemeblair avatar May 25 '19 18:05 graemeblair

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?

lukesonnet avatar May 29 '19 16:05 lukesonnet

Decision: can I just have a smarter error?

I don't really want to support this.

lukesonnet avatar Sep 12 '19 16:09 lukesonnet