# Demonstration of mediansByMask()
x<-1:6
mask<-rbind(c(TRUE,FALSE,FALSE),
c(TRUE,FALSE,FALSE),
c(FALSE,TRUE,FALSE),
c(FALSE,TRUE,FALSE),
c(FALSE,FALSE,TRUE),
c(FALSE,FALSE,TRUE))
mediansByMask(x,mask)
# Compute split-halves for a single
# participant, stratified by stimulus
data(foodAAT)
currdata<-foodAAT[foodAAT$subjectid==3,]
currdata$stratfactor<-
interaction(currdata$is_pull,
currdata$is_target,
currdata$stimid)
currdata<-currdata[order(currdata$stratfactor),]
groupsizes<-
rle(as.character(currdata$stratfactor))$lengths
mysplits<-
stratifiedItersplits(splits=1000,
groupsizes=groupsizes)
# Median for half 1
mediansByMask(currdata$RT,mysplits==1)
#How to use meansByMask()
meansByMask(x,mask)
sd(meansByMask(currdata$RT,mysplits==1))
# How to use sdsByMask() to compute
# mask-based D-scores
meansByMask(currdata$RT,mysplits==1) /
sdsByMask(currdata$RT,mysplits==1)
# Compute the bootstrapped
# standard error of a median
weights<-
bootstrapWeights(size=nrow(currdata),
times=1000)
bootmeds<-mediansByWeight(currdata$RT,weights)
sd(bootmeds) # bootstrapped standard error
# Compute the bootstrapped
# standard error of a mean
bootmeans<-meansByWeight(currdata$RT,weights)
sd(bootmeans) # bootstrapped standard error
# exact standard error for comparison
sd(currdata$RT)/sqrt(length(currdata$RT))
# Use sdsByWeight to compute bootstrapped D-scores
bootsds<-sdsByWeight(currdata$RT,weights)
# bootstrapped standard error of D-score
sd(bootmeans/bootsds)
Run the code above in your browser using DataLab