ezPerm: Perform a factorial permutation test

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

View source: R/ezPerm.R

Description

This function provides easy non-parametric permutation test analysis of data from factorial experiments, including purely within-Ss designs (a.k.a. “repeated measures”), purely between-Ss designs, and mixed within-and-between-Ss designs.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
ezPerm(
    data
    , dv
    , wid
    , within = NULL
    , between = NULL
    , perms = 1e3
    , parallel = FALSE
    , alarm = FALSE
)

Arguments

data

Data frame containing the data to be analyzed.

dv

Name of the column in data that contains the dependent variable. Values in this column must be numeric.

wid

Name of the column in data that contains the variable specifying the case/Ss identifier.

within

Names of columns in data that contain predictor variables that are manipulated (or observed) within-Ss. If a single value, may be specified by name alone; if multiple values, must be specified as a .() list.

between

Names of columns in data that contain predictor variables that are manipulated (or observed) between-Ss. If a single value, may be specified by name alone; if multiple values, must be specified as a .() list.

perms

An integer > 0 specifying the number of permutations to compute.

parallel

Logical. If TRUE, computation will be parallel, assuming that a parallel backend has been specified (as in library(doMC);options(cores=4);registerDoMC(). Likely only to work when running R from a unix terminal.)

alarm

Logical. If TRUE, call the alarm function when ezPerm completes.

Value

A data frame containing the permutation test results.

Warning

ezPerm() is a work in progress. Under the current implementation, only main effects may be trusted.

Author(s)

Michael A. Lawrence mike.lwrnc@gmail.com
Visit the ez development site at http://github.com/mike-lawrence/ez
for the bug/issue tracker and the link to the mailing list.

See Also

link{ezANOVA}, ezBoot, ezMixed

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
39
40
41
42
43
44
45
46
47
48
49
library(plyr)
#Read in the ANT data (see ?ANT).
data(ANT)
head(ANT)
ezPrecis(ANT)

#Compute some useful statistics per cell.
cell_stats = ddply(
    .data = ANT
    , .variables = .( subnum , group , cue , flank )
    , .fun = function(x){
        #Compute error rate as percent.
        error_rate = mean(x$error)*100
        #Compute mean RT (only accurate trials).
        mean_rt = mean(x$rt[x$error==0])
        #Compute SD RT (only accurate trials).
        sd_rt = sd(x$rt[x$error==0])
        to_return = data.frame(
            error_rate = error_rate
            , mean_rt = mean_rt
            , sd_rt = sd_rt
        )
        return(to_return)
    }
)

#Compute the grand mean RT per Ss.
gmrt = ddply(
    .data = cell_stats
    , .variables = .( subnum , group )
    , .fun = function(x){
        to_return = data.frame(
            mrt = mean(x$mean_rt)
        )
        return(to_return)
    }
)

#Run a purely between-Ss permutation test on the mean_rt data.
mean_rt_perm = ezPerm(
    data = gmrt
    , dv = mrt
    , wid = subnum
    , between = group
    , perms = 1e1 #1e3 or higher is best for publication
)

#Show the Permutation test.
print(mean_rt_perm)

Example output

  subnum     group block trial     cue     flank location direction       rt
1      1 Treatment     1     1    None   Neutral       up      left 398.6773
2      1 Treatment     1     2  Center   Neutral       up      left 389.1822
3      1 Treatment     1     3  Double   Neutral       up      left 333.2186
4      1 Treatment     1     4 Spatial   Neutral       up      left 419.7640
5      1 Treatment     1     5    None Congruent       up      left 446.4754
6      1 Treatment     1     6  Center Congruent       up      left 338.9766
  error
1     0
2     0
3     0
4     0
5     0
6     0
Data frame dimensions: 5760 rows, 10 columns
             type missing values      min         max
subnum     factor       0     20        1          20
group      factor       0      2  Control   Treatment
block     numeric       0      6        1           6
trial     numeric       0     48        1          48
cue        factor       0      4     None     Spatial
flank      factor       0      3  Neutral Incongruent
location   factor       0      2     down          up
direction  factor       0      2     left       right
rt        numeric       0   5760 179.5972    657.6986
error     numeric       0      2        0           1

|                                                    |  0%                      
|=====                                               | 10% ~0 s remaining       
|==========                                          | 20% ~0 s remaining       
|===============                                     | 30% ~0 s remaining       
|====================                                | 40% ~0 s remaining       
|==========================                          | 50% ~0 s remaining       
|===============================                     | 60% ~0 s remaining       
|====================================                | 70% ~0 s remaining       
|=========================================           | 80% ~0 s remaining       
|==============================================      | 90% ~0 s remaining       
|====================================================|100% ~0 s remaining       
|====================================================|100%                      Completed after 0 s 
  Effect p p<.05
1  group 0     *

ez documentation built on May 2, 2019, 3:46 a.m.