aovperm {permuco} | R Documentation |
P-values based on permutation tests for ANOVA and repeated measures ANOVA designs.
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
aovperm(
formula,
data = NULL,
np = 5000,
method = NULL,
type = "permutation",
...
)
Arguments
formula |
A formula object. The formula for repeated measures ANOVA should be written using the same notation as aov by adding
|
data |
A data frame or matrix. |
np |
The number of permutations. Default value is |
method |
A character string indicating the method used to handle nuisance variables. Default is |
type |
A character string to specify the type of transformations: "permutation" and "signflip" are available. Is overridden if P is given. See help from Pmat. |
... |
Futher arguments, see details. |
Details
The following methods are available for the fixed effects model defined as y = D\eta + X\beta + \epsilon
. If we want to test \beta = 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\eta + X\beta + E\kappa + Z\gamma+ \epsilon
. If we want to test \beta = 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)
jaromil.frossard@unige.ch
See Also
Other main function:
clusterlm()
,
lmperm()
Examples
## 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
## same analysis but with signflip
## Warning : np argument must be greater (recommendation: np>=5000)
mod_cost_0s <- aovperm(cost ~ LOSc*sex*insurance, data = emergencycost, type="signflip", np = 2000)
mod_cost_0s
## 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