amrei-stammann / alpaca

An R-package for fitting glm's with high-dimensional k-way fixed effects
43 stars 6 forks source link

automatically remove collinear variables #15

Open thorek1 opened 3 years ago

thorek1 commented 3 years ago

Hi,

it would be great to have alpaca automatically remove collinear variables. See the issue here and how fixest tackles it:

n <- 100

dat <- data.frame(y = runif(n) > .5,
                  x1 = rnorm(n),
                  x2 = rnorm(n) + 2,
                  x2 = (rnorm(n) + 2) / 2,
                  x3 = sample(LETTERS[1:3],n, T))

library(alpaca)

alpaca::feglm(y ~ x1 + x2 | x3,dat)
alpaca::feglm(y ~ x1 + x2 | x3,dat)
alpaca::feglm(y ~ x1 + x2 * x3 | x3,dat)
#Error in qr.solve(X, z, epsilon) : singular matrix 'a' in solve

library(fixest)

fixest::feglm(y ~ x1 + x2 | x3,dat)
fixest::feglm(y ~ x1 + x2 | x3,dat)
fixest::feglm(y ~ x1 + x2 * x3 | x3,dat)
# Variables 'x3B' and 'x3C' have been removed because of collinearity (see $collin.var).

Thore

amrei-stammann commented 3 years ago

Thanks, it is on our agenda.