# NOT RUN {
data(toydata)
# generates a permuted data set with 2-level data
permcluster(cluster=c("classroom"),data=toydata,leveltested=1)
# generates a permuted data set with 4-level data to test for level 2
permcluster(cluster=c("region","school","classroom"),
data=toydata,leveltested=2)
# performing a permutation test with another
# test statistic might look like this
# }
# NOT RUN {
pval=0
# compute the statistic with the original data. Call in stato.
for (i in 1:npermut)
{
pdata=permcluster(cluster=c("classroom"),data=toydata,leveltested=1)
# compute the statistic with pdata using the new column
# clusperm1 instead of classroom as the cluster index.
# call it statp.
pval=pval+(statp>stato)
}
pval/npermut
# }
# NOT RUN {
# }
Run the code above in your browser using DataLab