From: Spencer Graves <spencer.graves_at_pdf.com>

Date: Fri 29 Sep 2006 - 15:30:34 GMT

R-help@stat.math.ethz.ch mailing list

https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Sat Sep 30 01:33:30 2006

Date: Fri 29 Sep 2006 - 15:30:34 GMT

You want an 'augPred' plot with multiple lines per panel, from multiple factors in the model? Because you provided such a simple, self-contained example, I can offer much more substantive comments than I might have otherwise. First the bad news: I don't see an easy way to get what you want. Good news: I think I can outline for you a moderately simple but still not trivial way to get it -- though I haven't completed the exercise myself.

The 'augPred' documentation includes an example with two lines per panel, but one of the lines is just the 'fixed' model, which is the same in all frames. That's not what you want.

To dig deeper, I typed 'augPred' at a command prompt: It's a one line function consisting of 'UseMethod("augPred")'. This pushed me to do the following:

> methods("augPred")

[1] augPred.gls* augPred.lme* augPred.lmList*

This led me to try "getAnywhere(augPred.lme)", which listed out the function. I decided I wanted to walk through the function line by line, so I tried the following:

> debug(augPred.lme)

Error: object "augPred.lme" not found

Since 'augPred' is in library(nlme), I refined this as follows:

> debug(nlme:::augPred.lme)

This worked. Next I tried to execute your command 'augPred(fm1Pixel)', which put me into 'augPred.lme'. From there, one can walk through the function line by line, looking at what they do, etc. Later, you can do the execute your own modification to that code outside of a call to 'augPred'. If you get 'object ... not found', try adding 'nlme:::' as a prefix to '...'. If you do this, you will find that 'augPred' basically does three things:

- Creates a data.frame 'value' containing the explanatory variables for which predictions are needed. You need to add a column for 'Side' to 'value'; I don't see a way to do this in the function call.
- Call 'pred <- predict(...)' to get the numbers required for the lines.
- Reorganize things so 'plot.augPred' knows what to do.

After you get 'pred' with all the numbers you need, you can plot them any way you want.

Hope this helps. Spencer Graves

Afshartous, David wrote:

*> All,
**>
*

> I have a question RE plotting the prediction lines of a random effects

*> model via augPred. I'll illustrate via the Pixel dataset within the
**> nlme package:
**>
**> library(nlme)
**> attach(Pixel)
**> fm1Pixel = lme(pixel ~ day + I(day^2), data = Pixel, random = list(Dog =
**> ~ 1))
**> plot(augPred(fm1Pixel)) ### 10 fitted lines since there are 10 dogs
**>
**> fm2Pixel = update(fm1Pixel, . ~ . + Side)
**> plot(augPred(fm2Pixel)) ## also produces 10 fitted lines
**>
**> For the second plot, shouldn't we have 2 fitted lines per dog, one for
**> each level
**> of the fixed effect Side?
**>
**> 1) How does one plot insure that this is plotted accordingly?
**>
**> 2) How does one plot say only the first 5 dogs?
**>
**>
**> Thanks!
**> Dave
**>
**> ______________________________________________
**> R-help@stat.math.ethz.ch mailing list
**> https://stat.ethz.ch/mailman/listinfo/r-help
**> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
**> and provide commented, minimal, self-contained, reproducible code.
**>
*

R-help@stat.math.ethz.ch mailing list

https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Sat Sep 30 01:33:30 2006

Archive maintained by Robert King, hosted by
the discipline of
statistics at the
University of Newcastle,
Australia.

Archive generated by hypermail 2.1.8, at Fri 29 Sep 2006 - 16:30:24 GMT.

*
Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help.
Please read the posting
guide before posting to the list.
*