Plot Recipes
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?
this sounds like a great idea!
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)
)
R equivalent:
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.
Looks good!
This would be great to have. I'd have a preference for Makie based recipes, though.
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
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.