You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
FWIW, I have done this in modelsummary and it is quite tricky to do with generality. I don't think we want to support all possible packages, and a type that only supports glm and base fitting functions would be pretty bad and uncompetitive.
Thanks @vincentarelbundock; definitely interested in your experiences here (I was hoping you'd see this issue and chime in). FWIW I was busy writing down my own thoughts before your reply, so here they are for posterity:
I've been wondering whether we should support a "coefplot" type (i.e., as convenience layer which could then get passed to "pointrange", "errorbar", or "ribbon"). We would obviously need to decide on the scope and limitations, including supported model engines (lm as default, etc.) But in principle I wonder whether we could support any model that has both coef and confint methods?
Pseudo-code syntax would be something like:
plt(mpg~wt|cyl, mtcars, type="coefplot") # group coefficient plot with "dodged" intervals
plt(mpg~wt, mtcars, facet=~cyl, type="coefplot") # facet version
plt(am~wt, mtcars, type= type_coefplot(model=glm, args=list(family='binomial'), style='errorbar')) # customized ex.
Alternatively (or in addition), it might be worth PRing tinyplot methods for the broom and parameters repos.
One possibility would be a Suggests on parameters package. Not sure you want that.
Yeah, I wouldn't do that on our side. But we could propose a tinyplot.parameters_model (EDIT) method on their side that would kick in if both packages are loaded.
Yeah, frankly I'm not a fan of this. That's wrapping a lot of operations in a single function. We have some loess stuff already, but specifying a whole regression model inside tinyplot?! I don't think plt() should become a general model-fitting interface.
And I'm not sure I understand what .tinyplot S3 method is supposed to do. What object class is parameters expecting to process? AFAIK, there isn't a tinyplot object we can pass to a parameters_model function.
And I'm not sure I understand what .tinyplot S3 method is supposed to do. What object class is parameters expecting to process? AFAIK, there isn't a tinyplot object we can pass to a parameters_model function.
Ugh, sorry rush typing. I meant tinyplot. parameters_model, similar to how @zeileis implemented a tinyplot.zoo method recently. (WIll fix my previous post to avoid confusion).
(Seriously, though. LMK if there's interest and we can think about respective tinyplot.modelsummary and tinyplot.coeftest methods. But I would expect these to live in your respective repos rather than here.)
modelsummary functions only return tinytable or ggplot2 objects, so there isn't a class modelsummary, unfortunately.
There is a modelplot() function for coefficient plots, with some useful features: rename/reorder/omit coefficients, insert reference levels, multiple models side-by-side, robust standard errors, facetting, etc. I think a useful coef plot function probably has to implement many of those features. For reference, here's the code:
Given that there is no modelsummary class object, the suggestion above would boil down to implementing an alternative plotting backend, in addition to ggplot2. As previously discussed for marginaleffects here, I'm unlikely to do this in the short term, but may consider in the future.
The main issue is that tinyplot works less well for "incremental" modification workflows. When users plot outputs directly from modelsummary or marginaleffects functions, I can't offer all the arguments to control everything (ex: axis labels and styles). So it's really powerful to be able to tweak incrementally with ggplot2.
IMHO, tinyplot shines when the user can make the main call themselves, rather than delegate to a package function (of course, there could be argument passing, but ... is already used heavily in both packages, which complicates things a bit).
Secondary issue is duplication and maintenance of two plotting backends, obviously.
I see. I didn't realize that there isn't a dedicated class which makes it indeed a bit more complicated. And for those who want to combine modelsummary and tinyplot it would probably currently be best to use modelplot(..., draw = FALSE) and use that as input to tinyplot().
plt(am ~ wt, mtcars, type = type_coefplot(model = glm, args = list(family = 'binomial'), style = 'errorbar')) # customized ex.
Yeah, frankly I'm not a fan of this. That's wrapping a lot of operations in a single function. We have some loess stuff already, but specifying a whole regression model inside tinyplot?! I don't think plt() should become a general model-fitting interface.
And I'm not sure I understand what .tinyplot S3 method is supposed to do. What object class is parameters expecting to process? AFAIK, there isn't a tinyplot object we can pass to a parameters_model function.
For what it's worth, I read through this issue as I do lot's of regression work and I would agree with this opinion. It would be very rare for me to decide to skip straight to plotting when working with a model. I would expect to first write my model, then check summary/performance/fit, then save coefficients, and only then would I decide to plot those coefficients. All that to say, this seems like a pretty substantial undertaking (complexity wise) vs what appear to be the goals of this package.
Thanks the feedback and discussion everyone. Let's see if we can implement some downstream tinyplot.<packge> methods to support this kind of functionality. But closing on this then.
Activity
vincentarelbundock commentedon May 1, 2025
FWIW, I have done this in
modelsummaryand it is quite tricky to do with generality. I don't think we want to support all possible packages, and a type that only supportsglmand base fitting functions would be pretty bad and uncompetitive.vincentarelbundock commentedon May 1, 2025
One possibility would be a Suggests on
parameterspackage. Not sure you want that.grantmcdermott commentedon May 1, 2025
Thanks @vincentarelbundock; definitely interested in your experiences here (I was hoping you'd see this issue and chime in). FWIW I was busy writing down my own thoughts before your reply, so here they are for posterity:
I've been wondering whether we should support a
"coefplot"type (i.e., as convenience layer which could then get passed to"pointrange","errorbar", or"ribbon"). We would obviously need to decide on the scope and limitations, including supported model engines (lmas default, etc.) But in principle I wonder whether we could support any model that has bothcoefandconfintmethods?Pseudo-code syntax would be something like:
Alternatively (or in addition), it might be worth PRing
tinyplotmethods for the broom and parameters repos.grantmcdermott commentedon May 1, 2025
Yeah, I wouldn't do that on our side. But we could propose a
tinyplot.parameters_model(EDIT) method on their side that would kick in if both packages are loaded.zeileis commentedon May 1, 2025
Same for
modelsummaryandcoeftestobjects?vincentarelbundock commentedon May 1, 2025
Yeah, frankly I'm not a fan of this. That's wrapping a lot of operations in a single function. We have some loess stuff already, but specifying a whole regression model inside
tinyplot?! I don't thinkplt()should become a general model-fitting interface.And I'm not sure I understand what
.tinyplotS3 method is supposed to do. What object class isparametersexpecting to process? AFAIK, there isn't atinyplotobject we can pass to aparameters_modelfunction.vincentarelbundock commentedon May 1, 2025
Also, the natural workflow is:
It would be weird for
parametersto implement something that is "downstream" from them.grantmcdermott commentedon May 1, 2025
Ugh, sorry rush typing. I meant
tinyplot. parameters_model, similar to how @zeileis implemented atinyplot.zoomethod recently. (WIll fix my previous post to avoid confusion).grantmcdermott commentedon May 1, 2025
You guys are the maintainers, you tell me!
:-)
(Seriously, though. LMK if there's interest and we can think about respective
tinyplot.modelsummaryandtinyplot.coeftestmethods. But I would expect these to live in your respective repos rather than here.)vincentarelbundock commentedon May 1, 2025
modelsummaryfunctions only returntinytableorggplot2objects, so there isn't a classmodelsummary, unfortunately.There is a
modelplot()function for coefficient plots, with some useful features: rename/reorder/omit coefficients, insert reference levels, multiple models side-by-side, robust standard errors, facetting, etc. I think a useful coef plot function probably has to implement many of those features. For reference, here's the code:https://github.com/vincentarelbundock/modelsummary/blob/main/R/modelplot.R
Given that there is no
modelsummaryclass object, the suggestion above would boil down to implementing an alternative plotting backend, in addition toggplot2. As previously discussed formarginaleffectshere, I'm unlikely to do this in the short term, but may consider in the future.The main issue is that
tinyplotworks less well for "incremental" modification workflows. When users plot outputs directly frommodelsummaryormarginaleffectsfunctions, I can't offer all the arguments to control everything (ex: axis labels and styles). So it's really powerful to be able to tweak incrementally withggplot2.IMHO,
tinyplotshines when the user can make the main call themselves, rather than delegate to a package function (of course, there could be argument passing, but...is already used heavily in both packages, which complicates things a bit).Secondary issue is duplication and maintenance of two plotting backends, obviously.
zeileis commentedon May 1, 2025
I see. I didn't realize that there isn't a dedicated class which makes it indeed a bit more complicated. And for those who want to combine
modelsummaryandtinyplotit would probably currently be best to usemodelplot(..., draw = FALSE)and use that as input totinyplot().kscott-1 commentedon May 5, 2025
For what it's worth, I read through this issue as I do lot's of regression work and I would agree with this opinion. It would be very rare for me to decide to skip straight to plotting when working with a model. I would expect to first write my model, then check summary/performance/fit, then save coefficients, and only then would I decide to plot those coefficients. All that to say, this seems like a pretty substantial undertaking (complexity wise) vs what appear to be the goals of this package.
grantmcdermott commentedon May 5, 2025
Thanks the feedback and discussion everyone. Let's see if we can implement some downstream
tinyplot.<packge>methods to support this kind of functionality. But closing on this then.