Feature request: Implementing `fitstat` for `fixest_multi`

Open
#466 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
48/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Stale
Tech stack
r
Domain
data

Research direction

Start by reading the existing fitstat behavior and the fixest_multi methods for coef, confint, coeftable, and models. Reproduce the issue's feols split example, compare fitstat(m, "f", simplify = TRUE) with the manual lapply and rbind workflow, and make the built-in result provide per-model statistics aligned with models(m).

Written by the indexing model from the issue text.

Description

It seems to me that it would be useful to be able to call fitstat on fixest_multi objects, and get a data frame with the statistics for each model. This would be analogous to/consistent with how coef, confint, coeftable, etc. currently behave. I imagine it looking something like this:

library(fixest)

m <- feols(Sepal.Length ~ Sepal.Width, iris, split = ~Species)
fitstat(m, "f", simplify = TRUE)
#>   id sample.var     sample     stat            p df1 df2
#> 1  1    Species     setosa 58.99373 6.709843e-10   1  48
#> 2  2    Species versicolor 18.35169 8.771860e-05   1  48
#> 3  3    Species  virginica 12.68707 8.434625e-04   1  48

We could also produce this output manually like this:

model_stats <- m |>
  lapply(fitstat, "f", simplify = TRUE) |>
  lapply(as.data.frame) |>
  do.call(rbind, args = _)
rownames(model_stats) <- NULL
cbind(models(m), model_stats)

But this relies on some assumptions about the internals of fixest_multi (specifically that lapply(m) lists the models in the same order as models(m)), which made me feel a bit uneasy. And it would of course be nice to have this built in 😁

Dominant language
R
Stars
464
Forks
82
Avg merge
2d 7h
Merged PRs (30d)
12

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from lrberge/fixest

All issues in lrberge/fixest

Similar issues

More R issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.