## Not run:
# #
# # Compute power of the F-ratio test for category selectivity over
# # a range of plausible simulation parameters, placing results
# # in a dataframe. This computes values a subset of which were used to
# # generate figure 5 of Steinmetz & Thorp, 2013.
# #
#
# if (exists('res',inherits=FALSE)) rm('res')
#
# numRuns<-1000
#
# for (numCats in c(5,10,20,30)) {
# for (anovaP in c(0.01,0.05)) {
# for (meanRate in seq(0.5,10,by=0.5)) {
# for (fracChange in c(0.1,0.25,0.5,1)) {
# minRate<-meanRate*(1-fracChange)
# maxRate<-meanRate*(1+fracChange)
# respLevels<-seq(minRate,maxRate,length.out=numCats)
#
# print(paste(numCats,anovaP,meanRate,fracChange))
#
# numSig<-compPowerCatSelectivity(respLevels,
# alpha=anovaP, numRuns=numRuns,
# showProgress=TRUE)
#
# df1<-data.frame(numCats=numCats,
# fracChange=fracChange, anovaP=anovaP, meanRate=meanRate,
# frac=numSig/numRuns)
#
# if (!exists('res',inherits=FALSE)) res<-df1
# else res<-rbind(res,df1)
# }
# }
# }
# }
#
# ## End(Not run)
#
# Example of smaller simulation corresponding to circle at 0.5 fractional
# change in figure 5A of Steinmetz & Thorp, 2013.
#
numRuns<-5
numCats<-30
anovaP<-0.05
meanRate<-0.5
fracChange<-0.5
minRate<-meanRate*(1-fracChange)
maxRate<-meanRate*(1+fracChange)
respLevels<-seq(minRate,maxRate,length.out=numCats)
print(paste(numCats,anovaP,meanRate,fracChange))
numSig<-compPowerCatSelectivity(respLevels,
alpha=anovaP, numRuns=numRuns,
showProgress=TRUE)
df1<-data.frame(numCats=numCats,
fracChange=fracChange, anovaP=anovaP, meanRate=meanRate,
frac=numSig/numRuns)
Run the code above in your browser using DataLab