View source: R/anova_related.R
Many two-way ANOVAs | R Documentation |
Many two-way ANOVAs.
twoway.anovas(y, x1, x2, interact = FALSE, logged = FALSE)
y |
A matrix with the data, where the rows denote the observations (and the two groups) and the columns are the variables. |
x1 |
A numerical vector with 1s, 2s, 3s and so one indicating the two groups. Alternatively it can be a factor variable. This is the one factor. |
x2 |
A numerical vector with 1s, 2s, 3s and so one indicating the two groups. Alternatively it can be a factor variable. This is the other factor. |
interact |
A boolean variable specifying whether you want to test for interaction. |
logged |
Should the p-values be returned (FALSE) or their logarithm (TRUE)? |
The classical two-way ANOVA design is performed. Note that the design must be balanced. For every combination of values of the two factors, x1 and x2 the same number of observations must exist. If that's not the case, regression models must be used.
A matrix with the test statistic and the p-value of each test.
Michail Tsagris
R implementation and documentation: Michail Tsagris <mtsagris@uoc.gr> and Manos Papadakis <papadakm95@gmail.com>.
D.C. Montgomery (2001). Design and analysis of experiments (5th Edition). New York: John Wiley & Sons.
ancovas, ftests, ttests
y <- as.matrix( rnorm(125) )
x1 <- rep(1:5, 25)
x2 <- rep(1:5, each = 25)
x1 <- factor(x1)
x2 <- factor(x2)
res<-anova( lm(y ~ x1 + x2) )
res<-twoway.anovas(y, x1, x2)
res<-anova( lm(y ~ x1*x2) )
res<-twoway.anovas(y, x1, x2, interact = TRUE)
y <- matrnorm(125, 100)
a1 <- twoway.anovas(y, x1, x2)
a2 <- twoway.anovas(y, x1, x2, interact = TRUE)
y <- NULL
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.