[R] lme, diagnostic plots and missing values
Mark Wardle
mark at wardle.org
Tue Sep 18 14:18:23 CEST 2007
Dear all,
I'm using lme() to great success in modelling some of my clinical
data. It's saved me hours so I'm very grateful to have such powerful
tools!
I'm now exploring model diagnostics (using Pinheiro/Bates mixed
effects book), but have come across a problem with missing data:
# the models - no problems here
m1 <- lme(ic.total ~ duration + gilman,
random = ~ 1 | patient.id, data=ic, subset=complete.cases(ic))
m2 <- lme(ic.total ~ duration + gilman,
random = ~ 1 | patient.id, data=ic, na.action=na.omit)
# simple resid/fitted plots fine too
plot(m1)
plot(m2)
# try something a bit more clever:
plot(m1, resid(., type='p')~fitted(.) | sex, id=0.05) # FINE!
plot(m2, resid(., type='p')~fitted(.) | sex, id=0.05) # NOT FINE....:
Error in `[[<-.data.frame`(`*tmp*`, j, value = c(2L, 1L, 2L, 2L, 1L, 1L, :
replacement has 181 rows, data has 219
Am I doing something fundamentally stupid?
Many thanks for your help,
Best wishes,
Mark
R version 2.5.1 (2007-06-27)
i386-apple-darwin8.9.1
locale:
en_GB.UTF-8/en_GB.UTF-8/en_GB.UTF-8/C/en_GB.UTF-8/en_GB.UTF-8
attached base packages:
[1] "splines" "stats" "graphics" "grDevices" "datasets"
"utils" "methods" "base"
other attached packages:
lme4 Matrix coda irr survival
Hmisc moments psychometric nlme multilevel
lattice RODBC
"0.99875-7" "0.999375-2" "0.12-1" "0.70" "2.32"
"3.4-2" "0.11" "0.1.2" "3.1-84" "2.2"
"0.16-5" "1.2-1"
>
--
Dr. Mark Wardle
Specialist registrar, Neurology
Cardiff, UK
More information about the R-help
mailing list