jacob-long / jtools

Tools for summarizing/visualizing regressions and other helpful stuff
https://jtools.jacob-long.com
GNU General Public License v3.0
164 stars 22 forks source link

Error in export_summs when model has many fixed effects #106

Closed nathanihoff closed 2 years ago

nathanihoff commented 3 years ago

I am trying to use export_summs with a model that has many fixed effects and am getting an error about mismatch in row numbers.

Here is a reproducible example, using the gapminder dataset, with the error pasted below.

mod <- lm(lifeExp ~ ., data = gapminder::gapminder)
jtools::export_summs(mod)
Error: Assigned data `x$coeftable[, lci_lab]` must be compatible with existing data.
x Existing data has 142 rows.
x Assigned data has 149 rows.
ℹ Only vectors of size 1 are recycled.
Backtrace:
In addition: Warning messages:
1: In base$std.error[!is.na(base$std.error)] <- x$coeftable[, "S.E."] :
  number of items to replace is not a multiple of replacement length
2: In base$statistic[!is.na(base$statistic)] <- x$coeftable[, stat_col] :
  number of items to replace is not a multiple of replacement length
3: In base[["p.value"]][!is.na(base$statistic)] <- x$coeftable[, "p"] :
  number of items to replace is not a multiple of replacement length

The huxreg command works with this model, producing a table with no error. (I need clustered standard errors, so I would prefer to use export_summs.)

jacob-long commented 2 years ago

Okay, I see the issue here. The coefficients for the continents are undefined so somewhere along the way I'm removing the undefined rows which is surprising some subsequent operation. I'll see how feasible it is to fix without pulling my hair out. I generally have tolerated errors when models have undefined coefficients.