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

Deepayan Sarkar deepayan.sarkar at gmail.com
Mon Apr 2 21:07:26 CEST 2007


On 3/31/07, Patrick Drechsler <patrick at pdrechsler.de> wrote:
> 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?

demo("intervals", package = "lattice")

will give you examples of confidence intervals. If you want more
specific answers, please give a more relevant example.


> --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".

No it doesn't. The regression line is draw by panel.lmline, which is
called by panel.xyplot, and that is executed in the plot(foo) stage.
In other words, foo does not contain the results of those
calculations.

-Deepayan

> 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
>
> ______________________________________________
> R-help at 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.
>



More information about the R-help mailing list