[R] add confidence intervales to xyplot for ANCOVA and extracting info

Patrick Drechsler patrick at pdrechsler.de
Sat Mar 31 14:26:46 CEST 2007


Hi,

I would like to add confidence intervales to an ANCOVA with 2
covariates when using xyplot.

What would be a good way of accomplishing this?

--8<---------------cut here---------------start------------->8---
rm(list = ls(all = TRUE))
rm(list = c(ls()))

library(lattice)

## 1. generate data
random <- rnorm(200)
y <- abs(random)
x1.cont <- abs(random)
x2.fac <- as.factor(rep(1:5, 4))     # 4 groups
x3.fac <- as.factor(rep(1:4, each=5))# 5 groups
A <- data.frame(y, x1.cont, x2.fac, x2.fac)

## 2. plot data
foo <- xyplot(log(y) ~ log(x1.cont) | x2.fac * x3.fac,
              data = A,
              type = c("p","r"),
              strip = strip.custom(strip.names=TRUE),
              as.table=TRUE)

plot(foo)
--8<---------------cut here---------------end--------------->8---

The function xyplot calculates many statistics so it can produce
regression lines and other things using "type". How does one access
this data for further analysis? I have looked at str(foo), but I did
not see an easy way of extracting the data.

TIA,

Patrick

,----[ sessionInfo() ]
| R version 2.4.1 (2006-12-18) 
| i486-pc-linux-gnu 
| 
| locale:
| LC_CTYPE=de_DE.UTF-8;LC_NUMERIC=C;LC_TIME=de_DE.UTF-8;LC_COLLATE=de_DE.UTF-8;LC_MONETARY=de_DE.UTF-8;LC_MESSAGES=de_DE.UTF-8;LC_PAPER=de_DE.UTF-8;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=de_DE.UTF-8;LC_IDENTIFICATION=C
| 
| attached base packages:
| [1] "stats"     "graphics"  "grDevices" "utils"     "datasets"  "methods"  
| [7] "base"     
| 
| other attached packages:
|   lattice 
| "0.14-17" 
`----

-- 
Patrick Drechsler
Department of Zoology
University of Cambridge
Downing Street
Cambridge CB2 3EJ, UK



More information about the R-help mailing list