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

Plot Recipes #581

Open
irregular-rhomboid opened this issue Nov 30, 2024 · 5 comments
Open

Plot Recipes #581

irregular-rhomboid opened this issue Nov 30, 2024 · 5 comments

Comments

@irregular-rhomboid
Copy link

irregular-rhomboid commented Nov 30, 2024

It just occurred to me that one feature from R that is missing from this package is the ability to get summary plots (https://www.rdocumentation.org/packages/stats/versions/3.6.2/topics/plot.lm), and I see no issues about it here.

This is totally doable without adding new dependencies via Extensions and RecipesBase/MakieCore. I'm tempted to make a small PR during the holidays.

Those would be mostly for standard OLS linear regression. Any other plots that would be nice to have?

@ajinkya-k
Copy link

this sounds like a great idea!

@irregular-rhomboid
Copy link
Author

Alright, I've gotten started with the Plots recipes, and I'm running into some obstacles

Below is the current result from the following code snippet (code here).

using GLM
using StatsPlots
using RDatasets

data = dataset("datasets", "trees")

l = lm(@formula(Height ~ Girth + Volume), data)

plot(
    residualplot(l),
    qqplot(l),
    scalelocationplot(l),
    residualsleverageplot(l),
    layout = (2,2),
    size = (700,500)
)

plotlmJulia
R equivalent:
lmplotsR

The issues I'm currently facing are that I'm trying to reuse the qqplot recipe from StatsPlots, but wasn't able to find a way to dispatch it for LinearModel using Plots recipes. The only thing that worked was directly defining a method for qqplot.

Annotations also seem finnicky, so I'll probably raise an issue in the Plots repo.

Those technical details aside, how close do we want to stay to R's plots? R adds smoothed lines through the plots, which would require another dependency to implement in Julia, and it's not clear to whether that is worth it. I also haven't implemented the labelling of potential outliers, which seems more useful.

Anyway, Merry Christmas.

@ajinkya-k
Copy link

Looks good!

@andreasnoack
Copy link
Member

This would be great to have. I'd have a preference for Makie based recipes, though.

@irregular-rhomboid
Copy link
Author

irregular-rhomboid commented Dec 26, 2024

I'd have a preference for Makie based recipes, though

Coming right up.

using GLM
using GLMakie
using RDatasets

data = dataset("datasets", "trees")

l = lm(@formula(Height ~ Girth + Volume), data)

begin
    fig = Figure()

    residualplot(fig[1,1], l)
    qqplot(fig[1,2], l)
    scalelocationplot(fig[2,1], l)
    residualsleverageplot(fig[2,2], l)
    fig
end

makie

Frustratingly, there is no clear way to specify axis labels and titles in Makie recipes. Right now, I'm using a hack that is quite brittle.

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

3 participants