[R] panel ordering in nlme and augPred plots

Deepayan Sarkar deepayan at stat.wisc.edu
Mon Apr 25 17:29:08 CEST 2005


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

fm <- lme(Orthodont)
plot(Orthodont)
plot(augPred(fm, level = 0:1))

gives me the same ordering on both plots.

> ord.f<-order(my.1.fac, my.2.fac)
> plot(augPred(fit.nlme6, level=0:1), ord.f)
>
> The only thing I found out is that if I order grouped.data object
>
> gr.dat<-gr.dat[ord.f,]
>
> and do nlme fit, then the ordering in augPred plot is OK.
>
> BTW
>
> is there a way how to specify in plot
>
> row1 -> 3 panels
> row2 -> 3 panels
> row3 -> 3 panels
> row4 -> 2 panels
> row5 -> 4 panels

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)))

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




More information about the R-help mailing list