Michael Dewey
2004-Mar-22 13:15 UTC
[R] Lattice, skip= and layout= problem, plotting object from nlme output
I generate a groupedData object library(nlme) obj <- groupedData(mg10 ~ time | gp, data = common, outer = ~pct) gp has 101 levels, and pct has 3. There are 38, 25, 38 gps in each of the levels of pct respectively. I fit my model fit.rtg <- lme(mg10 ~ time * group, data = obj, random = ~time * group | gp) Now I try to plot the results. I would like to print 40 panels on each page and have a new level of pct start a new page. The effect of using outer in the call of groupedData is that the values of gp are presented by pct. plot.rtg <- plot(augPred(fit.rtg), skip = c(rep(FALSE, 38), TRUE, TRUE, rep(FALSE, 25), rep(TRUE, 15), rep(FALSE, 38), TRUE, TRUE), layout = c(5, 8, 3), strip = FALSE ) What I get is 38 panels on page 1 with 2 blank panels top right. I had hoped to get 25 on the next page with 15 blanks but I get 38 again with 2 blanks. If I alter layout to (say) layout = c(12, 10) I get blanks as expected on the single page produced so I surmise that skip is forcing the same format on each page. There is an example in \cite{pinheiro00} which suggests that what I wanted can be done (p113, p445-447) so I suspect I am doing something stupid here. I am using R 1.8.1 with the versions of lattice and nlme that came with it. I am using Windows 98SE if that is relevant. @BOOK{pinheiro00, author = {Pinheiro, J C and Bates, D M}, year = 2000, title = {Mixed-effects models in {S} and {S-PLUS}}, publisher = {Springer-Verlag} } Michael Dewey m.dewey at iop.kcl.ac.uk
Deepayan Sarkar
2004-Mar-22 19:28 UTC
[R] Lattice, skip= and layout= problem, plotting object from nlme output
On Monday 22 March 2004 07:15, Michael Dewey wrote:> I generate a groupedData object > > library(nlme) > obj <- groupedData(mg10 ~ time | gp, data = common, outer = ~pct) > > gp has 101 levels, and pct has 3. There are 38, 25, 38 gps in each of > the levels of pct respectively. > > I fit my model > > fit.rtg <- lme(mg10 ~ time * group, > data = obj, > random = ~time * group | gp) > > Now I try to plot the results. I would like to print 40 panels on > each page and have a new level of pct start a new page. The effect of > using outer in the call of groupedData is that the values of gp are > presented by pct. > > plot.rtg <- plot(augPred(fit.rtg), > skip = c(rep(FALSE, 38), TRUE, TRUE, > rep(FALSE, 25), rep(TRUE, 15), > rep(FALSE, 38), TRUE, TRUE), > layout = c(5, 8, 3), > strip = FALSE > ) > > What I get is 38 panels on page 1 with 2 blank panels top right. I > had hoped to get 25 on the next page with 15 blanks but I get 38 > again with 2 blanks. > > If I alter layout to (say) layout = c(12, 10) I get blanks as > expected on the single page produced so I surmise that skip is > forcing the same format on each page. There is an example in > \cite{pinheiro00} which suggests that what I wanted can be done > (p113, p445-447) so I suspect I am doing something stupid here.You are seeing documented lattice behavior, but looks like that's inconsistent with what happens in S-PLUS. lattice replicates the skip vector to be as long as the number of panels per page and uses that for every page, while S-PLUS replicates it to be as long as the total number of panels spanning all pages. I can easily fix this for 1.9.0, but this may break old (but probably rare) lattice code. For example, layout = c(2,2,2), skip = c(T,F,F) will now expand to page 1: T, F, F, T page 2: F, F, T, F as opposed to the current behavior page 1: T, F, F, T page 2: T, F, F, T Any objections to that ? Deepayan
Michael Dewey
2004-Mar-22 21:06 UTC
[R] Lattice, skip= and layout= problem, plotting object from nlme output
At 13:28 22/03/04 -0600, you wrote: [snip my original problem]>You are seeing documented lattice behavior, but looks like that's >inconsistent with what happens in S-PLUS. lattice replicates the skip >vector to be as long as the number of panels per page and uses that for >every page, while S-PLUS replicates it to be as long as the total >number of panels spanning all pages. > >I can easily fix this for 1.9.0, but this may break old (but probably >rare) lattice code. For example, > >layout = c(2,2,2), skip = c(T,F,F) > >will now expand to > >page 1: T, F, F, T >page 2: F, F, T, F > >as opposed to the current behavior > >page 1: T, F, F, T >page 2: T, F, F, T > >Any objections to that ?From my point of view the current behaviour is not very useful, and in your example either behaviour seems a bit strange so I would not object to it changing. Thanks for the quick response, and thanks for making lattice available. I find myself making so many more graphical displays because they are (a) easy (b) aesthetically pleasing (c) revealing about my dataset.>DeepayanMichael Dewey m.dewey at iop.kcl.ac.uk