pingouin icon indicating copy to clipboard operation
pingouin copied to clipboard

Get residuals from anova

Open jankaWIS opened this issue 3 years ago • 1 comments

Hi, recently I have been playing with statsmodels and pinguin and I have not been able to figure out how to get residuals from pinguin. What I mean is (taking your example):

df = pg.read_dataset('anova2')
# Pinguin
df.anova(dv="Yield", between=["Blend", "Crop"]).round(3)
# statsmodels
model = ols( 'Yield ~ C(Blend) + C(Crop) + C(Blend):C(Crop)', df).fit()
aov_table = anova_lm(model, typ=2)
res = model.resid 
pg.qqplot(res, dist='norm')

If I would like to plot the residuals, how can I do that without calling model.resid?

Thanks. image

jankaWIS avatar Aug 17 '20 14:08 jankaWIS

Hi @jankaWIS,

Thanks for opening the issue. Pingouin does not currently return the residuals for ANOVA models (it does only in the linear_regression function). I don't think it should be too hard to implement though. I'm jammed up right now but can take a look at that within the next couple of months. Or, if you'd like to submit a pull request, please feel free to do so!

Best, Raphael

raphaelvallat avatar Aug 17 '20 16:08 raphaelvallat