perm.anova: Permutation Analysis of Variance

View source: R/perm.anova.R

perm.anovaR Documentation

Permutation Analysis of Variance

Description

Performs a permutation analysis of variance for 1 to 3 factors. For 2 and 3 factors, experiment design must be balanced. For 2 factors, the factors can be crossed with or without interaction, or nested. The second factor can be a blocking (random) factor. For 3 factors, design is restricted to 2 fixed factors crossed (with or without interaction) inside blocks (third factor).

Usage

perm.anova(formula, nest.f2 = c("fixed", "random"), data, nperm = 999,
  progress = TRUE)

Arguments

formula

a formula of the form response ~ factor(s) (see Details).

nest.f2

in case of 2 nested factors, precision is needed if the nested factor (factor2) is "fixed" (default) or "random".

data

an optional data frame containing the variables in the formula formula. By default the variables are taken from environment(formula).

nperm

number of permutations.

progress

logical indicating if the progress bar should be displayed.

Details

For 2 factors, the formula can be:

response ~ factor1 + factor2 for 2 fixed factors without interaction

response ~ factor1 * factor2 for 2 fixed factors with interaction

response ~ factor1 / factor2 for 2 fixed factors with factor2 nested into factor1 (if factor2 is a random factor, argument nest.f2 must be changed from "fixed" (default) to "random")

response ~ factor1 | factor2 for 1 fixed factor (factor1) and 1 blocking (random) factor (factor2).

For 3 factors, the formula can only be:

response ~ factor1 + factor2 | factor3 or

response ~ factor1 * factor2 | factor3. The 2 factors are here fixed and crossed inside each level of the third, blocking (random), factor.

The function deals with the limitted floating point precision, which can bias calculation of p-values based on a discrete test statistic distribution.

Value

a data frame of class "anova".

Author(s)

Maxime HERVE <maxime.herve@univ-rennes1.fr>

Examples

set.seed(1203)
response <- c(rnorm(12),rpois(12,0.5),rnorm(12,2,1))
fact1 <- gl(3,12,labels=LETTERS[1:3])
fact2 <- gl(3,1,36,labels=letters[1:3])
fact3 <- gl(6,6,labels=letters[1:6])
block <- gl(2,6,36,labels=letters[1:2])

# Not enough permutations here but faster to run

# 2 crossed fixed factors with interaction
perm.anova(response~fact1*fact2,nperm=49)

# 2 nested fixed factors
perm.anova(response~fact1/fact2,nperm=49)

# 2 nested factors, fact2 being random
perm.anova(response~fact1/fact3,nest.f2="random",nperm=49)

# 1 fixed factor and 1 blocking (random) factor
perm.anova(response~fact1|block,nperm=49)

RVAideMemoire documentation built on Nov. 6, 2023, 5:07 p.m.