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

estimate_fit #38

Closed
strengejacke opened this issue Jul 26, 2019 · 18 comments
Closed

estimate_fit #38

strengejacke opened this issue Jul 26, 2019 · 18 comments

Comments

@strengejacke
Copy link
Member

@DominiqueMakowski estimate_fit() was renamed to estimate_response(), if I'm not mistaken. However, the plot now looks a bit different (I guess this is intended).

Could you please check https://github.com/easystats/see if plots are OK?

@DominiqueMakowski
Copy link
Member

image

maaan that plot is sick 😍😅

but no it is not the intended one indeed. I'll correct the README

@strengejacke
Copy link
Member Author

ehm, you probably need to correct the plot-function directly. ;-)

But yes, the plot looks crazy, though I really like the idea of having CIs for the uncerntainty in the draws (though this was not the case in the previous plots, if unintended, cool! :-D)

@DominiqueMakowski
Copy link
Member

ehm, you probably need to correct the plot-function directly. ;-)

right, lemme look into it

@strengejacke
Copy link
Member Author

This is not urgend, since estimate isn't on CRAN yet, anyway.

@DominiqueMakowski
Copy link
Member

it was just about changing estimate_response to estimate_link

@strengejacke
Copy link
Member Author

I just saw that it was almost completely nonsense what I wrote... It's probably indeed something to be fixed in the readme!

@strengejacke
Copy link
Member Author

We don't have a plot-method for estimate_response() or estimate_link() yet...

@DominiqueMakowski
Copy link
Member

DominiqueMakowski commented Jul 26, 2019

We don't have a plot-method for estimate_response() or estimate_link() yet...

I know, but my guess is this would be tricky (although super awesome); we would have to detect from the data the appropriate aesthetics (if interactions, draws, ci etc)

I'd say for now we can live with partial support for estimate_contrasts, which is just there as an initial implementation of lighthouse plots. Maybe we can think about improving the support for estimate once we are at the CRAN stage

@strengejacke
Copy link
Member Author

image

maaan that plot is sick

but no it is not the intended one indeed. I'll correct the README

I really like this plot, we need to implement a function that produces this kind of plot! 😀

@strengejacke
Copy link
Member Author

@DominiqueMakowski what about adding some more plot functions for the modelbased package? I think especially modelbased is a package that would really benefit from plot functions.

@DominiqueMakowski
Copy link
Member

I agree I agree, and also making them more robust to different formulas and parameters. Maybe inspiration could be drawn for estimate_link and estimate_response from ggeffects, I wonder how you deal with all the possibilities.

And for estimate_means() and estimate_response(), i.e., in cases where x is a factor, I'd love to improve and reinforce lighthouse plots #12 but last time I hit the limits of my abilities. Maybe now I could give it a fresh look, but first let me finish with report 😅

@strengejacke
Copy link
Member Author

There are quite some examples for plots in the vignettes, maybe we can at least start with functions that create "simple" plots like those? Maybe over the next weeks...

@DominiqueMakowski
Copy link
Member

Yes I agree. Though we could start with improving/making more robust the plotting estimate_means() because I think it could be the most straightforward to support and also because it's the one for which there is less alternative for now (whereas for estimate_link people can still use ggeffecst for easy plotting :)

Or estimate_response() which by default returns the predicted value for each point of the dataset. Basically I see that the difference between estimate_link() and estimate_response(), when it comes for plotting, is that estimate_link would plot the link(s) only (which is the interest) whereas estimate_response would plot the predicted relationship with also the datapoints of the original data (something like this).

We could essentially have a common function with an argument add_datapoints, set to FALSE by default for estimate_link objects and to TRUE for estimate_response.

@bwiernik
Copy link
Contributor

bwiernik commented May 29, 2021

I am really missing plotting functions for estimate_predicted(). Producing a plot like this seems pretty fundamental for model visualization:

library(ggplot2)
model <- lm(mpg ~ factor(cyl) * wt, data = mtcars)
ggplot(modelbased::estimate_prediction(model, data = "grid"), aes(x = wt, color = factor(cyl), fill = factor(cyl))) + 
  geom_point(aes(y = mpg), data = insight::get_data(model)) +
  geom_ribbon(aes(ymin = CI_low, ymax = CI_high), alpha = .2, color = NA) +
  geom_line(aes(y = Predicted))

Created on 2021-05-30 by the reprex package (v2.0.0)

@bwiernik
Copy link
Contributor

@DominiqueMakowski Let me know if you'd like to spitball or discuss any design considerations for this

@DominiqueMakowski
Copy link
Member

absolutely, I'm currently thinking of a proof-of-concept for an updated approach to my long-term goal that a draft can be seen through one of the original idea for see that I had in mind (#37 (comment); #9) that I never had the chance to fully realize due to my issues with focus management.

Besides the longer-term part of this goal (to offer an ingredients&recipe based - instead of a pre-baked - approach to plotting), the shorter goal would be to expose the middle portion, between the object and the plot.

In other words, I'm thinking of a visualisation_recipe() method that would take an object and return the data ready to be plotted (for now I'm trying a list of "geom" layers information), which could be easily and robustly plotted by see (with all the options of customisation). Will open an issue in modelbased to discuss some ideas

@bwiernik
Copy link
Contributor

Feel free to move this comment over to your modelbased issue.

I'm not exactly following what you mean by "method that would take an object and return the data ready to be plotted". The estimate_predicted() result already contains the necessary information, no? predictor values, response value, fitted value with SE and CI?

I think a basic approach for estimate_predicted() would be to produce a plot with:

  1. x-axis
    1. If model has one predictor, the predictor
    2. If model has multiple predictors, default to the fitted value? or maybe the first predictor in the formula?
    3. Have an x argument that takes the name of a variable to map to the x axis.
  2. geom_line
    1. y = Fitted
  3. geom_ribbon
    1. ymin = CI_low, ymax = CI_high
  4. points
    1. If x is numeric, geom_point(aes(y = response))
    2. If x is factor or ordered, geom_jitter(aes(y = response), height = 0, width = (length(levels(x)) - 1) / (4 * length(levels(x))))
  5. other aeshetics
    1. Arguments for shape, color, alpha, linetype, facet, etc. that pass these along

Then, we apply nice see defaults. If a user wants more customization, they can take the resulting ggplot and add more layers.

@IndrajeetPatil
Copy link
Member

Closed in favor of easystats/modelbased#110

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

No branches or pull requests

4 participants