Closed mattysimonson closed 3 months ago
As I finally look into this, I think the solution turns out to be relatively straightforward. Normally, a list of models should be handled by plot_coefs()
smoothly. But since the "fixest_multi" object doesn't identify itself as a list, for probably good reasons, plot_coefs()
doesn't know it's a list and treats it like it's a single model. While I tend to prefer general solutions to specific ones, I am just going to add a check for "fixest_multi" objects and treat them like lists, which seems to work.
library(fixest)
library(jtools)
est_mult <- feols(c(Ozone, Solar.R) ~ Wind + Temp + csw0(Wind:Temp, Day), airquality)
plot_coefs(est_mult)
The
fixest
package which came out last year has been a real boon to researchers using regression, and for the most part, it plays well withjtools
(this is important because whilefixest
can make beautiful tables, it relies on base R for plotting which is a pain for those of us used to ggplot2). A key feature offixest
is that you can run multiple models at once (e.g., on a split sample, or swapping out different outcome variables with the same set of preditors). When you do this, the results get saved as afixest_multi
object, which, from what I can tell, appears to be a list of individualfixest
model objects. Theplot_summs
function can handle individualfixest
model objects just fine, but if they're stored in afixest_multi
, then you have to break them out manually:modeling_3_outcomes <- fixest::feglm( c(support, favorability, trust) ~ income + gender + age, data = mydata) plot_summs(modeling_3_outcomes[[1]], modeling_3_outcomes[[2]], modeling_3_outcomes[[3]]
and realistically, you'd want to rename them after their DVs so the legend doesn't label each color as model 1, model 2, model 3:
plot_summs(support = modeling_3_outcomes[[1]], favorability = modeling_3_outcomes[[2]], trust = modeling_3_outcomes[[3]]
Ideally, I would be able to simply input
plot_summs(my_fixest_multi)
andplot_summs
would unpack this list and extract the model names (e.g. the DV names) automatically.There are probably other ways to make the integration of these two packages more seamless, but this is the first one that comes to mind, and it seems like reasonably low-hanging fruit to start with (at least the unpacking part is; less sure how easy it is to extract the DV names).