Data to quade.test() can be passed in a matrix or a data frame. If the the lines in the data frame are reordered the quade.test() has a different result. Comparing this behavior with the freidman.test(), the friedman.test() is invariant to reordered data frames. I can only speculate if this is connected to the lines from source code of friedman.test() that seem to lack in the quade.test() code: ## Need to ensure consistent order of observations within ## blocks. o <- order(groups, blocks) y <- y[o] groups <- groups[o] blocks <- blocks[o] The following example code invokes quade.test() with a data frame, a reordered data frame and matrices converted from both data frames. In case of the original data frame and both matrices it yields the same result. Only in case of the reordered data frame it shows a different result. ## constructing a data frame with the same data as in the quade.test help Store <- c(1,1,1,1,1,2,2,2,2,2,3,3,3,3,3,4,4,4,4,4,5,5,5,5,5,6,6,6,6,6,7,7,7,7,7) Brand <- c("A","B","C","D","E","A","B","C","D","E","A","B","C","D","E","A","B","C","D","E","A","B","C","D","E","A","B","C","D","E","A","B","C","D","E") nsold <- c( 5, 4, 7, 10, 12, 1, 3, 1, 0, 2, 16, 12, 22, 22, 35, 5, 4, 3, 5, 4, 10, 9, 7, 13, 10, 19, 18, 28, 37, 58, 10, 7, 6, 8, 7) df.example <- data.frame(Store, Brand, nsold) # this data.frame can be converted to a matrix that is the same # than the one from the help matrix.example <- xtabs(nsold~Store+Brand,data=df.example) # as expected this yields the same result quade.test(matrix.example) # using the interface with formula and data frame yields also the same result quade.test(nsold~Brand|Store,data=df.example) # now the rows in the data frame are put in another order df.reorder <-df.example[with(df.example, order(nsold)), ] # again this reordered data frame can be converted to a matrix matrix.from.reordered <- xtabs(nsold~Store+Brand,data=df.reorder) # the matrix is identical to the first matrix # (only some attributes are different and are deleted first) attr(matrix.example, "class") <- NULL attr(matrix.example, "call") <- NULL attr(matrix.from.reordered, "class") <- NULL attr(matrix.from.reordered, "call") <- NULL identical(matrix.from.reordered,matrix.example) # it therefore yields the same result quade.test(matrix.from.reordered) # using quade.test now with the reordered data frame it shows a # different result quade.test(nsold~Brand|Store,data=df.reorder) # the expected behavior would be that quade.test is invariant # to a different order of the rows and show the same result as # in the first three cases # with the similar friedman.test() the different order is no problem # all 4 cases show the same result friedman.test(matrix.example) friedman.test(nsold~Brand|Store,data=df.example) friedman.test(matrix.from.reordered) friedman.test(nsold~Brand|Store,data=df.reorder)

Created attachment 2357 [details] ensure quade.test.default works for unordered data I agree with L. Kahl's analysis. Here is a patch to handle the case of an unordered data frame.

In fact, essentially the same fix was made to friedman.test back in 2005, Index: src/library/stats/R/friedman.test.R =================================================================== --- src/library/stats/R/friedman.test.R (revision 33356) +++ src/library/stats/R/friedman.test.R (revision 33357) @@ -19,6 +19,12 @@ stop("not an unreplicated complete block design") groups <- factor(groups) blocks <- factor(blocks) + ## Need to ensure consistent order of observations within + ## blocks. + o <- order(groups, blocks) + y <- y[o] + groups <- groups[o] + blocks <- blocks[o] } k <- nlevels(groups)

Thank you both. You were entirely on spot. Fix committed to R-devel with svn r75012 Planned to port to 'R 3.5.1 patched' within a few days.