Debian Codegraph @

man/compresid2way.Rd

raw
1 \name{compresid2way}
2 \alias{compresid2way}
3 \title{Plot Components + Residuals for Two Factors}
4 \description{
5 For an analysis of variance or regression with (at least) two factors:
6 Plot components + residuals for two factors according to Tukey's
7 \dQuote{forget-it plot}. Try it!
8 }
9 \usage{
10 compresid2way(aov, data=NULL, fac=1:2, label = TRUE, numlabel = FALSE,
11 xlab=NULL, ylab=NULL, main=NULL,
12 col=c(2,3,4,4), lty=c(1,1,2,4), pch=c(1,2))
13 }
14 \arguments{
15 \item{aov}{either an \code{\link{aov}} object with a formula of the form
16 % \code{y \~{} a + b}, where \code{a} and \code{b} are factors,
17 \code{y ~ a + b}, where \code{a} and \code{b} are factors,
18 or such a formula.}
19 \item{data}{data frame containing \code{a} and \code{b}.}
20 \item{fac}{the two factors used for plotting. Either column numbers or
21 names for argument \code{data}.}
22 \item{label}{logical indicating if levels of factors should be shown
23 in the plot.}
24 \item{numlabel}{logical indicating if effects of factors will be shown
25 in the plot.}
26 \item{xlab,ylab,main}{the usual \code{\link{title}} components, here
27 with a non-trivial default constructed from \code{aov} and the
28 component factors used.}
29 \item{col,lty,pch}{colors, line types, plotting characters to be used
30 for plotting [1] positive residuals, [2] negative residuals,
31 [3] grid, [4] labels. If \code{pch} is sufficiently long, it will be used
32 as the list of individual symbols for plotting the y values.}
33 }
34 \details{For a two-way analysis of variance, the plot shows the additive
35 components of the fits for the two factors by the intersections of a
36 grid, along with the residuals.
37 The observed values of the target variable are identical to the
38 vertical coordinate.
39
40 The application of the function has been extended to cover more
41 complicated models. The components of the fit for two factors are
42 shown as just described, and the residuals are added. The result is a
43 \dQuote{component plus residual} plot for two factors in one display.
44 }
45 \value{Invisibly, a list with components
46 \item{compy}{data.frame containing the component effects of the two
47 factors, and combined effects plus residual}
48 \item{coef}{coefficients: Intercept and effects of the factors}
49 }
50 \references{
51 F. Mosteller and J. W. Tukey (1977)
52 \emph{Data Analysis and Regression: A Second Course in Statistics}.
53 Addison-Wesley, Reading, Mass., p. 176.
54
55 John W. Tukey (1977)
56 \emph{Exploratory Data Analysis}.
57 Addison-Wesley, Reading, Mass., p. 381.
58 }
59 \author{Werner Stahel \email{[email protected]}}
60 \seealso{\code{\link{interaction.plot}}}
61 \examples{
62 ## From Venables and Ripley (2002) p.165.
63 N <- c(0,1,0,1,1,1,0,0,0,1,1,0,1,1,0,0,1,0,1,0,1,1,0,0)
64 P <- c(1,1,0,0,0,1,0,1,1,1,0,0,0,1,0,1,1,0,0,1,0,1,1,0)
65 K <- c(1,0,0,1,0,1,1,0,0,1,0,1,0,1,1,0,0,0,1,1,1,0,1,0)
66 yield <- c(49.5,62.8,46.8,57.0,59.8,58.5,55.5,56.0,62.8,55.8,69.5,55.0,
67 62.0,48.8,45.5,44.2,52.0,51.5,49.8,48.8,57.2,59.0,53.2,56.0)
68 npk <- data.frame(block=gl(6,4), N=factor(N), P=factor(P),
69 K=factor(K), yield=yield)
70 npk.cr <- compresid2way(yield ~ N+P+K, data=npk, fac=c("P","K"))
71
72 ## Fisher's 1926 data on potatoe yield
73 data(potatoes)
74 pot.aov <- aov(yield ~ nitrogen+potash+pos, data=potatoes)
75 compresid2way(pot.aov, pch=as.character(potatoes$pos))
76
77 compresid2way(yield~nitrogen+potash, data=subset(potatoes, pos == 2))
78
79 ## 2 x 3 design :
80 data(warpbreaks)
81 summary(fm1 <- aov(breaks ~ wool + tension, data = warpbreaks))
82 compresid2way(fm1)
83 }
84 \keyword{hplot}