Hello, nlme-experts among the list members,
I have encountered a puzzling behaviour of the function augPred() from the
nlme-library, version 3.3.1 (using S-PLUS, Ver. 6.0 Rel. 1 for Sun SPARC,
SunOS 5.6), about which I haven't found anything in the archive.
augPred() permutes the original response values without appropriately
reordering the co- and grouping variables (!) if the grouping levels do
not occur in "blocks" in the respective column of the groupedData object
(as it is, for example, the case in column "Subject" of the groupedData
object Orthodont in Dr. Pinheiro's and Dr. Bates' book "Mixed-Effects
Models in S and S-PLUS").
Consider my (small) example groupedData object called "komp":
> komp
Grouped Data: Y ~ x | ID
ID x Y
1 RA1 1 2.746
2 RA2 1 1.512
3 RA3 1 3.130
4 RA1 2 1.451
5 RA2 2 3.418
6 RA3 2 5.264
7 RA1 3 1.362
8 RA2 3 3.098
9 RA3 3 2.078
10 RA1 4 3.046
11 RA2 4 3.157
12 RA3 4 6.101
Produce lmList-fits of Y vs. x by ID and the augmented predictions data
frame:
> komp.lis <- lmList( Y ~ x | ID, data= komp)
> komplis.pred <- augPred( komp.lis, length.out= 2)
> komplis.pred
x ID Y .type
1 1 RA1 2.7460 original
2 1 RA2 1.4510 original
3 1 RA3 1.3620 original
4 2 RA1 3.0460 original
5 2 RA2 1.5120 original
6 2 RA3 3.4180 original
7 3 RA1 3.0980 original
8 3 RA2 3.1570 original
9 3 RA3 3.1300 original
10 4 RA1 5.2640 original
11 4 RA2 2.0780 original
12 4 RA3 6.1010 original
13 1 RA1 2.0296 predicted
14 4 RA1 2.2729 predicted
15 1 RA2 2.1040 predicted
16 4 RA2 3.4885 predicted
17 1 RA3 3.2842 predicted
18 4 RA3 5.0023 predicted
Now, compare the original data in komplis.pred$Y (in the rows with .type==
"original") with komp$Y: The former vector contains the permutation
komp$Y[ c( 1, 4, 7, 10, 2, 5, 8, 11, 3, 6, 9, 12)] *altough*
komplis.pred$x and komplis.pred$ID are in the same order as komp$x and
komp$ID, respectively!
Thus, in komplis.pred the original Y-elements have lost their relation to
the corresponding elements in komplis.pred$x and komplis.pred$ID (both of
which have their elements still in the original order and correct relation
to each other).
This has, of course, puzzling consequences when plotting the augmented
fits:
> plot( komplis.pred)
The fitted lines and the original data get mixed up completely (not
shown).
Have I ovelooked anything? And if not, does anybody have a solution or a
work around for the described problem?
Thank you for any hint.
Best regards -- Gerrit
-------------------------------------------------------------------------
Dr. Gerrit Eichner Mathematical Institute of the
gerrit.eichner@math.uni-giessen.de Justus-Liebig-Univ. Giessen
Tel: +49-(0)641-99-32104 Arndtstr. 2, D-35392 Giessen
Fax: +49-(0)641-99-32029 http://www.uni-giessen.de/AG_Stochastik
-------------------------------------------------------------------------
|