Re: [R] xyplot: adding pooled regression lines to a paneled type="r" plot

Date: Tue, 22 Jun 2010 12:45:12 -0400


Look at the ancova function in the HH package.

## install.packages("HH") ## if not there yet. library(HH)
library(nlme) ## for the Orthodont data

ancova(distance ~ age*Sex, data=Orthodont)
ancova(distance ~ age+Sex, data=Orthodont)
ancova(distance ~ age, groups=Sex, data=Orthodont)
ancova(distance ~ Sex, x=age, data=Orthodont)


On Tue, Jun 22, 2010 at 12:30 PM, Michael Friendly <>wrote:

> Consider the following plot that shows separate regression lines ~ age for
> each subject in the Pothoff-Roy Orthodont data,
> with separate panels by Sex:
> library(nlme)
> #plot(Orthodont)
> xyplot(distance ~ age|Sex, data=Orthodont, type='r', groups=Subject,
> col=gray(.50),
> main="Individual linear regressions ~ age")
> I'd like to also show in each panel the pooled OLS regression line for each
> Sex in the corresponding panel,
> generated by the following model:
> Ortho.OLS <- lm(distance ~ age * Sex, data=Orthodont)

        [[alternative HTML version deleted]] mailing list PLEASE do read the posting guide and provide commented, minimal, self-contained, reproducible code. Received on Tue 22 Jun 2010 - 16:47:28 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Tue 22 Jun 2010 - 17:00:33 GMT.

Mailing list information is available at Please read the posting guide before posting to the list.

list of date sections of archive