Learn R Programming

ez (version 3.0-1)

ezPerm: Function to perform a factorial permutation test

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

ezPerm(
    data
    , dv
    , wid
    , within = NULL
    , between = NULL
    , perms
    , alarm = TRUE
)

Arguments

data
Data frame containing the data to be analyzed.
dv
.() object specifying the column in data that contains the dependent variable. Values in this column must be numeric.
wid
.() object specifying the column in data that contains the variable specifying the case/Ss identifier.
within
Optional .() object specifying one or more columns in data that contain predictor variables that are manipulated within-Ss.
between
Optional .() object specifying one or more columns in data that contain predictor variables that are manipulated between-Ss.
perms
An integer > 0 specifying the number of permutations to compute.
alarm
Logical. If TRUE (default), 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.

Details

While within and between are both optional, at least one column of data must be provided to either within or between. Any numeric or character variables in data that are specified as either wid, within or between will be converted to a factor with a warning. The expected standard deviation of p-values is approximately sqrt(true_p*(1-true_p)/perms); significance tests using an alpha of .05 should therefore employ at least 1e3 permutations. As the permutation test is computationally intensive, it is advisable to pre-test smaller values of perms and extrapolate to estimate the total test duration before attempting a full run. To facilitate such extrapolation, test duration is provided in the output after running a permutation test.

See Also

ANT, ANT2, ezANOVA, ezBoot, ezBootPlot, ezCor, ezDesign, ezMixed, link{ezMixedRel}, ezPerm, ezPlot, ezPrecis, ezPredict, ezResample, ezStats, progress_time, progress_timeCI

Examples

Run this code
#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])
        return(c(error_rate=error_rate,mean_rt=mean_rt,sd_rt=sd_rt))
    }
)

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

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

#Show the Permutation test.
print(mean_rt_perm)

Run the code above in your browser using DataLab