I am concerned that resid_panel might be improperly calculating Pearson residuals for lme models with heterogeneous variances. I believe the issue lies on line 39 of the helper_resid.R script. A short reproducible example:
library(agridat)
library(nlme)
library(ggResidpanel)
data('graybill.heteroskedastic')
str(graybill.heteroskedastic)
fit1 <- lme(fixed = yield ~ gen,
data = graybill.heteroskedastic,
random = ~1|env)
# With homogeneous variances, these are identical:
resid_panel(fit1, type = 'pearson')
resid_auxpanel(residuals = resid(fit1, type = 'pearson'),
predicted = predict(fit1))
fit2 <- lme(fixed = yield ~ gen,
data = graybill.heteroskedastic,
random = ~1|env,
weights = varIdent(form = ~1|gen))
# With heterogeneous variances, these are not:
resid_panel(fit2, type = 'pearson')
resid_auxpanel(residuals = resid(fit2, type = 'pearson'),
predicted = predict(fit2))
I am concerned that
resid_panel
might be improperly calculating Pearson residuals forlme
models with heterogeneous variances. I believe the issue lies on line 39 of the helper_resid.R script. A short reproducible example: