yellowbrick icon indicating copy to clipboard operation
yellowbrick copied to clipboard

Diagnostic Plots for Linear Regression Analysis

Open pkaf opened this issue 3 years ago • 4 comments

If not already considered or being developed it would be neat to have some standard diagnostic plots for linear regression analysis mainly

a. residual vs fitted b. normal q-q c. scale-location d. residual vs leverage

as shown in https://data.library.virginia.edu/diagnostic-plots/. Example plots Screen Shot 2022-01-25 at 8 53 42 pm Screen Shot 2022-01-25 at 8 53 48 pm Screen Shot 2022-01-25 at 8 53 53 pm Screen Shot 2022-01-25 at 8 54 00 pm

I am happy to PR.

pkaf avatar Jan 25 '22 09:01 pkaf

I will love to hear your thought on ^^ @bbengfort .

pkaf avatar Jan 25 '22 09:01 pkaf

@pkaf We'd certainly be open to more regression analysis tools or adaptations of our current tools to support these types of analyses.

The ResidualsPlot is currently plotted against the fitted value, so I think that's what plot 1 is - it also has the option to have a Q-Q plot alongside it, which I think is plot 2. Perhaps that plot could be modified to plot the residuals against actual value instead of the predicted value?

Scale-location vs fitted values (your third plot) also seems like it might be an adaptation of the ResidualsPlot to standardize the residuals rather than using the raw residuals - this would be a great param to add!

We also have a CooksDistance visualizer, which may be related to your last plot of standardized residuals to Leverage, or might be a building block towards that visualization.

If the ResidualsPlot is not sufficient, perhaps you could look into creating a ResidualsDiagnostics visualizer that plots all four of these graphs in 4 separate axes? We haven't done a lot of multi-axes plotting, but this could be a good start toward that.

bbengfort avatar Feb 19 '22 23:02 bbengfort

@bbengfort recently, I pushed an example depicting above graphs in statsmodels https://www.statsmodels.org/devel/examples/notebooks/generated/linear_regression_diagnostics_plots.html . We can adapt it here too.

pkaf avatar Mar 15 '22 01:03 pkaf

@pkaf awesome - we welcome any PRs that you might open for Yellowbrick!

bbengfort avatar May 21 '22 18:05 bbengfort