Open rferrali opened 6 hours ago
That's an interesting use-case.
My guess is that the easiest (or more "direct") implementation would be to write a function that accepts the same list of models, and then automatically builds the required input for the add_rows
argument.
So you would just do this preprocessing, and then call modelsummary()
as usual.
That's what I'm currently doing. The problem with this approach is that it doesn't handle formatting gracefully, especially when displaying standard errors in parenthesis underneath (I typically use tex output, so that function basically wraps all numbers within \num{}, and adds parentheses; but then, it doesn't display well when using HTML output, e.g., during development). Of course, one could add parameters to the function to tweak the output, but in the end, all the parameters set in modelsummary (e.g., stars, number of significant digits, ...) would need to be re-entered. I guess the main challenge is to manage to inherit the modelsummary parameters without having the user re-type them.
On Wed, Nov 27, 2024 at 4:53 PM Vincent Arel-Bundock < @.***> wrote:
That's an interesting use-case.
My guess is that the easiest (or more "direct") implementation would be to write a function that accepts the same list of models, and then automatically builds the required input for the add_rows argument.
So you would just do this preprocessing, and then call modelsummary() as usual.
— Reply to this email directly, view it on GitHub https://github.com/vincentarelbundock/modelsummary/issues/838#issuecomment-2504228314, or unsubscribe https://github.com/notifications/unsubscribe-auth/AGL2RAIW33O7OLUKEJILNCT2CXTJNAVCNFSM6AAAAABSS7I2PWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDKMBUGIZDQMZRGQ . You are receiving this because you authored the thread.Message ID: @.***>
-- Romain Ferrali Postdoctoral associate NYU Abu Dhabi UAE O: +971 50 675 4347
Hard to say without a Minimal Working Example (emphasis on the minimal since the description is very complex).
Thanks for writing this great package -- and the also great
marginaleffects
package. I often display OLS estimates of causal effects, in subgroups. So, my models often look like y ~ treatment + controls, and then y ~ treatment * subgroup_factor + controls.I typically want to report (1) treatment + treatment:subgroup_factor_1, treatment + treatment:subgroup_factor_2, ... at the bottom of the table, as well as (2) the mean outcome of the control group, by subgroup. So
mean(y[subgroup_factor == 1])
, ...For (1),
marginaleffects::hypotheses
is the go to to conduct the hypothesis test. I then format this as the main estimates; i.e., estimate^stars, and (SD) right below. However, displaying using theadd_rows
argument is quite tedious.For (2), I usually either use
add_lines
orglance_custom
. Typically,add_lines
rather thanglance_custom
as the subgroups vary from table to table. So, setting the setting globally usingglance_custom
is a bit dangerous.I wonder how we could do better? I don't think that this use case is general enough to be an additional argument of
modelsummary
. Perhaps using another function that could be piped aftermodelsummary
?Happy to write this as a separate package, but I would appreciate hearing thoughts before getting started.