% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/friedman_nemenyi_test.R
\name{friedman_nemenyi_test}
\alias{friedman_nemenyi_test}
\title{Nemenyi Post-Hoc Test for Friedman Rank Sums}
\usage{
friedman_nemenyi_test(data, formula, detailed = FALSE)
}
\arguments{
\item{data}{a data.frame containing the variables in the formula.}

\item{formula}{a formula of the form \code{a ~ b | c}, where \code{a}
(numeric) is the dependent variable name; \code{b} is the within-subjects
factor variable (the treatment); and \code{c} is the column name containing
the individuals/subjects (block) identifier. Should be unique per individual.}

\item{detailed}{logical value. If TRUE, returns the rank-sum estimate and the
test method in the output.}
}
\value{
return a data frame with some of the following columns: \itemize{
 \item \code{.y.}: the y (outcome) variable used in the test. \item
 \code{group1,group2}: the compared treatments in the pairwise tests. \item
 \code{n1,n2}: the number of blocks (subjects) contributing to each treatment.
 \item \code{estimate}: the rank-sum difference. \item \code{estimate1,
 estimate2}: the rank sums of the two treatments, respectively. \item
 \code{statistic}: the studentized-range test statistic. \item \code{p.adj}:
 the p-value (already adjusted for multiple comparisons via the studentized
 range distribution). \item \code{method}: the statistical test used to
 compare groups. \item \code{p.adj.signif}: the significance level of the
 adjusted p-values. }

 The \strong{returned object has an attribute called args}, which is a list
 holding the test arguments.
}
\description{
Performs the Nemenyi (Wilcoxon-Nemenyi-McDonald-Thompson) all-pairs
 post-hoc test for a two-way balanced complete block design, following a
 significant Friedman rank sum test. The treatment rank sums are compared
 pairwise and the test statistic is referred to the studentized range
 distribution, which already accounts for the multiplicity of the all-pairs
 comparisons (so, as for \code{\link{tukey_hsd}()}, there is no separate
 p-value adjustment step). It should only be used as a post-hoc procedure when
 the Friedman test is itself significant.

 The Nemenyi test is the rank-based, repeated-measures analogue of Tukey's
 HSD. Unlike \code{\link{friedman_conover_test}()} (the Durbin-Conover test),
 it does not borrow the residual rank variance and is therefore more
 conservative.
}
\details{
For a balanced complete block design with \eqn{b} blocks and \eqn{k}
 treatments, the observations within each block are ranked. Let \eqn{R_j} be
 the sum of the within-block ranks for treatment \eqn{j}. The pairwise
 statistic for treatments \eqn{i} and \eqn{j} is \deqn{q_{ij} =
 \frac{|R_i - R_j|}{\sqrt{b\,k\,(k+1)/12}}} and the p-value is obtained from
 the studentized range distribution with \eqn{k} groups and infinite degrees
 of freedom.
}
\examples{
# A balanced complete block design: 3 treatments measured on 6 subjects
df <- data.frame(
  id        = factor(rep(1:6, 3)),
  treatment = factor(rep(c("A", "B", "C"), each = 6)),
  score     = c(4, 6, 3, 5, 4, 5,    7, 8, 6, 7, 9, 6,    6, 9, 7, 8, 8, 9)
)

# Omnibus Friedman test
df \%>\% friedman_test(score ~ treatment | id)

# Nemenyi all-pairs post-hoc
df \%>\% friedman_nemenyi_test(score ~ treatment | id)
}
\references{
Nemenyi, P. (1963) Distribution-free Multiple Comparisons. PhD
 Thesis, Princeton University.

 Hollander, M., Wolfe, D. A. (1973) Nonparametric Statistical Methods. Wiley.
}
\seealso{
\code{\link{friedman_test}}, \code{\link{friedman_conover_test}},
  \code{\link{friedman_effsize}}
}
