Learn R Programming

ez (version 3.0-1)

ezResample: Function to resample data.

Description

This function resamples data (useful when bootstrapping and used by ezBoot).

Usage

ezResample(
	data
	, dv
	, wid
	, within = NULL
	, between = NULL
	, resample_within = FALSE
)

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 (or observed) within-Ss.
between
Optional .() object specifying one or more columns in data that contain predictor variables that are manipulated (or observed) between-Ss.
resample_within
Logical. If TRUE, and if there are multiple observations per subject within each cell of the design specified by the factorial combination of variables supplied to within and between, then these observations-within-cells are resa

Value

  • A data frame consisting of the resampled data

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)


#Bootstrap the within-cell variances
var_boots = ldply(
	.data = 1:1e1 #1e3 or higher should be used for publication
	, .fun = function(x){
		this_resample = ezResample(
			data = ANT[ANT$error==0,]
			, dv = .(rt)
		    , wid = .(subnum)
		    , within = .(cue,flank)
		    , between = .(group)
		)
		cell_vars = ddply(
			.data = this_resample
			, .variables = .(subnum,cue,flank,group)
			, .fun = function(x){
				to_return = data.frame(
					value = var(x$rt)
				)
				return(to_return)
			}
		)
		mean_cell_vars = ddply(
			.data = cell_vars
			, .variables = .(cue,flank,group)
			, .fun = function(x){
				to_return = data.frame(
					value = mean(x$value)
				)
				return(to_return)
			}
		)
		mean_cell_vars$iteration = x
		return(mean_cell_vars)
	}
	, .progress = 'timeCI'
)

Run the code above in your browser using DataLab