Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Retain model metadata (N, log.lik, R2, etc) #158

Open
1 of 3 tasks
grantmcdermott opened this issue Sep 29, 2020 · 1 comment · May be fixed by #168
Open
1 of 3 tasks

Retain model metadata (N, log.lik, R2, etc) #158

grantmcdermott opened this issue Sep 29, 2020 · 1 comment · May be fixed by #168

Comments

@grantmcdermott
Copy link

Please specify whether your issue is about:

  • a possible bug
  • a question about package functionality
  • a suggested code or documentation change, improvement to the code, or feature request

Background

In tidymodels/broom#909, I bundled some broom tidiers for margins objects. The tidy.margins method is straightforward. However, a glance.margins method proves more difficult, because none of the original model metadata that glance() requires are retained in the margins objects. My hackish solution involves accessing the original model call from the margins object attributes, rerunning this original model, and then calling glance on said original model. This is clearly inefficient and becomes increasingly expensive as we start dealing with large models.

As an aside: A glance.margins method is required by modern table generating packages like modelsummary and huxtable. So we need to find a way to include it if we want to produce nice regression tables with marginal effects. See here.

Possible solutions

I think there are two possible solutions here. They are not mutually exclusive.

  1. Add an option for saving the original model object (perhaps as an attribute) as part of the margins return object.
  2. Include a minimal set of model meta data tags (again, perhaps as attributes) as part of the margins return object, regardless of whether the original model object was retained above or not.

FWIW, we recently faced the same problem with lmtest::coeftest(). Achim implemented both of the above solutions and so I was able to bundle a glance.coeftestmethod that takes advantage of that. Result: More nice regression tables!

Thoughts?

@leeper
Copy link
Owner

leeper commented Jan 10, 2021

I think we can just add the whole model object as an attribute. Want to send a PR?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants