ffAnova | R Documentation |
Analysis of variance table for a linear model using type II
* sums of squares,
which are described in Langsrud et al. (2007).
Type II
* extends the type II
philosophy to continuous variables.
The results are invariant to scale changes and pitfalls are avoided.
ffAnova(formula, data = NULL)
formula |
A model |
data |
An optional data frame, list or environment. |
This function is a variant of ffmanova
for the univariate special case.
The two input parameters will be interpreted by model.frame
.
An object of class "anova"
(see anova
).
Øyvind Langsrud and Bjørn-Helge Mevik
Langsrud, Ø., Jørgensen, K., Ofstad, R. and Næs, T. (2007): “Analyzing Designed Experiments with Multiple Responses”, Journal of Applied Statistics, 34, 1275-1296.
# Generate example data
set.seed(123)
a <- c(0, 0, 0, 10, 10, 10, 1, 1, 1)
A <- as.character(a) # A is categorical
b <- 1:9
y <- rnorm(9)/10 + a # y depends strongly on a (and A)
a100 <- a + 100 # change of scale (origin)
b100 <- b + 100 # change of scale (origin)
# Four ways of obtaining the same results
ffAnova(y ~ A * b)
ffAnova(y ~ A * b100)
ffAnova(lm(y ~ A * b))
ffAnova(y ~ A * b, data.frame(A = A, y = y, b = 1:9))
# Second order continuous variable
ffAnova(y ~ a + I(a^2))
# Model equivalent to 'y ~ A * b'
ffAnova(y ~ (a + I(a^2)) * b)
# Demonstrating similarities and differences using package car
if (!require(car)) # Package car is loaded if available
Anova <- function(...) { # Replacement function if car not available
warning("No results since package car is not available")}
lm_Ab <- lm(y ~ A * b)
lm_Ab100 <- lm(y ~ A * b100)
# Type II same as type II* in this case
Anova(lm_Ab) # Type II
Anova(lm_Ab100) # Type II
ffAnova(lm_Ab) # Type II*
ffAnova(lm_Ab100) # Type II*
# Type III depends on scale
Anova(lm_Ab, type = 3)
Anova(lm_Ab100, type = 3)
lm_a <- lm(y ~ a + I(a^2))
lm_a100 <- lm(y ~ a100 + I(a100^2))
# Now Type II depends on scale
Anova(lm_a) # Type II
Anova(lm_a100) # Type II
ffAnova(lm_a) # Type II*
ffAnova(lm_a100) # Type II*
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.