As @caracal's said, this script implements a permutation-based approach to Friedman's test with the coin package.
The maxT procedure is rather complex and there is no relation with the traditional $\chi^2$ statistic you're probably used to get after a Friedman ANOVA. The general idea is to control the FWER. Let's say you perform 1000 permutations, for every variable of interest, then you can derive not only pointwise empirical p-values for each variable (as you would do with a single permutation test) but also a value that accounts for the fact that you tested all those variables at the same time. The latter is achieved by comparing each observed test statistic against the maximum of permuted statistics over all variables. In other words, this p-value reflects the chance of seeing a test statistic as large as the one you observed, given you've performed as many tests.
More information (in a genomic context, and with algorithmic considerations) can be found in
Dudoit, S., Shaffer, J.P., and
Boldrick, J.C. (2003). Multiple
Hypothesis Testing in Microarray
Experiments. Statistical
Science, 18(1), 71–103.
(Here are some slides from the same author with applications in R with the multtest package.)
Another good reference is Multiple Testing Procedures with Applications to Genomics, by Dudoit and van der Laan (Springer, 2008).
Now, if you want to get more "traditional" statistic, you can use the agricolae package which has a friedman()
function that performs the overall Friedman's test followed by post-hoc comparisons.
The permutation method yields a maxT=3.24, p=0.003394, suggesting an overall effect of the target when accounting for the blocking factor. The post-hoc tests basically indicate that only results for Wine A vs. Wine C (p=0.003400) are statistically different at the 5% level.
Using the non-parametric test, we have
> library(agricolae)
> with(WineTasting, friedman(Taster, Wine, Taste, group=FALSE))
Friedman's Test
===============
Adjusted for ties
Value: 11.14286
Pvalue chisq : 0.003805041
F value : 7.121739
Pvalue F: 0.002171298
Alpha : 0.05
t-Student : 2.018082
Comparison between treatments
Sum of the ranks
Difference pvalue sig LCL UCL
Wine A - Wine B 6 0.301210 -5.57 17.57
Wine A - Wine C 21 0.000692 *** 9.43 32.57
Wine B - Wine C 15 0.012282 * 3.43 26.57
The two global tests agree and basically say there is a significant effect of Wine type. We would, however, reach different conclusions about the pairwise difference. It should be noted that the above pairwise tests (Fisher's LSD) are not really corrected for multiple comparisons, although the difference B-C would remain significant even after Holm's correction (which also provides strong control of the FWER).
To my surprise a couple of searches didn't seem to turn up prior discussion of post hoc for goodness of fit; I expect there's probably one here somewhere, but since I can't locate it easily, I think it's reasonable to turn my comments into an answer, so that people can at least find this one using the same search terms I just used.
The pairwise comparisons you seek to do (conditional on only comparing the two groups involved) are sensible.
This amounts to taking group pairs and testing whether the proportion in one of the groups differs from 1/2 (a one-sample proportions test). This - as you suggest - can be done as a z-test (though binomial test and chi-square goodness of fit would also work).
Many of the usual approaches to dealing with the overall type I error rate should work here (including Bonferroni -- along with the usual issues that can come with it).
Best Answer
I agree with @nico's comments. This is in effect an expansion of them.
1) Although ad hoc is academic or researchers' jargon, it should not be understood as a technical term. There is no precise definition (or antonym) to be discovered or found lurking on the internet.
2) Although "to the purpose" fits the Latin as well as any other translation, there is often a negative overtone in the way it is used which is dismissive, disparaging, deflationary, or deprecatory, whether in criticism of other people's work or (perhaps more commonly) of one's own work. However, this is not universal: ad hoc allows a positive translation such as "fit for purpose" (you read it here first?).
3) Commonly, a researcher would describe a test or more generally any procedure as ad hoc as a qualification to defuse possible criticism. The implication would be that although what was done seems appropriate in the circumstances, it should not be taken to follow from general principles or necessarily to have wider applications. There is often an implication that the researcher would willingly use a better-grounded procedure if one could be identified.
Examples often serve better than definitions. Faced with distributions that can be negative, zero or positive, and are long-tailed in both directions, I have used cube root transformations. There is no theory worthy of the name behind this; it just works well for those circumstances and can thus be described as ad hoc.
The connection with post hoc is a matter of a common Latin word, but there is no statistical link.
I know of no reason to hyphenate here: ad hoc and post hoc are the original Latin phrases which remain widely acceptable in academic and research literature.