[R-sig-ME] Non-zero residual sums, correlation structure (nlme)

Adam Clark @d@m@tc|@rk @end|ng |rom gm@||@com
Mon Nov 6 14:03:26 CET 2023


Hi all,

My colleague and I were working through some examples in the Pinheiro and
Bates book, and ran into a bit of a puzzle. When we try fitting a simple
intercept-only model to the default Orthodont dataset that includes a
correlation structure, the residuals of the model no longer add up to 0 -
rather, they diverge from zero quite a bit. This divergence seems to be
much larger than we would expect simply from finite computational error.

I'm sure that the answer is that I'm missing something fundamental about
what the correlation structure is doing to the model residuals, but after
quite a bit of Googling, I'm none the wiser.

Can anyone suggest a source that I could read (or an answer) that could
explain this behaviour?

Many thanks,
Adam Clark


### example code
require(nlme)
data(Orthodont)
## 1. fit mixed model
mod_lme = lme(distance ~ 1, Orthodont, random = ~1|Subject)
resid_lme = Orthodont$distance-predict(mod_lme, level = 0)

# raw residuals
sum(resid_lme) # ~0

# normalised residuals
sum(residuals(mod_lme, type = "n")) # ~0


## 2. fit mixed model with correlation structure
mod_lme2 = lme(distance ~ 1, Orthodont, random = ~1|Subject, correlation =
corSymm(form = ~1|Subject))
resid_lme2 = Orthodont$distance-predict(mod_lme2, level = 0)

# raw residuals
sum(resid_lme2) # -11.9!

# normalised residuals
sum(residuals(mod_lme2, type = "n")) # 17.8!

-- 
Adam Thomas Clark
Asst. Professor
Karl-Franzens-Universität Graz
Institut für Biologie
www.adamclarktheecologist.com

	[[alternative HTML version deleted]]



More information about the R-sig-mixed-models mailing list