aovperm: P-values based on permutation tests for ANOVA and repeated...

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/fit_model.R

Description

Provides p-values for omnibus tests based on permutations for factorial and repeated measures ANOVA. This function produces the F statistics, parametric p-values (based, on Gaussian and sphericity assumptions) and p-values based on the permutation methods that handle nuisance variables.

Usage

1
aovperm(formula, data = NULL, np = 5000, method = NULL, ...)

Arguments

formula

A formula object. The formula for repeated measures ANOVA should be written using the same notation as aov by adding +Error(id/within), where id is the factor that identify the subjects and within is the within factors.

data

A data frame or matrix.

np

The number of permutations. Default value is 5000.

method

A character string indicating the method used to handle nuisance variables. Default is NULL and will change if to "freedman_lane" for the fixed effects model and "Rd_kheradPajouh_renaud" for the random effect models. See Details for other methods.

...

Futher arguments, see details.

Details

The following methods are available for the fixed effects model defined as y = Dη + Xβ + ε. If we want to test β = 0 and take into account the effects of the nuisance variables D, we transform the data :

method argument y* D* X*
"draper_stoneman" y D PX
"freedman_lane" (H_D+PR_D)y D X
"manly" Py D X
"terBraak" (H_{X,D}+PR_{X,D})y D X
"kennedy" PR_D y R_D X
"huh_jhun" PV'R_Dy V'R_D X
"dekker" y D PR_D X

The following methods are available for the random effects model y = Dη + Xβ + Eκ + Zγ+ ε. If we want to test β = 0 and take into account the effect of the nuisance variable D we can transform the data by permutation:

method argument y* D* X* E* Z*
"Rd_kheradPajouh_renaud" PR_D y R_D X R_D E R_D Z
"Rde_kheradPajouh_renaud" PR_{D,E}y R_{D,E} X R_{D,E}Z

Other arguments could be pass in ... :

P : a matrix, of class matrix or Pmat, containing the permutations (for the reproductibility of the results). The first column must be the identity permutation (not checked). P overwrites np argument.
rnd_rotation : a random matrix of size n \times n to compute the rotation used for the "huh_jhun" method. coding_sum : a logical set to TRUE defining the coding of the design matrix to contr.sum to test the main effects. If it is set to FALSE the design matrix is computed with the coding defined in the dataframe. The tests of simple effets are possible with a coding of the factors of the dataframe set to contr.treatment.

Value

A lmperm object containing most of the objects given in an lm object, an ANOVA table with parametric and permutation p-values, the test statistics and the permutation distributions.

Author(s)

[email protected]

See Also

lmperm plot.lmperm

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
## data
data("emergencycost")

## centrering the covariate to the mean
emergencycost$LOSc <- scale(emergencycost$LOS, scale = FALSE)

## ANCOVA
## Warning : np argument must be greater (recommendation: np>=5000)
mod_cost_0 <- aovperm(cost ~ LOSc*sex*insurance, data = emergencycost, np = 2000)
mod_cost_0

## Testing at 14 days
emergencycost$LOS14 <- emergencycost$LOS - 14

mod_cost_14 <- aovperm(cost ~ LOS14*sex*insurance, data = emergencycost, np = 2000)
mod_cost_14

## Effect of sex within the public insured
contrasts(emergencycost$insurance) <- contr.treatment
contrasts(emergencycost$sex) <- contr.sum
emergencycost$insurance <- relevel(emergencycost$insurance, ref = "public")

mod_cost_se <- aovperm(cost ~ LOSc*sex*insurance, data = emergencycost,
                        np = 2000, coding_sum = FALSE)
mod_cost_se


## Repeated measures ANCOVA
## data
data(jpah2016)

## centrering the covariate
jpah2016$bmic <- scale(jpah2016$bmi, scale = FALSE)

## Warning : np argument must be greater (recommendation: np>=5000)
mod_jpah2016 <- aovperm(iapa ~ bmic*condition*time+ Error(id/(time)),
                    data = jpah2016, method = "Rd_kheradPajouh_renaud")
mod_jpah2016

permuco documentation built on Jan. 25, 2019, 5:03 p.m.