An analytical procedure is run for 112 consecutive days. Each day, the analyses are run in four batches in order -- Batch-1, Batch-2, etc. In each batch is a QC sample, labeled QC1, QC2, etc. The following R code generates a contingency table for the data, showing the number of times each QC sample was a particular rank. For example, QC1 had the highest result 43 days out of 112 and QC4 had the lowest result 28 days out of 112. The analyst has the feeling that the first batch of the day tends to have the highest results. What statistical test should I use to check out whether or not the ranks of the QC samples are random from day to day? I understand that I should not use a chi-square test of independence between the QC sample and the ranks, but why not?

count <- c(43,26,26,17,24,33,28,27,18,27,27,40,27,26,31,28)
mat.obs <- matrix(count,nrow=4,byrow=TRUE) 
rownames(mat.obs) <- c("QC1","QC2","QC3","QC4")
colnames(mat.obs) <- c("1","2","3","4")
  • 1
    $\begingroup$ I think that this feeling comes from the fact that given the way your 4×4 matrix is generated, all rows and all columns sum to 112. This is definitely not a classical contingency table. $\endgroup$
    – Elvis
    Dec 5, 2012 at 23:14
  • $\begingroup$ The table was generated after the analyst expressed the gut feeling about the QC samples, and if nothing else it is a concise way of presenting the results for discussion. $\endgroup$
    – Tom
    Dec 6, 2012 at 11:56
  • 1
    $\begingroup$ I think the table is fine. I just point out what makes it special... I'll try to propose an answer later. $\endgroup$
    – Elvis
    Dec 6, 2012 at 12:16

1 Answer 1


I think you probably want a Friedman test. This is designed for just this case. It is a non-parametric equivalent of an ANOVA for where the data are rankings.

You can implement this in R using friedman.test() which comes with the base distribution. However, you need some additional information not contained in your summary table. You will need to present the data with 112 rows and 4 columns (one for each QC sample), with the cell being the rank from one to four of each sample for that day.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.