Patrick Drechsler
2007-Mar-31 12:26 UTC
[R] add confidence intervales to xyplot for ANCOVA and extracting info
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
Deepayan Sarkar
2007-Apr-02 19:07 UTC
[R] add confidence intervales to xyplot for ANCOVA and extracting info
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. >