
Last chance! 50% off unlimited learning
Sale ends in
CochranQTest(y, ...)
"CochranQTest"(y, groups, blocks, ...)
"CochranQTest"(formula, data, subset, na.action, ...)
a ~ b | c
, where a, b and c give the data values and corresponding groups and blocks, respectively.htest
containing the following components:The null hypothesis is that apart from an effect of blocks, the location parameter of y is the same in each of the groups.
If y is a matrix, groups and blocks are obtained from the column and row indices, respectively. NA's are not allowed in groups or blocks; if y contains NA's, corresponding blocks are removed.
Note that Cochran's Q Test is analogue to the Friedman test with 0, 1 coded response. This is used here for a simple implementation.
# example in:
# http://support.sas.com/documentation/cdl/en/statugfreq/63124/PDF/default/statugfreq.pdf
# pp. S. 1824
# use expand.grid, xtabs and Untable to create the dataset
d.frm <- Untable(xtabs(c(6,2,2,6,16,4,4,6) ~ .,
expand.grid(rep(list(c("F","U")), times=3))),
colnames = LETTERS[1:3])
# rearrange to long shape
d.long <- reshape(d.frm, varying=1:3, times=names(d.frm)[c(1:3)],
v.names="resp", direction="long")
# after having done the hard work of data organisation, performing the test is a piece of cake....
CochranQTest(resp ~ time | id, data=d.long)
Run the code above in your browser using DataLab