[R] panel ordering in nlme and augPred plots

Petr Pikal petr.pikal at precheza.cz
Tue Apr 26 10:08:06 CEST 2005


Hi

So FYI attached is source file limity.txt which, with the code

limity.1 <- dget("limity.txt")
limity.gr <- groupedData(konverze~tepl|spol.f, limity.1, 
order.groups=F)
plot(limity.gr)	# panel order is OK
fit.nlsList1 <- nlsList(SSfpl,limity.gr)
fit.nlme1 <- nlme(fit.nlsList1, random=xmid+scal~1)
plot(augPred(fit.nlme1, level=0:1)) # panel order is mismatched

gives me different ordering of these two plots. After

ooo <- order(limity.gr$zdrzeni,  limity.gr$mvykon.c)
limity.gr <- update(limity.gr[ooo,])

both plots are in the same (correct) order. The key is probably in 
order of limity.gr file, which is different after updating.

Cheers
Petr

On 25 Apr 2005 at 18:25, Deepayan Sarkar <deepayan at sta wrote:

> Thank you.
> 
> On 25 Apr 2005 at 10:29, Deepayan Sarkar wrote:
> 
> > On Monday 25 April 2005 09:40, Petr Pikal wrote:
> > > Dear all
> > >
> > > I am trying nlme together with Pinheiro/Bates book. I constructed
> > > grouped data object with suitable plotting layout (according to
> > > some common factor, panels from bottom to top are in increasing
> > > order).
> > >
> > > When I do nlme(... some stuff...) I get fitted object which I can
> > > plot with
> > >
> > > plot(augPred(fit.nlme6, level=0:1))
> > >
> > > but it results in completely different ordering. Is there any way
> > > how I can plot panels in some defined order e.g.
> > 
> > Could you give us a reproducible example? Following the example on
> > the help page
> > 
> 
> Not yet, I try.
> 
> I made my grouped.data with ooo ordering
> 
> limity.gr<-groupedData(konverze~tepl|spol.f, limity[ooo,], 
> order.groups=F)
> 
> which led to correct ordering in
> 
> plot(limity.gr)
> 
> but it probably left limity.gr in the same order as limity
> 
> > head(limity[,1:2])
>   pokus vzorek
> 1     1      6
> 2     1      7
> 3     1      8
> 4     1      9
> 5     1     10
> 6     2      8
> > head(limity.gr[,1:2])
>   pokus vzorek
> 1     1      6
> 2     1      7
> 3     1      8
> 4     1      9
> 5     1     10
> 6     2      8
> > head(limity.gr[ooo,1:2])
>    pokus vzorek
> 33    10      3
> 34    10      4
> 35    10      5
> 36    10      7
> 37    10      8
> 38    10      9
> > head(limity[ooo,1:2])
>    pokus vzorek
> 26     7      5
> 27     7      6
> 28     7      7
> 78    15      9
> 79    15     10
> 80    15     11
> 
> When I reordered the limity.gr file in desired order and I made the
> nlme analysis based on this newly ordered data, augPred plot was OK.
> 
> <snip>
> 
> > 
> > Possibly. plot.augPred produces a Trellis plot, and usually
> > arguments to the underlying plotting function can be passed on
> > through the top-level call. e.g., with the Orthodont data
> > 
> > plot(augPred(fm1, level = 0:1), skip = rep(c(F,T), c(16, 2)))
> 
> That's it! Together with suitable layout I got what I wanted. 
> 
> Great.
> Thanks a lot
> 
> Best regards
> Petr
> 
> > 
> > or 
> > 
> > p <- plot(augPred(fm1, level = 0:1))
> > update(p, skip = rep(c(F,T), c(16, 2)))
> > 
> > You would of course have to know what valid arguments are; for that
> > see ?xyplot and ?update.trellis (in the lattice package).
> > 
> > Deepayan
> 
> 

Petr Pikal
petr.pikal at precheza.cz


-------------- next part --------------
structure(list(pokus = c(1, 1, 1, 1, 1, 2, 2, 2, 3, 3, 4, 4, 
4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 9, 9, 10, 
10, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 11, 12, 12, 12, 12, 
12, 13, 13, 13, 13, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 
14, 14, 14, 14, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 
15, 15, 15, 15, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 
16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 17, 17, 17, 17, 17, 
17, 17, 17, 17, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 
18, 18, 18, 18, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 20, 
20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 21, 21, 21, 21, 21, 
21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21), vzorek = c(6, 7, 
8, 9, 10, 8, 9, 10, 7, 8, 7, 8, 9, 10, 7, 8, 9, 10, 5, 6, 7, 
10, 11, 3, 4, 5, 6, 7, 10, 11, 3, 4, 3, 4, 5, 7, 8, 9, 10, 2, 
3, 4, 7, 8, 9, 3, 4, 5, 9, 10, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6, 
7, 8, 9, 10, 11, 12, 13, 14, 15, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 
11, 12, 13, 14, 15, 16, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 
13, 14, 15, 16, 17, 18, 19, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 
12, 13, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 1, 2, 3, 4, 5, 6, 7, 8, 9, 
10, 11, 12, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 
16), cas = c(150, 180, 210, 240, 270, 210, 240, 270, 180, 210, 
180, 210, 240, 270, 180, 210, 240, 270, 120, 150, 180, 60, 90, 
60, 90, 120, 150, 180, 60, 90, 60, 90, 60, 90, 120, 30, 60, 90, 
120, 30, 60, 90, 30, 60, 90, 60, 90, 120, 90, 120, 60, 90, 120, 
150, 0, 20, 40, 60, 80, 0, 20, 40, 60, 80, 0, 20, 40, 60, 80, 
0, 10, 20, 30, 0, 20, 40, 60, 0, 10, 20, 30, 0, 10, 20, 30, 0, 
10, 20, 0, 10, 20, 30, 0, 10, 20, 30, 0, 10, 20, 30, 0, 10, 20, 
30, 0, 20, 40, 60, 0, 20, 40, 60, 80, 0, 20, 40, 60, 0, 10, 20, 
30, 0, 10, 20, 30, 0, 10, 20, 30, 0, 10, 20, 30, 0, 10, 20, 30, 
0, 20, 40, 0, 10, 20, 20, 0, 20, 40, 60, 0, 20, 40, 60, 0, 20, 
40, 60, 0, 20, 40, 60, 0, 20, 40, 60, 0, 10, 20, 30, 0, 10, 20, 
30), tepl = c(550, 550, 550, 550, 550, 600, 600, 600, 650, 650, 
700, 700, 700, 700, 750, 750, 750, 750, 750, 750, 750, 750, 750, 
750, 750, 750, 750, 750, 750, 750, 750, 750, 750, 750, 750, 800, 
800, 800, 800, 725, 725, 725, 725, 725, 725, 725, 725, 725, 725, 
725, 750, 750, 750, 750, 800, 800, 800, 800, 800, 800, 800, 800, 
800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 
800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 
825, 825, 825, 825, 850, 850, 850, 850, 875, 875, 875, 875, 900, 
900, 900, 900, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 
800, 800, 800, 800, 800, 800, 800, 825, 825, 825, 825, 850, 850, 
850, 850, 875, 875, 875, 875, 775, 775, 775, 775, 775, 775, 775, 
775, 775, 775, 775, 825, 825, 825, 825, 825, 825, 825, 825, 825, 
825, 825, 825, 775, 775, 775, 775, 750, 750, 750, 750, 750, 750, 
750, 750, 775, 775, 775, 775), zdrzeni = c(300, 300, 300, 300, 
300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 
300, 200, 200, 200, 110, 110, 60, 60, 60, 60, 60, 12, 12, 7, 
7, 3, 3, 3, 3, 3, 3, 3, 7, 7, 7, 12, 12, 12, 110, 110, 110, 60, 
60, 60, 60, 60, 60, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 
3, 3, 3, 3, 3, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 
3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 60, 
60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 30, 30, 30, 30, 
30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 3, 3, 3, 3, 60, 
60, 60, 30, 30, 30, 30, 30, 30, 30, 30, 3, 3, 3, 3, 60, 60, 60, 
60, 60, 60, 60, 60, 60, 60, 60, 60, 3, 3, 3, 3, 3, 3, 3, 3), 
    mvykon = c(9.0362565, 9.0362565, 9.0362565, 9.0362565, 9.0362565, 
    9.0362565, 9.0362565, 9.0362565, 9.0362565, 9.0362565, 9.0362565, 
    9.0362565, 9.0362565, 9.0362565, 9.0362565, 9.0362565, 9.0362565, 
    9.0362565, 6.024171, 6.024171, 6.024171, 3.31329405, 3.31329405, 
    1.8072513, 1.8072513, 1.8072513, 1.8072513, 1.8072513, 0.36145026, 
    0.36145026, 0.210845985, 0.210845985, 0.090362565, 0.090362565, 
    0.090362565, 0.090362565, 0.090362565, 0.090362565, 0.090362565, 
    0.210845985, 0.210845985, 0.210845985, 0.36145026, 0.36145026, 
    0.36145026, 3.31329405, 3.31329405, 3.31329405, 1.8072513, 
    1.8072513, 1.8072513, 1.8072513, 1.8072513, 1.8072513, 0.090362565, 
    0.090362565, 0.090362565, 0.090362565, 0.090362565, 0.202161315, 
    0.202161315, 0.202161315, 0.202161315, 0.202161315, 0.313960065, 
    0.313960065, 0.313960065, 0.313960065, 0.313960065, 0.537557565, 
    0.537557565, 0.537557565, 0.537557565, 0.90362565, 0.90362565, 
    0.90362565, 0.90362565, 3.13960065, 3.13960065, 3.13960065, 
    3.13960065, 5.37557565, 5.37557565, 5.37557565, 5.37557565, 
    0.537557565, 0.537557565, 0.537557565, 0.537557565, 0.537557565, 
    0.537557565, 0.537557565, 0.537557565, 0.537557565, 0.537557565, 
    0.537557565, 0.537557565, 0.537557565, 0.537557565, 0.537557565, 
    0.537557565, 0.537557565, 0.537557565, 0.537557565, 1.8072513, 
    1.8072513, 1.8072513, 1.8072513, 4.0432263, 4.0432263, 4.0432263, 
    4.0432263, 4.0432263, 6.2792013, 6.2792013, 6.2792013, 6.2792013, 
    5.37557565, 5.37557565, 5.37557565, 5.37557565, 5.37557565, 
    5.37557565, 5.37557565, 5.37557565, 5.37557565, 5.37557565, 
    5.37557565, 5.37557565, 5.37557565, 5.37557565, 5.37557565, 
    5.37557565, 0.313960065, 0.313960065, 0.313960065, 0.313960065, 
    6.2792013, 6.2792013, 6.2792013, 3.13960065, 3.13960065, 
    3.13960065, 3.13960065, 3.13960065, 3.13960065, 3.13960065, 
    3.13960065, 0.313960065, 0.313960065, 0.313960065, 0.313960065, 
    6.2792013, 6.2792013, 6.2792013, 6.2792013, 4.0432263, 4.0432263, 
    4.0432263, 4.0432263, 4.0432263, 4.0432263, 4.0432263, 4.0432263, 
    0.202161315, 0.202161315, 0.202161315, 0.202161315, 0.202161315, 
    0.202161315, 0.202161315, 0.202161315), konverze = c(34.4092669938343, 
    33.6404149529208, 35.4642706844019, 33.4479998260961, 36.2299165537051, 
    38.8032640576276, 38.7082614757145, 39.562400762269, 46.4098215400063, 
    46.6878560360014, 80.7682462310968, 72.5122960531819, 83.4838544120605, 
    75.99919751406, 99.9213063122585, 99.9216531020603, 99.9217537554212, 
    99.9217825051555, 99.919735973438, 99.9214638739669, 99.9212762420845, 
    99.9113806939044, 99.919735973438, 99.9213063122585, 99.9217081795054, 
    99.9216953557315, 99.9214154939673, 99.9215084406288, 99.8946793219813, 
    99.7313943076732, 97.0203545826443, 96.325564135491, 93.1583585989976, 
    90.8498403908506, 92.6345479427419, 99.9218714537421, 99.9218745682224, 
    99.9218789636136, 99.9218760694787, 74.2759329066312, 74.5030423498955, 
    74.6540647353064, 78.96406439195, 79.105007113877, 78.325479890549, 
    92.8113108152061, 89.1504310156568, 87.661689663491, 89.522160619596, 
    89.416561120322, 99.9215494274125, 99.921621548057, 99.921621548057, 
    99.921621548057, 99.919894417069, 99.9207846435903, 99.9201838275247, 
    99.9201838275247, 99.920315589499, 99.2406256921944, 98.771466845088, 
    98.8925409019089, 98.3185223107056, 99.563451684125, 87.5480121019775, 
    86.3861697659327, 85.667632887137, 87.261806402352, 85.1184465622741, 
    75.0302665801947, 72.7445493020412, 73.8196585138101, 73.6669632040268, 
    99.9218369284028, 99.9218471730953, 99.9218392951483, 99.9218503629537, 
    97.5112049929177, 97.6079007533892, 99.3861963620773, 96.2638961779662, 
    78.18261641054, 73.2839173672686, 74.2000769075299, 80.9044626462036, 
    76.0731725538, 73.360675269182, 77.5354924275454, 84.0576186105554, 
    85.5463465366198, 84.8715788005048, 84.2470213500837, 94.6490574904999, 
    93.1154520184348, 94.9462038565578, 96.5664414913018, 99.8075530086229, 
    99.920250746614, 99.9210466338302, 99.916823601997, 99.9218919877098, 
    99.9218855990822, 99.921901065055, 99.9219026965073, 99.9219080625446, 
    99.9218970517983, 99.921883044339, 99.9218836951646, 99.9217031223996, 
    99.9216763638153, 99.9217005578213, 99.921747471072, 99.9214910564103, 
    99.9045972834445, 99.8920464361591, 99.9032460775732, 99.9145254676165, 
    89.6796415060874, 88.444397881242, 83.290766004827, 82.8367059128002, 
    99.8171837907443, 98.5214155112903, 98.0987848541092, 97.0744833950812, 
    99.9218503629537, 99.9218392951483, 99.9218673431016, 99.9218681850666, 
    99.921923903655, 99.9219252892848, 99.9219247371768, 99.9219238350975, 
    78.7519895119856, 81.9805768702718, 81.3108582648618, 77.967676175538, 
    89.887893514819, 88.8270840767329, 90.3998338676438, 90.997556516565, 
    90.6011017735806, 91.5292932379583, 92.5453612879952, 99.921888027357, 
    99.9218946033935, 99.9219026965073, 99.921901065055, 99.9200435675742, 
    99.9200435675742, 99.9202375304238, 99.920315589499, 99.921849311762, 
    99.9218040999625, 99.9218449853178, 99.9218647561647, 99.9045150817654, 
    99.9075791736413, 99.5096002832137, 99.6682405147593, 82.2457644762503, 
    83.2262012216549, 81.7138401025478, 81.7138401025478, 74.0481366983525, 
    72.7445493020412, 72.0458424615628, 74.2000769075299, 83.0967699009502, 
    90.997556516565, 88.9353477402655, 87.9999421662423), mvykon.c = c(9.04, 
    9.04, 9.04, 9.04, 9.04, 9.04, 9.04, 9.04, 9.04, 9.04, 9.04, 
    9.04, 9.04, 9.04, 9.04, 9.04, 9.04, 9.04, 6.22, 6.22, 6.22, 
    3.19, 3.19, 1.81, 1.81, 1.81, 1.81, 1.81, 0.33, 0.33, 0.2, 
    0.2, 0.09, 0.09, 0.09, 0.09, 0.09, 0.09, 0.09, 0.2, 0.2, 
    0.2, 0.33, 0.33, 0.33, 3.19, 3.19, 3.19, 1.81, 1.81, 1.81, 
    1.81, 1.81, 1.81, 0.09, 0.09, 0.09, 0.09, 0.09, 0.2, 0.2, 
    0.2, 0.2, 0.2, 0.33, 0.33, 0.33, 0.33, 0.33, 0.54, 0.54, 
    0.54, 0.54, 0.9, 0.9, 0.9, 0.9, 3.19, 3.19, 3.19, 3.19, 5.38, 
    5.38, 5.38, 5.38, 0.54, 0.54, 0.54, 0.54, 0.54, 0.54, 0.54, 
    0.54, 0.54, 0.54, 0.54, 0.54, 0.54, 0.54, 0.54, 0.54, 0.54, 
    0.54, 0.54, 1.81, 1.81, 1.81, 1.81, 4.04, 4.04, 4.04, 4.04, 
    4.04, 6.22, 6.22, 6.22, 6.22, 5.38, 5.38, 5.38, 5.38, 5.38, 
    5.38, 5.38, 5.38, 5.38, 5.38, 5.38, 5.38, 5.38, 5.38, 5.38, 
    5.38, 0.33, 0.33, 0.33, 0.33, 6.22, 6.22, 6.22, 3.19, 3.19, 
    3.19, 3.19, 3.19, 3.19, 3.19, 3.19, 0.33, 0.33, 0.33, 0.33, 
    6.22, 6.22, 6.22, 6.22, 4.04, 4.04, 4.04, 4.04, 4.04, 4.04, 
    4.04, 4.04, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2), spol.f = structure(c(15, 
    15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 
    15, 15, 14, 14, 14, 13, 13, 10, 10, 10, 10, 10, 6, 6, 5, 
    5, 1, 1, 1, 1, 1, 1, 1, 5, 5, 5, 6, 6, 6, 13, 13, 13, 10, 
    10, 10, 10, 10, 10, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 
    3, 3, 4, 4, 4, 4, 7, 7, 7, 7, 8, 8, 8, 8, 9, 9, 9, 9, 4, 
    4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 10, 
    10, 10, 10, 11, 11, 11, 11, 11, 12, 12, 12, 12, 9, 9, 9, 
    9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 3, 3, 3, 3, 12, 12, 
    12, 8, 8, 8, 8, 8, 8, 8, 8, 3, 3, 3, 3, 12, 12, 12, 12, 11, 
    11, 11, 11, 11, 11, 11, 11, 2, 2, 2, 2, 2, 2, 2, 2), .Label = c("0.09.3", 
    "0.2.3", "0.33.3", "0.54.3", "0.2.7", "0.33.12", "0.9.30", 
    "3.19.30", "5.38.30", "1.81.60", "4.04.60", "6.22.60", "3.19.110", 
    "6.22.200", "9.04.300"), class = "factor")), .Names = c("pokus", 
"vzorek", "cas", "tepl", "zdrzeni", "mvykon", "konverze", "mvykon.c", 
"spol.f"), row.names = c("1", "2", "3", "4", "5", "6", "7", "8", 
"9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", 
"20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", 
"31", "32", "33", "34", "35", "36", "37", "38", "39", "40", "41", 
"42", "43", "44", "45", "46", "47", "48", "49", "50", "51", "52", 
"53", "54", "55", "56", "57", "58", "59", "60", "61", "62", "63", 
"64", "65", "66", "67", "68", "69", "70", "71", "72", "73", "74", 
"75", "76", "77", "78", "79", "80", "81", "82", "83", "84", "85", 
"86", "87", "88", "89", "90", "91", "92", "93", "94", "95", "96", 
"97", "98", "99", "100", "101", "102", "103", "104", "105", "106", 
"107", "108", "109", "110", "111", "112", "113", "114", "115", 
"116", "117", "118", "119", "120", "121", "122", "123", "124", 
"125", "126", "127", "128", "129", "130", "131", "132", "133", 
"134", "135", "136", "137", "138", "139", "140", "141", "142", 
"143", "144", "145", "146", "147", "148", "149", "150", "151", 
"152", "153", "154", "155", "156", "157", "158", "159", "160", 
"161", "162", "163", "164", "165", "166", "167", "168", "169", 
"170", "171", "172"), class = "data.frame")


More information about the R-help mailing list