medianTest function

Brown-Mood Median Test

Brown-Mood Median Test

Performs Brown-Mood Median Test.

medianTest(x, ...) ## Default S3 method: medianTest(x, g, simulate.p.value = FALSE, B = 2000, ...) ## S3 method for class 'formula' medianTest( formula, data, subset, na.action, simulate.p.value = FALSE, B = 2000, ... )

Arguments

  • x: a numeric vector of data values, or a list of numeric data vectors.
  • ...: further arguments to be passed to or from methods.
  • g: a vector or factor object giving the group for the corresponding elements of "x". Ignored with a warning if "x" is a list.
  • simulate.p.value: a logical indicating whether to compute p-values by Monte-Carlo simulation.
  • B: an integer specifying the number of replicates used in the Monte-Carlo test.
  • formula: a formula of the form response ~ group where response gives the data values and group a vector or factor of the corresponding groups.
  • data: an optional matrix or data frame (or similar: see model.frame) containing the variables in the formula formula. By default the variables are taken from environment(formula).
  • subset: an optional vector specifying a subset of observations to be used.
  • na.action: a function which indicates what should happen when the data contain NAs. Defaults to getOption("na.action").

Returns

A list with class htest . For details see chisq.test.

Details

The null hypothesis, Hc("0:theta1=theta2=\n_0: \\theta_1 = \\theta_2 =\n", "ldots=thetak\\ldots = \\theta_k")

is tested against the alternative, HA:θiθj  (ij)_\mathrm{A}: \theta_i \ne \theta_j ~~(i \ne j), with at least one unequality beeing strict.

Examples

## Hollander & Wolfe (1973), 116. ## Mucociliary efficiency from the rate of removal of dust in normal ## subjects, subjects with obstructive airway disease, and subjects ## with asbestosis. x <- c(2.9, 3.0, 2.5, 2.6, 3.2) # normal subjects y <- c(3.8, 2.7, 4.0, 2.4) # with obstructive airway disease z <- c(2.8, 3.4, 3.7, 2.2, 2.0) # with asbestosis g <- factor(x = c(rep(1, length(x)), rep(2, length(y)), rep(3, length(z))), labels = c("ns", "oad", "a")) dat <- data.frame( g = g, x = c(x, y, z)) ## AD-Test adKSampleTest(x ~ g, data = dat) ## BWS-Test bwsKSampleTest(x ~ g, data = dat) ## Kruskal-Test ## Using incomplete beta approximation kruskalTest(x ~ g, dat, dist="KruskalWallis") ## Using chisquare distribution kruskalTest(x ~ g, dat, dist="Chisquare") ## Not run: ## Check with kruskal.test from R stats kruskal.test(x ~ g, dat) ## End(Not run) ## Using Conover's F kruskalTest(x ~ g, dat, dist="FDist") ## Not run: ## Check with aov on ranks anova(aov(rank(x) ~ g, dat)) ## Check with oneway.test oneway.test(rank(x) ~ g, dat, var.equal = TRUE) ## End(Not run) ## Median Test asymptotic medianTest(x ~ g, dat) ## Median Test with simulated p-values set.seed(112) medianTest(x ~ g, dat, simulate.p.value = TRUE)

References

Brown, G.W., Mood, A.M., 1951, On Median Tests for Linear Hypotheses, in: Proceedings of the Second Berkeley Symposium on Mathematical Statistics and Probability. University of California Press, pp. 159–167.

See Also

chisq.test.

  • Maintainer: Thorsten Pohlert
  • License: GPL (>= 3)
  • Last published: 2024-09-08

Useful links