Movatterモバイル変換


[0]ホーム

URL:


Type:Package
Title:Calculate Pairwise Multiple Comparisons of Mean Rank SumsExtended
Version:1.9.12
Date:2024-09-07
Description:For one-way layout experiments the one-way ANOVA can be performed as an omnibus test. All-pairs multiple comparisons tests (Tukey-Kramer test, Scheffe test, LSD-test) and many-to-one tests (Dunnett test) for normally distributed residuals and equal within variance are available. Furthermore, all-pairs tests (Games-Howell test, Tamhane's T2 test, Dunnett T3 test, Ury-Wiggins-Hochberg test) and many-to-one (Tamhane-Dunnett Test) for normally distributed residuals and heterogeneous variances are provided. Van der Waerden's normal scores test for omnibus, all-pairs and many-to-one tests is provided for non-normally distributed residuals and homogeneous variances. The Kruskal-Wallis, BWS and Anderson-Darling omnibus test and all-pairs tests (Nemenyi test, Dunn test, Conover test, Dwass-Steele-Critchlow- Fligner test) as well as many-to-one (Nemenyi test, Dunn test, U-test) are given for the analysis of variance by ranks. Non-parametric trend tests (Jonckheere test, Cuzick test, Johnson-Mehrotra test, Spearman test) are included. In addition, a Friedman-test for one-way ANOVA with repeated measures on ranks (CRBD) and Skillings-Mack test for unbalanced CRBD is provided with consequent all-pairs tests (Nemenyi test, Siegel test, Miller test, Conover test, Exact test) and many-to-one tests (Nemenyi test, Demsar test, Exact test). A trend can be tested with Pages's test. Durbin's test for a two-way balanced incomplete block design (BIBD) is given in this package as well as Gore's test for CRBD with multiple observations per cell is given. Outlier tests, Mandel's k- and h statistic as well as functions for Type I error and Power analysis as well as generic summary, print and plot methods are provided.
Depends:R (≥ 3.5.0)
Imports:mvtnorm (≥ 1.0), multcompView, gmp, Rmpfr, SuppDists,kSamples (≥ 1.2.7), BWStest (≥ 0.2.1), MASS, stats
Suggests:xtable, graphics, knitr, rmarkdown, car, e1071, multcomp,pwr, NSM3
SystemRequirements:gmp (>= 4.2.3), mpfr (>= 3.0.0) | file README.md
SystemRequirementsNote:see >> README.md
SysDataCompression:gzip
VignetteBuilder:knitr, rmarkdown
Classification/MSC-2010:62J15, 62J10, 62G10, 62F03, 62G30
NeedsCompilation:yes
Encoding:UTF-8
LazyData:true
RoxygenNote:7.3.1
License:GPL (≥ 3)
Packaged:2024-09-08 09:18:42 UTC; thorsten
Author:Thorsten PohlertORCID iD [aut, cre]
Maintainer:Thorsten Pohlert <thorsten.pohlert@gmx.de>
Repository:CRAN
Date/Publication:2024-09-08 10:10:03 UTC

Cochran's distribution

Description

Distribution function and quantile functionfor Cochran's distribution.

Usage

qcochran(p, k, n, lower.tail = TRUE, log.p = FALSE)pcochran(q, k, n, lower.tail = TRUE, log.p = FALSE)

Arguments

p

vector of probabilities.

k

number of groups.

n

(average) sample size of the k groups.

lower.tail

logical; if TRUE (default),probabilities areP[X \leq x] otherwise,P[X > x].

log.p

logical; if TRUE, probabilities p are given as log(p).

q

vector of quantiles.

Value

pcochran gives the distribution function andqcochran gives the quantile function.

References

Cochran, W.G. (1941) The distribution of the largest of a set of estimatedvariances as a fraction of their total.Ann. Eugen.11, 47–52.

Wilrich, P.-T. (2011) Critical values of Mandel's h and k,Grubbs and the Cochran test statistic.Adv. Stat. Anal..doi:10.1007/s10182-011-0185-y.

See Also

FDist

Examples

qcochran(0.05, 7, 3)

Grubbs D* distribution

Description

Distribution function for Grubbs D* distribution.

Usage

pdgrubbs(q, n, m = 10000, lower.tail = TRUE, log.p = FALSE)

Arguments

q

vector of quantiles.

n

total sample size.

m

number of Monte-Carlo replicates. Defaults to10,000.

lower.tail

logical; if TRUE (default),probabilities areP[X \leq x] otherwise,P[X > x].

log.p

logical; if TRUE, probabilities p are given as log(p).

Value

pgrubbs gives the distribution function

References

Grubbs, F.E. (1950) Sample criteria for testing outlying observations,Ann. Math. Stat.21, 27–58.

Wilrich, P.-T. (2011) Critical values of Mandel's h and k,Grubbs and the Cochran test statistic,Adv. Stat. Anal..doi:10.1007/s10182-011-0185-y.

See Also

Grubbs

Examples

pdgrubbs(0.62, 7, 1E4)

Generalized Siegel-Tukey Test of Homogeneity ofScales

Description

Performs a Siegel-Tukey k-sample rank dispersion test.

Usage

GSTTest(x, ...)## Default S3 method:GSTTest(x, g, dist = c("Chisquare", "KruskalWallis"), ...)## S3 method for class 'formula'GSTTest(  formula,  data,  subset,  na.action,  dist = c("Chisquare", "KruskalWallis"),  ...)

Arguments

x

a numeric vector of data values, or a list of numeric datavectors.

...

further arguments to be passed to or from methods.

g

a vector or factor object giving the group for thecorresponding elements of"x".Ignored with a warning if"x" is a list.

dist

the test distribution. Defaults's to"Chisquare".

formula

a formula of the formresponse ~ group whereresponse gives the data values andgroup a vector orfactor of the corresponding groups.

data

an optional matrix or data frame (or similar: seemodel.frame) containing the variables in theformulaformula. By default the variables are taken fromenvironment(formula).

subset

an optional vector specifying asubset of observations to be used.

na.action

a function which indicates what should happen whenthe data containNAs. Defaults togetOption("na.action").

Details

Meyer-Bahlburg (1970) has proposed a generalized Siegel-Tukeyrank dispersion test for thek-sample case.Likewise to thefligner.test, this testis a nonparametric test for testing the homogegeneity ofscales in several groups.Let\theta_i, and\lambda_i denotelocation and scale parameter of theith group,then for the two-tailed case, the null hypothesisH:\lambda_i / \lambda_j = 1 | \theta_i = \theta_j, ~ i \ne j istested against the alternative,A:\lambda_i / \lambda_j \ne 1with at least one inequality beeing strict.

The data are combinedly ranked according to Siegel-Tukey.The ranking is done by alternate extremes (rank 1 is lowest,2 and 3 are the two highest, 4 and 5 are the two next lowest, etc.).

Meyer-Bahlburg (1970) showed, that the Kruskal-Wallis H-testcan be employed on the Siegel-Tukey ranks.The H-statistic is assymptoticallychi-squared distributed withv = k - 1 degreeof freedom, the default test distribution is consequentlydist = "Chisquare". Ifdist = "KruskalWallis" is selected,an incomplete beta approximation is used for the calculationof p-values as implemented in the functionpKruskalWallis of the packageSuppDists.

Value

A list with class"htest" containing the following components:

method

a character string indicating what type of test was performed.

data.name

a character string giving the name(s) of the data.

statistic

the estimated quantile of the test statistic.

p.value

the p-value for the test.

parameter

the parameters of the test statistic, if any.

alternative

a character string describing the alternative hypothesis.

estimates

the estimates, if any.

null.value

the estimate under the null hypothesis, if any.

Note

If ties are present, a tie correction is performed anda warning message is given. The GSTTest is sensitive tomedian differences, likewise to the Siegel-Tukey test.It is thus appropriate to apply this test on the residualsof a one-way ANOVA, rather than on the original data(see example).

References

H.F.L. Meyer-Bahlburg (1970), A nonparametric test for relativespread in k unpaired samples,Metrika15, 23–29.

See Also

fligner.test,pKruskalWallis,Chisquare,fligner.test

Examples

GSTTest(count ~ spray, data = InsectSprays)## as means/medians differ, apply the test to residuals## of one-way ANOVAans <- aov(count ~ spray, data = InsectSprays)GSTTest( residuals( ans) ~ spray, data =InsectSprays)

Grubbs distribution

Description

Distribution function and quantile functionfor Grubbs distribution.

Usage

qgrubbs(p, n)pgrubbs(q, n, lower.tail = TRUE)

Arguments

p

vector of probabilities.

n

total sample size.

q

vector of quantiles.

lower.tail

logical; if TRUE (default),probabilities areP[X \leq x] otherwise,P[X > x].

Value

pgrubbs gives the distribution function andqgrubbs gives the quantile function.

References

Grubbs, F. E. (1950) Sample criteria for testing outlying observations.Ann. Math. Stat.21, 27–58.

Wilrich, P.-T. (2011) Critical values of Mandel's h and k,Grubbs and the Cochran test statistic.Adv. Stat. Anal..doi:10.1007/s10182-011-0185-y.

See Also

TDist

Examples

qgrubbs(0.05, 7)

Extended One-Sided Studentised Range Test

Description

Performs Nashimoto-Wright's extendedone-sided studentised rangetest against an ordered alternative for normal datawith equal variances.

Usage

MTest(x, ...)## Default S3 method:MTest(x, g, alternative = c("greater", "less"), ...)## S3 method for class 'formula'MTest(  formula,  data,  subset,  na.action,  alternative = c("greater", "less"),  ...)## S3 method for class 'aov'MTest(x, alternative = c("greater", "less"), ...)

Arguments

x

a numeric vector of data values, or a list of numeric datavectors.

...

further arguments to be passed to or from methods.

g

a vector or factor object giving the group for thecorresponding elements of"x".Ignored with a warning if"x" is a list.

alternative

the alternative hypothesis. Defaults togreater.

formula

a formula of the formresponse ~ group whereresponse gives the data values andgroup a vector orfactor of the corresponding groups.

data

an optional matrix or data frame (or similar: seemodel.frame) containing the variables in theformulaformula. By default the variables are taken fromenvironment(formula).

subset

an optional vector specifying asubset of observations to be used.

na.action

a function which indicates what should happen whenthe data containNAs. Defaults togetOption("na.action").

Details

The procedure uses the property of a simple order,\theta_m' - \mu_m \le \mu_j - \mu_i \le \mu_l' - \mu_l\qquad (l \le i \le m~\mathrm{and}~ m' \le j \le l').The null hypothesis H_{ij}: \mu_i = \mu_j is tested againstthe alternative A_{ij}: \mu_i < \mu_j for any1 \le i < j \le k.

The all-pairs comparisons test statistics for a balanced design are

\hat{h}_{ij} = \max_{i \le m < m' \le j} \frac{\left(\bar{x}_{m'} - \bar{x}_m \right)} {s_{\mathrm{in}} / \sqrt{n}},

withn = n_i; ~ N = \sum_i^k n_i ~~ (1 \le i \le k),\bar{x}_i the arithmetic mean of theith group,ands_{\mathrm{in}}^2 the within ANOVA variance. The null hypothesis is rejected,if\hat{h} > h_{k,\alpha,v}, withv = N - kdegree of freedom.

For the unbalanced case with moderate imbalance the test statistic is

\hat{h}_{ij} = \max_{i \le m < m' \le j} \frac{\left(\bar{x}_{m'} - \bar{x}_m \right)} {s_{\mathrm{in}} \left(1/n_m + 1/n_{m'}\right)^{1/2}},

The null hypothesis is rejected, if\hat{h}_{ij} > h_{k,\alpha,v} / \sqrt{2}.

The function does not return p-values. Instead the critical h-valuesas given in the tables of Hayter (1990) for\alpha = 0.05 (one-sided)are looked up according to the number of groups (k) andthe degree of freedoms (v).

Value

method

a character string indicating what type of test was performed.

data.name

a character string giving the name(s) of the data.

statistic

the estimated statistic(s)

crit.value

critical values for\alpha = 0.05.

alternative

a character string describing the alternative hypothesis.

parameter

the parameter(s) of the test distribution.

dist

a string that denotes the test distribution.

There are print and summary methods available.

Note

The function will give a warning for the unbalanced case and returns thecritical valueh_{k,\alpha,\infty} / \sqrt{2}.

References

Hayter, A. J.(1990) A One-Sided Studentised RangeTest for Testing Against a Simple Ordered Alternative,Journal of the American Statistical Association85, 778–785.

Nashimoto, K., Wright, F.T., (2005) Multiple comparison proceduresfor detecting differences in simply ordered means.Comput. Statist. Data Anal.48, 291–306.

See Also

osrtTest,NPMTest

Examples

##md <- aov(weight ~ group, PlantGrowth)anova(md)osrtTest(md)MTest(md)

Mandel's h Distribution

Description

Distribution function and quantile functionfor Mandel's h distribution.

Usage

qmandelh(p, k, lower.tail = TRUE, log.p = FALSE)pmandelh(q, k, lower.tail = TRUE, log.p = FALSE)

Arguments

p

vector of probabilities.

k

number of groups.

lower.tail

logical; if TRUE (default),probabilities areP[X \leq x] otherwise,P[X > x].

log.p

logical; ifTRUE, probabilitiesare given as log(p).

q

vector of quantiles.

Value

pmandelh gives the distribution function andqmandelh gives the quantile function.

Source

The code forpmandelh was taken from:
Stephen L R Ellison. (2017). metRology: Support for MetrologicalApplications. R package version 0.9-26-2.https://CRAN.R-project.org/package=metRology

References

Practice E 691 (2005)Standard Practice forConducting an Interlaboratory Study to Determine thePrecision of a Test Method, ASTM International.

See Also

mandelhTest

Examples

## We need a two-sided upper-tail quantileqmandelh(p = 0.005/2, k = 7, lower.tail=FALSE)

Mandel's k Distribution

Description

Distribution function and quantile functionfor Mandel's k distribution.

Usage

qmandelk(p, k, n, lower.tail = TRUE, log.p = FALSE)pmandelk(q, k, n, lower.tail = TRUE, log.p = FALSE)

Arguments

p

vector of probabilities.

k

number of groups.

n

number of replicates per group.

lower.tail

logical; if TRUE (default),probabilities areP[X \leq x] otherwise,P[X > x].

log.p

logical; ifTRUE, probabilitiesare given as log(p).

q

vector of quantiles.

Value

pmandelk gives the distribution function andqmandelk gives the quantile function.

Source

The code forpmandelk was taken from:
Stephen L R Ellison. (2017). metRology: Support for MetrologicalApplications. R package version 0.9-26-2.https://CRAN.R-project.org/package=metRology

Note

The functions are only appropriate for balanced designs.

References

Practice E 691 (2005)Standard Practice forConducting an Interlaboratory Study to Determine thePrecision of a Test Method, ASTM International.

See Also

mandelkTest

pmandelh,qmandelh

Examples

qmandelk(0.005, 7, 3, lower.tail=FALSE)

All-Pairs Comparisons for Simply Ordered Mean Ranksums

Description

Performs Nashimoto and Wright's all-pairs comparison procedurefor simply ordered mean ranksums.

Usage

NPMTest(x, ...)## Default S3 method:NPMTest(  x,  g,  alternative = c("greater", "less"),  method = c("look-up", "boot", "asympt"),  nperm = 10000,  ...)## S3 method for class 'formula'NPMTest(  formula,  data,  subset,  na.action,  alternative = c("greater", "less"),  method = c("look-up", "boot", "asympt"),  nperm = 10000,  ...)

Arguments

x

a numeric vector of data values, or a list of numeric datavectors.

...

further arguments to be passed to or from methods.

g

a vector or factor object giving the group for thecorresponding elements of"x".Ignored with a warning if"x" is a list.

alternative

the alternative hypothesis. Defaults togreater.

method

a character string specifying the test statistic to use.Defaults to"look-up" that uses published Table values of Williams (1972).

nperm

number of permutations for the asymptotic permutation test.Defaults to1000. Ignored, ifmethod = "look-up".

formula

a formula of the formresponse ~ group whereresponse gives the data values andgroup a vector orfactor of the corresponding groups.

data

an optional matrix or data frame (or similar: seemodel.frame) containing the variables in theformulaformula. By default the variables are taken fromenvironment(formula).

subset

an optional vector specifying asubset of observations to be used.

na.action

a function which indicates what should happen whenthe data containNAs. Defaults togetOption("na.action").

Details

The procedure uses the property of a simple order,\theta_m' - \theta_m \le \theta_j - \theta_i \le \theta_l' - \theta_l\qquad (l \le i \le m~\mathrm{and}~ m' \le j \le l').The null hypothesis H_{ij}: \theta_i = \theta_j is tested againstthe alternative A_{ij}: \theta_i < \theta_j for any1 \le i < j \le k.

The all-pairs comparisons test statistics for a balanced design are

\hat{h}_{ij} = \max_{i \le m < m' \le j} \frac{\left(\bar{R}_{m'} - \bar{R}_m \right)}{\sigma_a / \sqrt{n}},

withn = n_i; ~ N = \sum_i^k n_i ~~ (1 \le i \le k),\bar{R}_i the mean rank for theith group,and\sigma_a = \sqrt{N \left(N + 1 \right) / 12}. The null hypothesis is rejected,ifh_{ij} > h_{k,\alpha,\infty}.

For the unbalanced case with moderate imbalance the test statistic is

\hat{h}_{ij} = \max_{i \le m < m' \le j} \frac{\left(\bar{R}_{m'} - \bar{R}_m \right)} {\sigma_a \left(1/n_m + 1/n_{m'}\right)^{1/2}},

The null hypothesis is rejected, if\hat{h}_{ij} > h_{k,\alpha,\infty} / \sqrt{2}.

Ifmethod = "look-up" the function will not returnp-values. Instead the critical h-valuesas given in the tables of Hayter (1990) for\alpha = 0.05 (one-sided)are looked up according to the number of groups (k) andthe degree of freedoms (v = \infty).

Ifmethod = "boot" an asymetric permutation testis conducted andp-values is returned.

Ifmethod = "asympt" is selected the asymptoticp-value is estimated as implemented in thefunctionpHayStonLSA of the packageNSM3.

Value

method

a character string indicating what type of test was performed.

data.name

a character string giving the name(s) of the data.

statistic

the estimated statistic(s)

crit.value

critical values for\alpha = 0.05.

alternative

a character string describing the alternative hypothesis.

parameter

the parameter(s) of the test distribution.

dist

a string that denotes the test distribution.

There are print and summary methods available.

Either a list of class"PMCMR" or alist with class"osrt" that contains the followingcomponents:

method

a character string indicating what type of test was performed.

data.name

a character string giving the name(s) of the data.

statistic

the estimated statistic(s)

crit.value

critical values for\alpha = 0.05.

alternative

a character string describing the alternative hypothesis.

parameter

the parameter(s) of the test distribution.

dist

a string that denotes the test distribution.

There are print and summary methods available.

A list with class"PMCMR" containing the following components:

method

a character string indicating what type of test was performed.

data.name

a character string giving the name(s) of the data.

statistic

lower-triangle matrix of the estimatedquantiles of the pairwise test statistics.

p.value

lower-triangle matrix of the p-values for the pairwise tests.

alternative

a character string describing the alternative hypothesis.

p.adjust.method

a character string describing the method for p-valueadjustment.

model

a data frame of the input data.

dist

a string that denotes the test distribution.

Note

The function will give a warning for the unbalanced case and returns thecritical valueh_{k,\alpha,\infty} / \sqrt{2}.

Source

Ifmethod = "asympt" is selected, this function callsan internal probability functionpHS. The GPL-2 code forthis function was taken frompHayStonLSA of thethe packageNSM3:

Grant Schneider, Eric Chicken and Rachel Becvarik (2020) NSM3:Functions and Datasets to Accompany Hollander, Wolfe, andChicken - Nonparametric Statistical Methods, Third Edition. Rpackage version 1.15.https://CRAN.R-project.org/package=NSM3

References

Hayter, A. J.(1990) A One-Sided Studentised RangeTest for Testing Against a Simple Ordered Alternative,Journal of the American Statistical Association85, 778–785.

Nashimoto, K., Wright, F.T. (2007)Nonparametric Multiple-Comparison Methods for SimplyOrdered Medians.Comput Stat Data Anal51, 5068–5076.

See Also

MTest

Examples

## Example from Shirley (1977)## Reaction times of mice to stimuli to their tails.x <- c(2.4, 3, 3, 2.2, 2.2, 2.2, 2.2, 2.8, 2, 3, 2.8, 2.2, 3.8, 9.4, 8.4, 3, 3.2, 4.4, 3.2, 7.4, 9.8, 3.2, 5.8, 7.8, 2.6, 2.2, 6.2, 9.4, 7.8, 3.4, 7, 9.8, 9.4, 8.8, 8.8, 3.4, 9, 8.4, 2.4, 7.8)g <- gl(4, 10)## Shirley's test## one-sided test using look-up tableshirleyWilliamsTest(x ~ g, alternative = "greater")## Chacko's global hypothesis test for 'greater'chackoTest(x , g)## post-hoc test, default is standard normal distribution (NPT'-test)summary(chaAllPairsNashimotoTest(x, g, p.adjust.method = "none"))## same but h-distribution (NPY'-test)chaAllPairsNashimotoTest(x, g, dist = "h")## NPM-testNPMTest(x, g)## Hayter-Stone testhayterStoneTest(x, g)## all-pairs comparisonshsAllPairsTest(x, g)

Pentosan Dataset

Description

A benchmark dataset of an interlaboratory study fordetermining the precision of a test methodon several levels of the material Pentosan.

Format

A data frame with 189 obs. of 3 variables:

value

numeric, test result (no unit specified)

lab

factor, identifier of the lab (1–7)

material

factor, identifier of the level of the material (A–I)

Source

Tab. 8, Practice E 691, 2005,Standard Practice forConducting an Interlaboratory Study to Determine thePrecision of a Test Method, ASTM International.


Anderson-Darling All-Pairs Comparison Test

Description

Performs Anderson-Darling all-pairs comparison test.

Usage

adAllPairsTest(x, ...)## Default S3 method:adAllPairsTest(x, g, p.adjust.method = p.adjust.methods, ...)## S3 method for class 'formula'adAllPairsTest(  formula,  data,  subset,  na.action,  p.adjust.method = p.adjust.methods,  ...)

Arguments

x

a numeric vector of data values, or a list of numeric datavectors.

...

further arguments to be passed to or from methods.

g

a vector or factor object giving the group for thecorresponding elements of"x".Ignored with a warning if"x" is a list.

p.adjust.method

method for adjusting p values (seep.adjust).

formula

a formula of the formresponse ~ group whereresponse gives the data values andgroup a vector orfactor of the corresponding groups.

data

an optional matrix or data frame (or similar: seemodel.frame) containing the variables in theformulaformula. By default the variables are taken fromenvironment(formula).

subset

an optional vector specifying asubset of observations to be used.

na.action

a function which indicates what should happen whenthe data containNAs. Defaults togetOption("na.action").

Details

For all-pairs comparisons in an one-factorial layoutwith non-normally distributed residuals Anderson-Darling'sall-pairs comparison test can be used. A total ofm = k(k-1)/2hypotheses can be tested. The null hypothesisH_{ij}: F_i(x) = F_j(x) is tested in the two-tailed testagainst the alternativeA_{ij}: F_i(x) \ne F_j(x), ~~ i \ne j.

This function is a wrapper function that sequentiallycallsadKSampleTest for each pair.The calculated p-values forPr(>|T2N|)can be adjusted to account for Type I error multiplicityusing any method as implemented inp.adjust.

Value

A list with class"PMCMR" containing the following components:

method

a character string indicating what type of test was performed.

data.name

a character string giving the name(s) of the data.

statistic

lower-triangle matrix of the estimatedquantiles of the pairwise test statistics.

p.value

lower-triangle matrix of the p-values for the pairwise tests.

alternative

a character string describing the alternative hypothesis.

p.adjust.method

a character string describing the method for p-valueadjustment.

model

a data frame of the input data.

dist

a string that denotes the test distribution.

References

Scholz, F.W., Stephens, M.A. (1987) K-Sample Anderson-Darling Tests.Journal of the American Statistical Association82, 918–924.

See Also

adKSampleTest,adManyOneTest,ad.pval.

Examples

adKSampleTest(count ~ spray, InsectSprays)out <- adAllPairsTest(count ~ spray, InsectSprays, p.adjust="holm")summary(out)summaryGroup(out)

Anderson-Darling k-Sample Test

Description

Performs Anderson-Darling k-sample test.

Usage

adKSampleTest(x, ...)## Default S3 method:adKSampleTest(x, g, ...)## S3 method for class 'formula'adKSampleTest(formula, data, subset, na.action, ...)

Arguments

x

a numeric vector of data values, or a list of numeric datavectors.

...

further arguments to be passed to or from methods.

g

a vector or factor object giving the group for thecorresponding elements of"x".Ignored with a warning if"x" is a list.

formula

a formula of the formresponse ~ group whereresponse gives the data values andgroup a vector orfactor of the corresponding groups.

data

an optional matrix or data frame (or similar: seemodel.frame) containing the variables in theformulaformula. By default the variables are taken fromenvironment(formula).

subset

an optional vector specifying asubset of observations to be used.

na.action

a function which indicates what should happen whenthe data containNAs. Defaults togetOption("na.action").

Details

The null hypothesis, H_0: F_1 = F_2 = \ldots = F_kis tested against the alternative,H_\mathrm{A}: F_i \ne F_j ~~(i \ne j), with at leastone unequality beeing strict.

This function only evaluates version 1 of the k-sample Anderson-Darlingtest (i.e. Eq. 6) of Scholz and Stephens (1987).The p-values are estimated with the extended empirical functionas implemented inad.pval ofthe packagekSamples.

Value

A list with class"htest" containing the following components:

method

a character string indicating what type of test was performed.

data.name

a character string giving the name(s) of the data.

statistic

the estimated quantile of the test statistic.

p.value

the p-value for the test.

parameter

the parameters of the test statistic, if any.

alternative

a character string describing the alternative hypothesis.

estimates

the estimates, if any.

null.value

the estimate under the null hypothesis, if any.

References

Scholz, F.W., Stephens, M.A. (1987) K-Sample Anderson-Darling Tests.Journal of the American Statistical Association82, 918–924.

See Also

adAllPairsTest,adManyOneTest,ad.pval.

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 subjectsy <- c(3.8, 2.7, 4.0, 2.4)      # with obstructive airway diseasez <- c(2.8, 3.4, 3.7, 2.2, 2.0) # with asbestosisg <- 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-TestadKSampleTest(x ~ g, data = dat)## BWS-TestbwsKSampleTest(x ~ g, data = dat)## Kruskal-Test## Using incomplete beta approximationkruskalTest(x ~ g, dat, dist="KruskalWallis")## Using chisquare distributionkruskalTest(x ~ g, dat, dist="Chisquare")## Not run: ## Check with kruskal.test from R statskruskal.test(x ~ g, dat)## End(Not run)## Using Conover's FkruskalTest(x ~ g, dat, dist="FDist")## Not run: ## Check with aov on ranksanova(aov(rank(x) ~ g, dat))## Check with oneway.testoneway.test(rank(x) ~ g, dat, var.equal = TRUE)## End(Not run)## Median Test asymptoticmedianTest(x ~ g, dat)## Median Test with simulated p-valuesset.seed(112)medianTest(x ~ g, dat, simulate.p.value = TRUE)

Anderson-Darling Many-To-One Comparison Test

Description

Performs Anderson-Darling many-to-one comparison test.

Usage

adManyOneTest(x, ...)## Default S3 method:adManyOneTest(x, g, p.adjust.method = p.adjust.methods, ...)## S3 method for class 'formula'adManyOneTest(  formula,  data,  subset,  na.action,  p.adjust.method = p.adjust.methods,  ...)

Arguments

x

a numeric vector of data values, or a list of numeric datavectors.

...

further arguments to be passed to or from methods.

g

a vector or factor object giving the group for thecorresponding elements of"x".Ignored with a warning if"x" is a list.

p.adjust.method

method for adjustingp values (seep.adjust).

formula

a formula of the formresponse ~ group whereresponse gives the data values andgroup a vector orfactor of the corresponding groups.

data

an optional matrix or data frame (or similar: seemodel.frame) containing the variables in theformulaformula. By default the variables are taken fromenvironment(formula).

subset

an optional vector specifying asubset of observations to be used.

na.action

a function which indicates what should happen whenthe data containNAs. Defaults togetOption("na.action").

Details

For many-to-one comparisons (pairwise comparisons with one control)in an one-factorial layout with non-normally distributedresiduals Anderson-Darling's non-parametric test can be performed.Let there bek groups including the control,then the number of treatment levels ism = k - 1.Thenm pairwise comparisons can be performed betweenthei-th treatment level and the control.H_i: F_0 = F_i is tested in the two-tailed case againstA_i: F_0 \ne F_i, ~~ (1 \le i \le m).

This function is a wrapper function that sequentiallycallsadKSampleTest for each pair.The calculated p-values forPr(>|T2N|)can be adjusted to account for Type I error inflationusing any method as implemented inp.adjust.

Value

A list with class"PMCMR" containing the following components:

method

a character string indicating what type of test was performed.

data.name

a character string giving the name(s) of the data.

statistic

lower-triangle matrix of the estimatedquantiles of the pairwise test statistics.

p.value

lower-triangle matrix of the p-values for the pairwise tests.

alternative

a character string describing the alternative hypothesis.

p.adjust.method

a character string describing the method for p-valueadjustment.

model

a data frame of the input data.

dist

a string that denotes the test distribution.

Note

Factor labels forg must be assigned in such a way,that they can be increasingly ordered from zero-dosecontrol to the highest dose level, e.g. integers{0, 1, 2, ..., k} or letters {a, b, c, ...}.Otherwise the function may not select the correct valuesfor intended zero-dose control.

It is safer, to i) label the factor levels as given above,and to ii) sort the data according to increasing dose-levelsprior to call the function (seeorder,factor).

References

Scholz, F.W., Stephens, M.A. (1987) K-Sample Anderson-Darling Tests.Journal of the American Statistical Association82, 918–924.

See Also

adKSampleTest,adAllPairsTest,ad.pval.

Examples

## Data set PlantGrowth## Global testadKSampleTest(weight ~ group, data = PlantGrowth)##ans <- adManyOneTest(weight ~ group,                             data = PlantGrowth,                             p.adjust.method = "holm")summary(ans)

Algae Growth Inhibition Data Set

Description

A dose-response experiment was conducted using Atrazineat 9 different dose-levels including the zero-dose controland the biomass of algae (Selenastrumcapricornutum) as the response variable. Three replicateswere measured at day 0, 1 and 2. The fluorescence method (Mayer etal. 1997) was applied to measure biomass.

Format

A data frame with 22 observations on the following 10 variables.

concentration

a numeric vector of dose value in mg / L

Day.0

a numeric vector, total biomass

Day.0.1

a numeric vector, total biomass

Day.0.2

a numeric vector, total biomass

Day.1

a numeric vector, total biomass

Day.1.1

a numeric vector, total biomass

Day.1.2

a numeric vector, total biomass

Day.2

a numeric vector, total biomass

Day.2.1

a numeric vector, total biomass

Day.2.2

a numeric vector, total biomass

Source

ENV/JM/MONO(2006)18/ANN, page 24.

References

OECD (ed. 2006)Current approaches in the statistical analysisof ecotoxicity data: A guidance to application - Annexes, OECD Serieson testing and assessment, No. 54, (ENV/JM/MONO(2006)18/ANN).

See Also

demo(algae)


Plotting PMCMR Objects

Description

Plots a bar-plot for objects of class"PMCMR".

Usage

barPlot(x, alpha = 0.05, ...)

Arguments

x

an object of class"PMCMR".

alpha

the selected alpha-level. Defaults to 0.05.

...

further arguments for methodbarplot.

Value

A barplot where the height of the bars corresponds to the arithmeticmean. The extend of the whiskers are\pm z_{(1-\alpha/2)}\times s_{\mathrm{E},i}, where the latter denotes the standard errorof theith group. Symbolic letters are depicted on top of the bars,whereas different letters indicate significant differences betweengroups for the selected level of alpha.

Note

The barplot is strictly spoken only valid for normal data, asthe depicted significance intervall implies symetry.

Examples

## data set chickwtsans <- tukeyTest(weight ~ feed, data = chickwts)barPlot(ans)

BWS All-Pairs Comparison Test

Description

Performs Baumgartner-Weiß-Schindler all-pairs comparison test.

Usage

bwsAllPairsTest(x, ...)## Default S3 method:bwsAllPairsTest(  x,  g,  method = c("BWS", "Murakami"),  p.adjust.method = p.adjust.methods,  ...)## S3 method for class 'formula'bwsAllPairsTest(  formula,  data,  subset,  na.action,  method = c("BWS", "Murakami"),  p.adjust.method = p.adjust.methods,  ...)

Arguments

x

a numeric vector of data values, or a list of numeric datavectors.

...

further arguments to be passed to or from methods.

g

a vector or factor object giving the group for thecorresponding elements of"x".Ignored with a warning if"x" is a list.

method

a character string specifying the test statistic to use. Defaults toBWS.

p.adjust.method

method for adjusting p values (seep.adjust).

formula

a formula of the formresponse ~ group whereresponse gives the data values andgroup a vector orfactor of the corresponding groups.

data

an optional matrix or data frame (or similar: seemodel.frame) containing the variables in theformulaformula. By default the variables are taken fromenvironment(formula).

subset

an optional vector specifying asubset of observations to be used.

na.action

a function which indicates what should happen whenthe data containNAs. Defaults togetOption("na.action").

Details

For all-pairs comparisons in an one-factorial layoutwith non-normally distributed residuals Baumgartner-Weiß-Schindlerall-pairs comparison test can be used. A total ofm = k(k-1)/2hypotheses can be tested. The null hypothesisH_{ij}: F_i(x) = F_j(x) is tested in the two-tailed testagainst the alternativeA_{ij}: F_i(x) \ne F_j(x), ~~ i \ne j.

This function is a wrapper function that sequentiallycallsbws_test for each pair.The default test method ("BWS") is the originalBaumgartner-Weiß-Schindler test statistic B. Formethod == "Murakami" it is the modified BWS statisticdenoted B*. The calculated p-values forPr(>|B|)orPr(>|B*|) can be adjusted to account for Type I errorinflation using any method as implemented inp.adjust.

Value

A list with class"PMCMR" containing the following components:

method

a character string indicating what type of test was performed.

data.name

a character string giving the name(s) of the data.

statistic

lower-triangle matrix of the estimatedquantiles of the pairwise test statistics.

p.value

lower-triangle matrix of the p-values for the pairwise tests.

alternative

a character string describing the alternative hypothesis.

p.adjust.method

a character string describing the method for p-valueadjustment.

model

a data frame of the input data.

dist

a string that denotes the test distribution.

References

Baumgartner, W., Weiss, P., Schindler, H. (1998) A nonparametric test for thegeneral two-sample problem,Biometrics54, 1129–1135.

Murakami, H. (2006) K-sample rank test based on modified Baumgartner statistic and its powercomparison,J. Jpn. Comp. Statist.19, 1–13.

See Also

bws_test.

Examples

out <- bwsAllPairsTest(count ~ spray, InsectSprays, p.adjust="holm")summary(out)summaryGroup(out)

Murakami's k-Sample BWS Test

Description

Performs Murakami's k-Sample BWS Test.

Usage

bwsKSampleTest(x, ...)## Default S3 method:bwsKSampleTest(x, g, nperm = 1000, ...)## S3 method for class 'formula'bwsKSampleTest(formula, data, subset, na.action, nperm = 1000, ...)

Arguments

x

a numeric vector of data values, or a list of numeric datavectors.

...

further arguments to be passed to or from methods.

g

a vector or factor object giving the group for thecorresponding elements of"x".Ignored with a warning if"x" is a list.

nperm

number of permutations for the assymptotic permutation test.Defaults to1000.

formula

a formula of the formresponse ~ group whereresponse gives the data values andgroup a vector orfactor of the corresponding groups.

data

an optional matrix or data frame (or similar: seemodel.frame) containing the variables in theformulaformula. By default the variables are taken fromenvironment(formula).

subset

an optional vector specifying asubset of observations to be used.

na.action

a function which indicates what should happen whenthe data containNAs. Defaults togetOption("na.action").

Details

LetX_{ij} ~ (1 \le i \le k,~ 1 \le 1 \le n_i) denote anidentically and independently distributed variable that is obtainedfrom an unknown continuous distributionF_i(x). LetR_{ij}be the rank ofX_{ij}, whereX_{ij} is jointly rankedfrom1 toN, ~ N = \sum_{i=1}^k n_i.In thek-sample test the null hypothesis, H:F_i = F_jis tested against the alternative,A:F_i \ne F_j ~~(i \ne j) with at least one inequalitybeeing strict. Murakami (2006) has generalizedthe two-sample Baumgartner-Weiß-Schindler test(Baumgartner et al. 1998) and proposed amodified statisticB_k^* defined by

B_{k}^* = \frac{1}{k}\sum_{i=1}^k\left\{\frac{1}{n_i} \sum_{j=1}^{n_i} \frac{(R_{ij} - \mathsf{E}[R_{ij}])^2} {\mathsf{Var}[R_{ij}]}\right\},

where

\mathsf{E}[R_{ij}] = \frac{N + 1}{n_i + 1} j

and

\mathsf{Var}[R_{ij}] = \frac{j}{n_i + 1} \left(1 - \frac{j}{n_i + 1}\right)\frac{\left(N-n_i\right)\left(N+1\right)}{n_i + 2}.

Thep-values are estimated via an assymptotic boot-strap method.It should be noted that theB_k^* detects both differences in theunknown location parameters and / or differencesin the unknown scale parameters of thek-samples.

Value

A list with class"htest" containing the following components:

method

a character string indicating what type of test was performed.

data.name

a character string giving the name(s) of the data.

statistic

the estimated quantile of the test statistic.

p.value

the p-value for the test.

parameter

the parameters of the test statistic, if any.

alternative

a character string describing the alternative hypothesis.

estimates

the estimates, if any.

null.value

the estimate under the null hypothesis, if any.

Note

One may increase the number of permutations to e.g.nperm = 10000in order to get more precise p-values. However, this will be onthe expense of computational time.

References

Baumgartner, W., Weiss, P., Schindler, H. (1998) A nonparametric test for thegeneral two-sample problem,Biometrics54, 1129–1135.

Murakami, H. (2006) K-sample rank test based on modified Baumgartner statistic and its powercomparison,J. Jpn. Comp. Statist.19, 1–13.

See Also

sample,bwsAllPairsTest,bwsManyOneTest.

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 subjectsy <- c(3.8, 2.7, 4.0, 2.4)      # with obstructive airway diseasez <- c(2.8, 3.4, 3.7, 2.2, 2.0) # with asbestosisg <- 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-TestadKSampleTest(x ~ g, data = dat)## BWS-TestbwsKSampleTest(x ~ g, data = dat)## Kruskal-Test## Using incomplete beta approximationkruskalTest(x ~ g, dat, dist="KruskalWallis")## Using chisquare distributionkruskalTest(x ~ g, dat, dist="Chisquare")## Not run: ## Check with kruskal.test from R statskruskal.test(x ~ g, dat)## End(Not run)## Using Conover's FkruskalTest(x ~ g, dat, dist="FDist")## Not run: ## Check with aov on ranksanova(aov(rank(x) ~ g, dat))## Check with oneway.testoneway.test(rank(x) ~ g, dat, var.equal = TRUE)## End(Not run)## Median Test asymptoticmedianTest(x ~ g, dat)## Median Test with simulated p-valuesset.seed(112)medianTest(x ~ g, dat, simulate.p.value = TRUE)

BWS Many-To-One Comparison Test

Description

Performs Baumgartner-Weiß-Schindler many-to-one comparison test.

Usage

bwsManyOneTest(x, ...)## Default S3 method:bwsManyOneTest(  x,  g,  alternative = c("two.sided", "greater", "less"),  method = c("BWS", "Murakami", "Neuhauser"),  p.adjust.method = p.adjust.methods,  ...)## S3 method for class 'formula'bwsManyOneTest(  formula,  data,  subset,  na.action,  alternative = c("two.sided", "greater", "less"),  method = c("BWS", "Murakami", "Neuhauser"),  p.adjust.method = p.adjust.methods,  ...)

Arguments

x

a numeric vector of data values, or a list of numeric datavectors.

...

further arguments to be passed to or from methods.

g

a vector or factor object giving the group for thecorresponding elements of"x".Ignored with a warning if"x" is a list.

alternative

the alternative hypothesis. Defaults totwo.sided.

method

a character string specifying the test statistic to use. Defaults toBWS.

p.adjust.method

method for adjusting p values (seep.adjust).

formula

a formula of the formresponse ~ group whereresponse gives the data values andgroup a vector orfactor of the corresponding groups.

data

an optional matrix or data frame (or similar: seemodel.frame) containing the variables in theformulaformula. By default the variables are taken fromenvironment(formula).

subset

an optional vector specifying asubset of observations to be used.

na.action

a function which indicates what should happen whenthe data containNAs. Defaults togetOption("na.action").

Details

For many-to-one comparisons (pairwise comparisons with one control)in an one-factorial layout with non-normally distributedresiduals Baumgartner-Weiß-Schindler's non-parametric test can be performed.Let there bek groups including the control,then the number of treatment levels ism = k - 1.Thenm pairwise comparisons can be performed betweenthei-th treatment level and the control.H_i: F_0 = F_i is tested in the two-tailed case againstA_i: F_0 \ne F_i, ~~ (1 \le i \le m).

This function is a wrapper function that sequentiallycallsbws_stat andbws_cdffor each pair. For the default test method ("BWS") the originalBaumgartner-Weiß-Schindler test statistic B and its corresponding Pr(>|B|)is calculated. Formethod == "BWS" only a two-sided test is possible.

Formethod == "Murakami" the modified BWS statisticdenoted B* and its corresponding Pr(>|B*|) is computed by sequentially callingmurakami_stat andmurakami_cdf.Formethod == "Murakami" only a two-sided test is possible.

Ifalternative == "greater" then the alternative, if onepopulation is stochastically larger than the other is tested:H_i: F_0 = F_i against A_i: F_0 \ge F_i, ~~ (1 \le i \le m).The modified test-statistic B* according to Neuhäuser (2001) and itscorresponding Pr(>B*) or Pr(<B*) is computed by sequentally callingmurakami_stat andmurakami_cdfwithflavor = 2.

The p-values can be adjusted to account for Type I errorinflation using any method as implemented inp.adjust.

Value

A list with class"PMCMR" containing the following components:

method

a character string indicating what type of test was performed.

data.name

a character string giving the name(s) of the data.

statistic

lower-triangle matrix of the estimatedquantiles of the pairwise test statistics.

p.value

lower-triangle matrix of the p-values for the pairwise tests.

alternative

a character string describing the alternative hypothesis.

p.adjust.method

a character string describing the method for p-valueadjustment.

model

a data frame of the input data.

dist

a string that denotes the test distribution.

Note

Factor labels forg must be assigned in such a way,that they can be increasingly ordered from zero-dosecontrol to the highest dose level, e.g. integers{0, 1, 2, ..., k} or letters {a, b, c, ...}.Otherwise the function may not select the correct valuesfor intended zero-dose control.

It is safer, to i) label the factor levels as given above,and to ii) sort the data according to increasing dose-levelsprior to call the function (seeorder,factor).

References

Baumgartner, W., Weiss, P., Schindler, H. (1998) A nonparametric test for thegeneral two-sample problem,Biometrics54, 1129–1135.

Murakami, H. (2006) K-sample rank test based on modified Baumgartner statistic and its powercomparison,J Jpn Comp Statist19, 1–13.

Neuhäuser, M. (2001) One-Side Two-Sample and Trend Tests Based on a ModifiedBaumgartner-Weiss-Schindler Statistic.J Nonparametric Stat13, 729–739.

See Also

murakami_stat,murakami_cdf,bws_stat,bws_cdf.

Examples

out <- bwsManyOneTest(weight ~ group, PlantGrowth, p.adjust="holm")summary(out)## A two-sample testset.seed(1245)x <- c(rnorm(20), rnorm(20,0.3))g <- gl(2, 20)summary(bwsManyOneTest(x ~ g, alternative = "less", p.adjust="none"))summary(bwsManyOneTest(x ~ g, alternative = "greater", p.adjust="none"))## Not run: ## Check with the implementation in package BWStestBWStest::bws_test(x=x[g==1], y=x[g==2], alternative = "less")BWStest::bws_test(x=x[g==1], y=x[g==2], alternative = "greater")## End(Not run)

Testing against Ordered Alternatives (Murakami's BWS Trend Test)

Description

Performs Murakami's modified Baumgartner-Weiß-Schindlertest for testing against ordered alternatives.

Usage

bwsTrendTest(x, ...)## Default S3 method:bwsTrendTest(x, g, nperm = 1000, ...)## S3 method for class 'formula'bwsTrendTest(formula, data, subset, na.action, nperm = 1000, ...)

Arguments

x

a numeric vector of data values, or a list of numeric datavectors.

...

further arguments to be passed to or from methods.

g

a vector or factor object giving the group for thecorresponding elements of"x".Ignored with a warning if"x" is a list.

nperm

number of permutations for the assymptotic permutation test.Defaults to1000.

formula

a formula of the formresponse ~ group whereresponse gives the data values andgroup a vector orfactor of the corresponding groups.

data

an optional matrix or data frame (or similar: seemodel.frame) containing the variables in theformulaformula. By default the variables are taken fromenvironment(formula).

subset

an optional vector specifying asubset of observations to be used.

na.action

a function which indicates what should happen whenthe data containNAs. Defaults togetOption("na.action").

Details

The null hypothesis, H_0: F_1(u) = F_2(u) = \ldots = F_k(u) ~~ u \in Ris tested against a simple order hypothesis,H_\mathrm{A}: F_1(u) \le F_2(u) \le \ldots \leF_k(u),~F_1(u) < F_k(u), ~~ u \in R.

The p-values are estimated through an assymptotic boot-strap methodusing the functionsample.

Value

A list with class"htest" containing the following components:

method

a character string indicating what type of test was performed.

data.name

a character string giving the name(s) of the data.

statistic

the estimated quantile of the test statistic.

p.value

the p-value for the test.

parameter

the parameters of the test statistic, if any.

alternative

a character string describing the alternative hypothesis.

estimates

the estimates, if any.

null.value

the estimate under the null hypothesis, if any.

Note

One may increase the number of permutations to e.g.nperm = 10000in order to get more precise p-values. However, this will be onthe expense of computational time.

Factor labels forg must be assigned in such a way,that they can be increasingly ordered from zero-dosecontrol to the highest dose level, e.g. integers{0, 1, 2, ..., k} or letters {a, b, c, ...}.Otherwise the function may not select the correct valuesfor intended zero-dose control.

It is safer, to i) label the factor levels as given above,and to ii) sort the data according to increasing dose-levelsprior to call the function (seeorder,factor).

References

Baumgartner, W., Weiss, P., Schindler, H. (1998) A nonparametric test for thegeneral two-sample problem,Biometrics54, 1129–1135.

Murakami, H. (2006) K-sample rank test based on modified Baumgartner statistic and its powercomparison,J Jpn Comp Statist19, 1–13.

Neuhäuser, M. (2001) One-Side Two-Sample and Trend Tests Based on a ModifiedBaumgartner-Weiss-Schindler Statistic.J Nonparametric Stat13, 729–739.

See Also

sample,bwsAllPairsTest,bwsManyOneTest.

kruskalTest andshirleyWilliamsTestof the packagePMCMRplus,kruskal.test of the librarystats.

Examples

## Example from Sachs (1997, p. 402)x <- c(106, 114, 116, 127, 145,       110, 125, 143, 148, 151,       136, 139, 149, 160, 174)g <- gl(3,5)levels(g) <- c("A", "B", "C")## Chacko's testchackoTest(x, g)## Cuzick's testcuzickTest(x, g)## Johnson-Mehrotra testjohnsonTest(x, g)## Jonckheere-Terpstra testjonckheereTest(x, g)## Le's testleTest(x, g)## Spearman type testspearmanTest(x, g)## Murakami's BWS trend testbwsTrendTest(x, g)## Fligner-Wolfe testflignerWolfeTest(x, g)## Shan-Young-Kang testshanTest(x, g)

All-Pairs Comparisons for Simply Ordered Mean Ranksums

Description

Performs Nashimoto and Wright's all-pairs comparison procedurefor simply ordered mean ranksums (NPT'-test and NPY'-test).

According to the authors, the procedure shall only beapplied after Chacko's test (seechackoTest) indicatesglobal significance.

Usage

chaAllPairsNashimotoTest(x, ...)## Default S3 method:chaAllPairsNashimotoTest(  x,  g,  p.adjust.method = c(p.adjust.methods),  alternative = c("greater", "less"),  dist = c("Normal", "h"),  ...)## S3 method for class 'formula'chaAllPairsNashimotoTest(  formula,  data,  subset,  na.action,  p.adjust.method = c(p.adjust.methods),  alternative = c("greater", "less"),  dist = c("Normal", "h"),  ...)

Arguments

x

a numeric vector of data values, or a list of numeric datavectors.

...

further arguments to be passed to or from methods.

g

a vector or factor object giving the group for thecorresponding elements of"x".Ignored with a warning if"x" is a list.

p.adjust.method

method for adjusting p values. Ignored ifdist = "h".

alternative

the alternative hypothesis. Defaults togreater.

dist

the test distribution. Defaults toNormal.

formula

a formula of the formresponse ~ group whereresponse gives the data values andgroup a vector orfactor of the corresponding groups.

data

an optional matrix or data frame (or similar: seemodel.frame) containing the variables in theformulaformula. By default the variables are taken fromenvironment(formula).

subset

an optional vector specifying asubset of observations to be used.

na.action

a function which indicates what should happen whenthe data containNAs. Defaults togetOption("na.action").

Details

The modified procedure uses the property of a simple order,\theta_m' - \theta_m \le \theta_j - \theta_i \le \theta_l' - \theta_l\qquad (l \le i \le m~\mathrm{and}~ m' \le j \le l').The null hypothesis H_{ij}: \theta_i = \theta_j is tested againstthe alternative A_{ij}: \theta_i < \theta_j for any1 \le i < j \le k.

LetR_{ij} be the rank ofX_{ij},whereX_{ij} is jointly rankedfrom\left\{1, 2, \ldots, N \right\}, ~~ N = \sum_{i=1}^k n_i,then the test statistics for all-pairs comparisonsand a balanced design is calculated as

\hat{T}_{ij} = \max_{i \le m < m' \le j} \frac{\left(\bar{R}_{m'} - \bar{R}_m \right)} {\sigma_a / \sqrt{n}},

withn = n_i; ~ N = \sum_i^k n_i ~~ (1 \le i \le k),\bar{R}_ithe mean rank for theith group,and the expected variance (without ties)\sigma_a^2 = N \left(N + 1 \right) / 12.

For the NPY'-test (dist = "h"), ifT_{ij} > h_{k-1,\alpha,\infty}.

For the unbalanced case with moderate imbalance the test statistic is

\hat{T}_{ij} = \max_{i \le m < m' \le j} \frac{\left(\bar{R}_{m'} - \bar{R}_m \right)} {\sigma_a \left(1/n_m + 1/n_{m'}\right)^{1/2}},

For the NPY'-test (dist="h") the null hypothesis is rejected in an unbalanced design,if\hat{T}_{ij} > h_{k,\alpha,\infty} / \sqrt{2}.In case of a NPY'-test, the function does not return p-values. Instead the critical h-valuesas given in the tables of Hayter (1990) for\alpha = 0.05 (one-sided)are looked up according to the number of groups (k-1) andthe degree of freedoms (v = \infty).

For the NPT'-test (dist = "Normal"), the null hypothesis is rejected, ifT_{ij} > \sqrt{2} t_{\alpha,\infty} = \sqrt{2} z_\alpha. Although Nashimoto and Wright (2005) originally did not use any p-adjustment,any method as available byp.adjust.methods canbe selected for the adjustment of p-values estimated fromthe standard normal distribution.

Value

Either a list of class"osrt" ifdist = "h" or a listof class"PMCMR" ifdist = "Normal".

method

a character string indicating what type of test was performed.

data.name

a character string giving the name(s) of the data.

statistic

the estimated statistic(s)

crit.value

critical values for\alpha = 0.05.

alternative

a character string describing the alternative hypothesis.

parameter

the parameter(s) of the test distribution.

dist

a string that denotes the test distribution.

There are print and summary methods available.

A list with class"PMCMR" containing the following components:

method

a character string indicating what type of test was performed.

data.name

a character string giving the name(s) of the data.

statistic

lower-triangle matrix of the estimatedquantiles of the pairwise test statistics.

p.value

lower-triangle matrix of the p-values for the pairwise tests.

alternative

a character string describing the alternative hypothesis.

p.adjust.method

a character string describing the method for p-valueadjustment.

model

a data frame of the input data.

dist

a string that denotes the test distribution.

Note

The function will give a warning for the unbalanced case and returns thecritical valueh_{k-1,\alpha,\infty} / \sqrt{2} if applicable.

References

Hayter, A. J.(1990) A One-Sided Studentised RangeTest for Testing Against a Simple Ordered Alternative,J Amer Stat Assoc85, 778–785.

Nashimoto, K., Wright, F.T. (2007)Nonparametric Multiple-Comparison Methods for Simply Ordered Medians.Comput Stat Data Anal51, 5068–5076.

See Also

Normal,chackoTest,NPMTest

Examples

## Example from Shirley (1977)## Reaction times of mice to stimuli to their tails.x <- c(2.4, 3, 3, 2.2, 2.2, 2.2, 2.2, 2.8, 2, 3, 2.8, 2.2, 3.8, 9.4, 8.4, 3, 3.2, 4.4, 3.2, 7.4, 9.8, 3.2, 5.8, 7.8, 2.6, 2.2, 6.2, 9.4, 7.8, 3.4, 7, 9.8, 9.4, 8.8, 8.8, 3.4, 9, 8.4, 2.4, 7.8)g <- gl(4, 10)## Shirley's test## one-sided test using look-up tableshirleyWilliamsTest(x ~ g, alternative = "greater")## Chacko's global hypothesis test for 'greater'chackoTest(x , g)## post-hoc test, default is standard normal distribution (NPT'-test)summary(chaAllPairsNashimotoTest(x, g, p.adjust.method = "none"))## same but h-distribution (NPY'-test)chaAllPairsNashimotoTest(x, g, dist = "h")## NPM-testNPMTest(x, g)## Hayter-Stone testhayterStoneTest(x, g)## all-pairs comparisonshsAllPairsTest(x, g)

Testing against Ordered Alternatives (Chacko's Test)

Description

Performs Chacko's test for testing against ordered alternatives.

Usage

chackoTest(x, ...)## Default S3 method:chackoTest(x, g, alternative = c("greater", "less"), ...)## S3 method for class 'formula'chackoTest(formula, data, subset, na.action, alternative = alternative, ...)

Arguments

x

a numeric vector of data values, or a list of numeric datavectors.

...

further arguments to be passed to or from methods.

g

a vector or factor object giving the group for thecorresponding elements of"x".Ignored with a warning if"x" is a list.

alternative

the alternative hypothesis. Defaults togreater.

formula

a formula of the formresponse ~ group whereresponse gives the data values andgroup a vector orfactor of the corresponding groups.

data

an optional matrix or data frame (or similar: seemodel.frame) containing the variables in theformulaformula. By default the variables are taken fromenvironment(formula).

subset

an optional vector specifying asubset of observations to be used.

na.action

a function which indicates what should happen whenthe data containNAs. Defaults togetOption("na.action").

Details

The null hypothesis, H_0: \theta_1 = \theta_2 = \ldots = \theta_kis tested against a simple order hypothesis,H_\mathrm{A}: \theta_1 \le \theta_2 \le \ldots \le\theta_k,~\theta_1 < \theta_k.

LetR_{ij} be the rank ofX_{ij},whereX_{ij} is jointly rankedfrom\left\{1, 2, \ldots, N \right\}, ~~ N = \sum_{i=1}^k n_i,then the test statistic is calculated as

H = \frac{1}{\sigma_R^2} \sum_{i=1}^k n_i \left(\bar{R^*}_i - \bar{R}\right),

where\bar{R^*}_i is the isotonic mean of thei-th groupand\sigma_R^2 = N \left(N + 1\right) / 12 the expected variance (without ties).H_0 is rejected, ifH > \chi^2_{v,\alpha} withv = k -1 degree of freedom. The p-values are estimatedfrom the chi-square distribution.

Value

A list with class"htest" containing the following components:

method

a character string indicating what type of test was performed.

data.name

a character string giving the name(s) of the data.

statistic

the estimated quantile of the test statistic.

p.value

the p-value for the test.

parameter

the parameters of the test statistic, if any.

alternative

a character string describing the alternative hypothesis.

estimates

the estimates, if any.

null.value

the estimate under the null hypothesis, if any.

Source

The source code for the application of the pool adjacent violatorstheorem to calculate the isotonic meanswas taken from the file"pava.f", which is included in thepackageIso:

Rolf Turner (2015). Iso: Functions to Perform Isotonic Regression.R package version 0.0-17.https://CRAN.R-project.org/package=Iso.

The file"pava.f" is a Ratfor modification of Algorithm AS 206.1:

Bril, G., Dykstra, R., Pillers, C., Robertson, T. (1984)Statistical Algorithms: Algorithm AS 206: IsotonicRegression in Two Independent Variables,Appl Statist34, 352–357.

The Algorith AS 206 is available from StatLibhttps://lib.stat.cmu.edu/apstat/. The Royal Statistical Societyholds the copyright to these routines,but has given its permission for their distribution provided thatno fee is charged.

Note

Factor labels forg must be assigned in such a way,that they can be increasingly ordered from zero-dosecontrol to the highest dose level, e.g. integers{0, 1, 2, ..., k} or letters {a, b, c, ...}.Otherwise the function may not select the correct valuesfor intended zero-dose control.

It is safer, to i) label the factor levels as given above,and to ii) sort the data according to increasing dose-levelsprior to call the function (seeorder,factor).

The function does neither check nor correct for ties.

References

Chacko, V. J. (1963) Testing homogeneity against ordered alternatives,Ann Math Statist34, 945–956.

See Also

kruskalTest andshirleyWilliamsTestof the packagePMCMRplus,kruskal.test of the librarystats.

Examples

## Example from Sachs (1997, p. 402)x <- c(106, 114, 116, 127, 145,       110, 125, 143, 148, 151,       136, 139, 149, 160, 174)g <- gl(3,5)levels(g) <- c("A", "B", "C")## Chacko's testchackoTest(x, g)## Cuzick's testcuzickTest(x, g)## Johnson-Mehrotra testjohnsonTest(x, g)## Jonckheere-Terpstra testjonckheereTest(x, g)## Le's testleTest(x, g)## Spearman type testspearmanTest(x, g)## Murakami's BWS trend testbwsTrendTest(x, g)## Fligner-Wolfe testflignerWolfeTest(x, g)## Shan-Young-Kang testshanTest(x, g)

Chen and Jan Many-to-One Comparisons Test

Description

Performs Chen and Jan nonparametric test for contrasting increasing(decreasing) dose levels of a treatment in a randomized block design.

Usage

chenJanTest(y, ...)## Default S3 method:chenJanTest(  y,  groups,  blocks,  alternative = c("greater", "less"),  p.adjust.method = c("single-step", "SD1", p.adjust.methods),  ...)

Arguments

y

a numeric vector of data values, or a list of numeric datavectors.

groups

a vector or factor object giving the group for thecorresponding elements of"x". Ignored with a warning if"x" is a list.

blocks

a vector or factor object giving the block for thecorresponding elements of"x".Ignored with a warning if"x" is a list.

alternative

the alternative hypothesis. Defaults togreater.

p.adjust.method

method for adjusting p values(seep.adjust)

...

further arguments to be passed to or from methods.

Details

Chen's test is a non-parametric step-down trend test fortesting several treatment levels with a zero control. Letthere bek groups including the control and letthe zero dose level be indicated withi = 0 and the highestdose level withi = m, then the followingm = k - 1 hypotheses are tested:

\begin{array}{ll}\mathrm{H}_{m}: \theta_0 = \theta_1 = \ldots = \theta_m, & \mathrm{A}_{m} = \theta_0 \le \theta_1 \le \ldots \theta_m, \theta_0 < \theta_m \\\mathrm{H}_{m-1}: \theta_0 = \theta_1 = \ldots = \theta_{m-1}, & \mathrm{A}_{m-1} = \theta_0 \le \theta_1 \le \ldots \theta_{m-1}, \theta_0 < \theta_{m-1} \\\vdots & \vdots \\\mathrm{H}_{1}: \theta_0 = \theta_1, & \mathrm{A}_{1} = \theta_0 < \theta_1\\\end{array}

LetY_{ij1}, Y_{ij2}, \ldots, Y_{ijn_{ij}}(i = 1, 2, \dots, b, j = 0, 1, \ldots, k ~ \mathrm{and} ~ n_{ij} \geq 1) bea i.i.d. random variable of at least ordinal scale. Further,the zero dosecontrol is indicated withj = 0.

The Mann-Whittney statistic is

T_{ij} = \sum_{u=0}^{j-1} \sum_{s=1}^{n_{ij}}\sum_{r=1}^{n_{iu}} I(Y_{ijs} - Y_{iur}),\qquad i = 1, 2, \ldots, b, ~ j = 1, 2, \ldots, k,

where where the indicator function returnsI(a) = 1, ~ \mathrm{if}~ a > 0, 0.5 ~ \mathrm{if} a = 0otherwise0.

Let

N_{ij} = \sum_{s=0}^j n_{is} \qquad i = 1, 2, \ldots, b, ~ j = 1, 2, \ldots, k,

and

T_j = \sum_{i=1}^b T_{ij} \qquad j = 1, 2, \ldots, k.

The mean and variance ofT_j are

\mu(T_j) = \sum_{i=1}^b n_{ij} ~ N_{ij-1} / 2 \qquad \mathrm{and}

\sigma(T_j) = \sum_{i=1}^b n_{ij} ~ N_{ij-1} \left[ \left(N_{ij} + 1\right) - \sum_{u=1}^{g_i} \left(t_u^3 - t_u \right) / \left\{N_{ij} \left(N_{ij} - 1\right) \right\} \right]/ 2,

withg_i the number of ties in theith block andt_u the size of the tied groupu.

The test statisticT_j^* is asymptotically multivariate normaldistributed.

T_j^* = \frac{T_j - \mu(T_j)}{\sigma(T_j)}

Ifp.adjust.method = "single-step" than the p-valuesare calculated with the probability function of the multivariatenormal distribution with\Sigma = I_k. Otherwisethe standard normal distribution is used to calculatep-values and any method as availablebyp.adjust or by the step-down procedure as proposedby Chen (1999), ifp.adjust.method = "SD1" can be usedto account for\alpha-error inflation.

Value

A list with class"PMCMR" containing the following components:

method

a character string indicating what type of test was performed.

data.name

a character string giving the name(s) of the data.

statistic

lower-triangle matrix of the estimatedquantiles of the pairwise test statistics.

p.value

lower-triangle matrix of the p-values for the pairwise tests.

alternative

a character string describing the alternative hypothesis.

p.adjust.method

a character string describing the method for p-valueadjustment.

model

a data frame of the input data.

dist

a string that denotes the test distribution.

References

Chen, Y.I., Jan, S.L., 2002. Nonparametric Identification ofthe Minimum Effective Dose for Randomized Block Designs.Commun Stat-Simul Comput31, 301–312.

See Also

Normalpmvnorm

Examples

## Example from Chen and Jan (2002, p. 306)## MED is at dose level 2 (0.5 ppm SO2)y <- c(0.2, 6.2, 0.3, 0.3, 4.9, 1.8, 3.9, 2, 0.3, 2.5, 5.4, 2.3, 12.7,-0.2, 2.1, 6, 1.8, 3.9, 1.1, 3.8, 2.5, 1.3, -0.8, 13.1, 1.1,12.8, 18.2, 3.4, 13.5, 4.4, 6.1, 2.8, 4, 10.6, 9, 4.2, 6.7, 35,9, 12.9, 2, 7.1, 1.5, 10.6)groups <- gl(4,11, labels = c("0", "0.25", "0.5", "1.0"))blocks <- structure(rep(1:11, 4), class = "factor",levels = c("1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11"))summary(chenJanTest(y, groups, blocks, alternative = "greater"))summary(chenJanTest(y, groups, blocks, alternative = "greater", p.adjust = "SD1"))

Chen's Many-to-One Comparisons Test

Description

Performs Chen's nonparametric test for contrasting increasing(decreasing) dose levels of a treatment.

Usage

chenTest(x, ...)## Default S3 method:chenTest(  x,  g,  alternative = c("greater", "less"),  p.adjust.method = c("SD1", p.adjust.methods),  ...)## S3 method for class 'formula'chenTest(  formula,  data,  subset,  na.action,  alternative = c("greater", "less"),  p.adjust.method = c("SD1", p.adjust.methods),  ...)

Arguments

x

a numeric vector of data values, or a list of numeric datavectors.

...

further arguments to be passed to or from methods.

g

a vector or factor object giving the group for thecorresponding elements of"x".Ignored with a warning if"x" is a list.

alternative

the alternative hypothesis. Defaults totwo.sided.

p.adjust.method

method for adjusting p values(seep.adjust)

formula

a formula of the formresponse ~ group whereresponse gives the data values andgroup a vector orfactor of the corresponding groups.

data

an optional matrix or data frame (or similar: seemodel.frame) containing the variables in theformulaformula. By default the variables are taken fromenvironment(formula).

subset

an optional vector specifying asubset of observations to be used.

na.action

a function which indicates what should happen whenthe data containNAs. Defaults togetOption("na.action").

Details

Chen's test is a non-parametric step-down trend test fortesting several treatment levels with a zero control.LetX_{0j} denote a variable with thej-threalization of the control group (1 \le j \le n_0)andX_{ij} thej-the realizationin thei-th treatment group (1 \le i \le k).The variables are i.i.d. of a least ordinal scale withF(x) = F(x_0) = F(x_i), ~ (1 \le i \le k).A total ofm = k hypotheses can be tested:

\begin{array}{ll}\mathrm{H}_{m}: \theta_0 = \theta_1 = \ldots = \theta_m, & \mathrm{A}_{m} = \theta_0 \le \theta_1 \le \ldots \theta_m, \theta_0 < \theta_m \\\mathrm{H}_{m-1}: \theta_0 = \theta_1 = \ldots = \theta_{m-1}, & \mathrm{A}_{m-1} = \theta_0 \le \theta_1 \le \ldots \theta_{m-1}, \theta_0 < \theta_{m-1} \\\vdots & \vdots \\\mathrm{H}_{1}: \theta_0 = \theta_1, & \mathrm{A}_{1} = \theta_0 < \theta_1\\\end{array}

The statisticsT_i are based on a Wilcoxon-type ranking:

T_i = \sum_{j=0}^{i=1} \sum_{u=1}^{n_i} \sum_{v=1}^{n_j} I(x_{iu} - x_{jv}), \qquad (1 \leq i \leq k),

where the indicator function returnsI(a) = 1, ~ \mathrm{if}~ a > 0, 0.5 ~ \mathrm{if} a = 0otherwise0.

The expectedith mean is

\mu(T_i) = n_i N_{i-1} / 2,

withN_j = \sum_{j =0}^i n_j and theith variance:

\sigma^2(T_i) = n_i N_{i-1} / 12 ~ \left\{N_i + 1 -\sum_{j=1}^g t_j \left(t_j^2 - 1 \right) /\left[N_i \left( N_i - 1 \right)\right]\right\}.

The test statisticT_i^* is asymptotically standard normal

T_i^* = \frac{T_i - \mu(T_i)} {\sqrt{\sigma^2(T_i)}}, \qquad (1 \leq i \leq k).

The p-values are calculated from the standard normal distribution.The p-values can be adjusted with any method as availablebyp.adjust or by the step-down procedure as proposedby Chen (1999), ifp.adjust.method = "SD1".

Value

A list with class"PMCMR" containing the following components:

method

a character string indicating what type of test was performed.

data.name

a character string giving the name(s) of the data.

statistic

lower-triangle matrix of the estimatedquantiles of the pairwise test statistics.

p.value

lower-triangle matrix of the p-values for the pairwise tests.

alternative

a character string describing the alternative hypothesis.

p.adjust.method

a character string describing the method for p-valueadjustment.

model

a data frame of the input data.

dist

a string that denotes the test distribution.

Note

Factor labels forg must be assigned in such a way,that they can be increasingly ordered from zero-dosecontrol to the highest dose level, e.g. integers{0, 1, 2, ..., k} or letters {a, b, c, ...}.Otherwise the function may not select the correct valuesfor intended zero-dose control.

It is safer, to i) label the factor levels as given above,and to ii) sort the data according to increasing dose-levelsprior to call the function (seeorder,factor).

References

Chen, Y.-I., 1999, Nonparametric Identification of theMinimum Effective Dose.Biometrics55, 1236–1240.doi:10.1111/j.0006-341X.1999.01236.x

See Also

wilcox.test,Normal

Examples

## Chen, 1999, p. 1237,## Minimum effective dose (MED)## is at 2nd dose leveldf <- data.frame(x = c(23, 22, 14,27, 23, 21,28, 37, 35,41, 37, 43,28, 21, 30,16, 19, 13),g = gl(6, 3))levels(df$g) <- 0:5ans <- chenTest(x ~ g, data = df, alternative = "greater",                p.adjust.method = "SD1")summary(ans)

Cochran Test

Description

Performs Cochran's test for testing an outlying (or inlying)variance.

Usage

cochranTest(x, ...)## Default S3 method:cochranTest(x, g, alternative = c("greater", "less"), ...)## S3 method for class 'formula'cochranTest(  formula,  data,  subset,  na.action,  alternative = c("greater", "less"),  ...)

Arguments

x

a numeric vector of data values, or a list of numeric datavectors.

...

further arguments to be passed to or from methods.

g

a vector or factor object giving the group for thecorresponding elements of"x".Ignored with a warning if"x" is a list.

alternative

the alternative hypothesis. Defaults to"greater"

formula

a formula of the formresponse ~ group whereresponse gives the data values andgroup a vector orfactor of the corresponding groups.

data

an optional matrix or data frame (or similar: seemodel.frame) containing the variables in theformulaformula. By default the variables are taken fromenvironment(formula).

subset

an optional vector specifying asubset of observations to be used.

na.action

a function which indicates what should happen whenthe data containNAs. Defaults togetOption("na.action").

Details

For normally distributed data the null hypothesis,H_0: \sigma_1^2 = \sigma_2^2 = \ldots = \sigma_k^2is tested against the alternative (greater)H_{\mathrm{A}}: \sigma_p > \sigma_i ~~ (i \le k, i \ne p) withat least one inequality being strict.

The p-value is computed with the functionpcochran.

Value

A list with class"htest" containing the following components:

method

a character string indicating what type of test was performed.

data.name

a character string giving the name(s) of the data.

statistic

the estimated quantile of the test statistic.

p.value

the p-value for the test.

parameter

the parameters of the test statistic, if any.

alternative

a character string describing the alternative hypothesis.

estimates

the estimates, if any.

null.value

the estimate under the null hypothesis, if any.

References

Cochran, W.G. (1941) The distribution of the largest of a set of estimatedvariances as a fraction of their total.Ann. Eugen.11, 47–52.

Wilrich, P.-T. (2011) Critical values of Mandel's h and k,Grubbs and the Cochran test statistic.Adv. Stat. Anal..doi:10.1007/s10182-011-0185-y.

See Also

bartlett.test,fligner.test.

Examples

data(Pentosan)cochranTest(value ~ lab, data = Pentosan, subset = (material == "A"))

Testing against Ordered Alternatives (Cuzick's Test)

Description

Performs Cuzick's test for testing against ordered alternatives.

Usage

cuzickTest(x, ...)## Default S3 method:cuzickTest(  x,  g,  alternative = c("two.sided", "greater", "less"),  scores = NULL,  continuity = FALSE,  ...)## S3 method for class 'formula'cuzickTest(  formula,  data,  subset,  na.action,  alternative = c("two.sided", "greater", "less"),  scores = NULL,  continuity = FALSE,  ...)

Arguments

x

a numeric vector of data values, or a list of numeric datavectors.

...

further arguments to be passed to or from methods.

g

a vector or factor object giving the group for thecorresponding elements of"x".Ignored with a warning if"x" is a list.

alternative

the alternative hypothesis. Defaults to"two.sided".

scores

numeric vector of scores. Defaults toNULL.

continuity

logical indicator whether a continuity correctionshall be performed. Defaults toFALSE.

formula

a formula of the formresponse ~ group whereresponse gives the data values andgroup a vector orfactor of the corresponding groups.

data

an optional matrix or data frame (or similar: seemodel.frame) containing the variables in theformulaformula. By default the variables are taken fromenvironment(formula).

subset

an optional vector specifying asubset of observations to be used.

na.action

a function which indicates what should happen whenthe data containNAs. Defaults togetOption("na.action").

Details

The null hypothesis, H_0: \theta_1 = \theta_2 = \ldots = \theta_kis tested against a simple order hypothesis,H_\mathrm{A}: \theta_1 \le \theta_2 \le \ldots \le\theta_k,~\theta_1 < \theta_k.

The p-values are estimated from the standard normal distribution.

Value

A list with class"htest" containing the following components:

method

a character string indicating what type of test was performed.

data.name

a character string giving the name(s) of the data.

statistic

the estimated quantile of the test statistic.

p.value

the p-value for the test.

parameter

the parameters of the test statistic, if any.

alternative

a character string describing the alternative hypothesis.

estimates

the estimates, if any.

null.value

the estimate under the null hypothesis, if any.

Note

Factor labels forg must be assigned in such a way,that they can be increasingly ordered from zero-dosecontrol to the highest dose level, e.g. integers{0, 1, 2, ..., k} or letters {a, b, c, ...}.Otherwise the function may not select the correct valuesfor intended zero-dose control.

It is safer, to i) label the factor levels as given above,and to ii) sort the data according to increasing dose-levelsprior to call the function (seeorder,factor).

References

Cuzick, J. (1995) A Wilcoxon-type test for trend,Statistics in Medicine4, 87–90.

See Also

kruskalTest andshirleyWilliamsTestof the packagePMCMRplus,kruskal.test of the librarystats.

Examples

## Example from Sachs (1997, p. 402)x <- c(106, 114, 116, 127, 145,       110, 125, 143, 148, 151,       136, 139, 149, 160, 174)g <- gl(3,5)levels(g) <- c("A", "B", "C")## Chacko's testchackoTest(x, g)## Cuzick's testcuzickTest(x, g)## Johnson-Mehrotra testjohnsonTest(x, g)## Jonckheere-Terpstra testjonckheereTest(x, g)## Le's testleTest(x, g)## Spearman type testspearmanTest(x, g)## Murakami's BWS trend testbwsTrendTest(x, g)## Fligner-Wolfe testflignerWolfeTest(x, g)## Shan-Young-Kang testshanTest(x, g)

Grubbs Double Outlier Test

Description

Performs Grubbs double outlier test.

Usage

doubleGrubbsTest(x, alternative = c("two.sided", "greater", "less"), m = 10000)

Arguments

x

a numeric vector of data.

alternative

the alternative hypothesis.Defaults to"two.sided".

m

number of Monte-Carlo replicates.

Details

LetX denote an identically and independently distributed continuousvariate with realizationsx_i ~~ (1 \le i \le k).Further, let the increasingly ordered realizationsdenotex_{(1)} \le x_{(2)} \le \ldots \le x_{(n)}. Thenthe following model for testing two maximum outliers can be proposed:

x_{(i)} = \left\{ \begin{array}{lcl} \mu + \epsilon_{(i)}, & \qquad & i = 1, \ldots, n - 2 \\ \mu + \Delta + \epsilon_{(j)} & \qquad & j = n-1, n \\ \end{array} \right.

with\epsilon \approx N(0,\sigma). The null hypothesis,H_0: \Delta = 0 is tested against the alternative,H_{\mathrm{A}}: \Delta > 0.

For testing two minimum outliers, the model can be proposedas

x_{(i)} = \left\{ \begin{array}{lcl} \mu + \Delta + \epsilon_{(j)} & \qquad & j = 1, 2 \\ \mu + \epsilon_{(i)}, & \qquad & i = 3, \ldots, n \\ \end{array} \right.

The null hypothesis is tested against the alternative,H_{\mathrm{A}}: \Delta < 0.

The p-value is computed with the functionpdgrubbs.

Value

A list with class"htest" containing the following components:

method

a character string indicating what type of test was performed.

data.name

a character string giving the name(s) of the data.

statistic

the estimated quantile of the test statistic.

p.value

the p-value for the test.

parameter

the parameters of the test statistic, if any.

alternative

a character string describing the alternative hypothesis.

estimates

the estimates, if any.

null.value

the estimate under the null hypothesis, if any.

References

Grubbs, F. E. (1950) Sample criteria for testing outlying observations.Ann. Math. Stat.21, 27–58.

Wilrich, P.-T. (2011) Critical values of Mandel's h and k,Grubbs and the Cochran test statistic.Adv. Stat. Anal..doi:10.1007/s10182-011-0185-y.

Examples

data(Pentosan)dat <- subset(Pentosan, subset = (material == "A"))labMeans <- tapply(dat$value, dat$lab, mean)doubleGrubbsTest(x = labMeans, alternative = "less")

Multiple Comparisons of Mean Rank Sums

Description

Performs the all-pairs comparison test for different factorlevels according to Dwass, Steel, Critchlow and Fligner.

Usage

dscfAllPairsTest(x, ...)## Default S3 method:dscfAllPairsTest(x, g, ...)## S3 method for class 'formula'dscfAllPairsTest(formula, data, subset, na.action, ...)

Arguments

x

a numeric vector of data values, or a list of numeric datavectors.

...

further arguments to be passed to or from methods.

g

a vector or factor object giving the group for thecorresponding elements of"x".Ignored with a warning if"x" is a list.

formula

a formula of the formresponse ~ group whereresponse gives the data values andgroup a vector orfactor of the corresponding groups.

data

an optional matrix or data frame (or similar: seemodel.frame) containing the variables in theformulaformula. By default the variables are taken fromenvironment(formula).

subset

an optional vector specifying asubset of observations to be used.

na.action

a function which indicates what should happen whenthe data containNAs. Defaults togetOption("na.action").

Details

For all-pairs comparisons in an one-factorial layoutwith non-normally distributed residuals the DSCFall-pairs comparison test can be used. A total ofm = k(k-1)/2hypotheses can be tested. The null hypothesisH_{ij}: F_i(x) = F_j(x) is tested in the two-tailed testagainst the alternativeA_{ij}: F_i(x) \ne F_j(x), ~~ i \ne j.As opposed to the all-pairs comparison procedures that dependon Kruskal ranks, the DSCF test is basically an extension ofthe U-test as re-ranking is conducted for each pairwise test.

The p-values are estimated from the studentized range distriburtion.

Value

A list with class"PMCMR" containing the following components:

method

a character string indicating what type of test was performed.

data.name

a character string giving the name(s) of the data.

statistic

lower-triangle matrix of the estimatedquantiles of the pairwise test statistics.

p.value

lower-triangle matrix of the p-values for the pairwise tests.

alternative

a character string describing the alternative hypothesis.

p.adjust.method

a character string describing the method for p-valueadjustment.

model

a data frame of the input data.

dist

a string that denotes the test distribution.

References

Douglas, C. E., Fligner, A. M. (1991) On distribution-free multiplecomparisons in the one-way analysis of variance,Communications inStatistics - Theory and Methods20, 127–139.

Dwass, M. (1960) Some k-sample rank-order tests. InContributions toProbability and Statistics, Edited by: I. Olkin,Stanford: Stanford University Press.

Steel, R. G. D. (1960) A rank sum test for comparing all pairs oftreatments,Technometrics2, 197–207

See Also

Tukey,pairwise.wilcox.test


Duncan's Multiple Range Test

Description

Performs Duncan's all-pairs comparisons test for normally distributeddata with equal group variances.

Usage

duncanTest(x, ...)## Default S3 method:duncanTest(x, g, ...)## S3 method for class 'formula'duncanTest(formula, data, subset, na.action, ...)## S3 method for class 'aov'duncanTest(x, ...)

Arguments

x

a numeric vector of data values, a list of numeric datavectors or a fitted model object, usually anaov fit.

...

further arguments to be passed to or from methods.

g

a vector or factor object giving the group for thecorresponding elements of"x".Ignored with a warning if"x" is a list.

formula

a formula of the formresponse ~ group whereresponse gives the data values andgroup a vector orfactor of the corresponding groups.

data

an optional matrix or data frame (or similar: seemodel.frame) containing the variables in theformulaformula. By default the variables are taken fromenvironment(formula).

subset

an optional vector specifying asubset of observations to be used.

na.action

a function which indicates what should happen whenthe data containNAs. Defaults togetOption("na.action").

Details

For all-pairs comparisons in an one-factorial layoutwith normally distributed residuals and equal variancesDuncan's multiple range test can be performed.LetX_{ij} denote a continuous random variablewith thej-the realization (1 \le j \le n_i)in thei-th group (1 \le i \le k). Furthermore, the totalsample size isN = \sum_{i=1}^k n_i. A total ofm = k(k-1)/2hypotheses can be tested: The null hypothesis isH_{ij}: \mu_i = \mu_j ~~ (i \ne j) is tested against the alternativeA_{ij}: \mu_i \ne \mu_j (two-tailed). Duncan's all-pairs teststatistics are given by

t_{(i)(j)} \frac{\bar{X}_{(i)} - \bar{X}_{(j)}} {s_{\mathrm{in}} \left(r\right)^{1/2}}, ~~ (i < j)

withs^2_{\mathrm{in}} the within-group ANOVA variance,r = k / \sum_{i=1}^k n_i and\bar{X}_{(i)} the increasinglyordered means1 \le i \le k.The null hypothesis is rejected if

\mathrm{Pr} \left\{ |t_{(i)(j)}| \ge q_{vm'\alpha'} | \mathrm{H} \right\}_{(i)(j)} = \alpha' = \min \left\{1,~ 1 - (1 - \alpha)^{(1 / (m' - 1))} \right\},

withv = N - k degree of freedom, the rangem' = 1 + |i - j| and\alpha' the Bonferroni adjustedalpha-error. The p-values are computedfrom theTukey distribution.

Value

A list with class"PMCMR" containing the following components:

method

a character string indicating what type of test was performed.

data.name

a character string giving the name(s) of the data.

statistic

lower-triangle matrix of the estimatedquantiles of the pairwise test statistics.

p.value

lower-triangle matrix of the p-values for the pairwise tests.

alternative

a character string describing the alternative hypothesis.

p.adjust.method

a character string describing the method for p-valueadjustment.

model

a data frame of the input data.

dist

a string that denotes the test distribution.

References

Duncan, D. B. (1955) Multiple range and multiple F tests,Biometrics11, 1–42.

See Also

Tukey,TukeyHSDtukeyTest

Examples

fit <- aov(weight ~ feed, chickwts)shapiro.test(residuals(fit))bartlett.test(weight ~ feed, chickwts)anova(fit)## also works with fitted objects of class aovres <- duncanTest(fit)summary(res)summaryGroup(res)

Dunnett's T3 Test

Description

Performs Dunnett's all-pairs comparison test for normally distributeddata with unequal variances.

Usage

dunnettT3Test(x, ...)## Default S3 method:dunnettT3Test(x, g, ...)## S3 method for class 'formula'dunnettT3Test(formula, data, subset, na.action, ...)## S3 method for class 'aov'dunnettT3Test(x, ...)

Arguments

x

a numeric vector of data values, a list of numeric datavectors or a fitted model object, usually anaov fit.

...

further arguments to be passed to or from methods.

g

a vector or factor object giving the group for thecorresponding elements of"x".Ignored with a warning if"x" is a list.

formula

a formula of the formresponse ~ group whereresponse gives the data values andgroup a vector orfactor of the corresponding groups.

data

an optional matrix or data frame (or similar: seemodel.frame) containing the variables in theformulaformula. By default the variables are taken fromenvironment(formula).

subset

an optional vector specifying asubset of observations to be used.

na.action

a function which indicates what should happen whenthe data containNAs. Defaults togetOption("na.action").

Details

For all-pairs comparisons in an one-factorial layoutwith normally distributed residuals but unequal groups variancesthe T3 test of Dunnett can be performed.LetX_{ij} denote a continuous random variablewith thej-the realization (1 \le j \le n_i)in thei-th group (1 \le i \le k). Furthermore, the totalsample size isN = \sum_{i=1}^k n_i. A total ofm = k(k-1)/2hypotheses can be tested: The null hypothesis isH_{ij}: \mu_i = \mu_j ~~ (i \ne j) is tested against the alternativeA_{ij}: \mu_i \ne \mu_j (two-tailed). Dunnett T3 all-pairstest statistics are given by

t_{ij} \frac{\bar{X}_i - \bar{X_j}} {\left( s^2_j / n_j + s^2_i / n_i \right)^{1/2}}, ~~ (i \ne j)

withs^2_i the variance of thei-th group.The null hypothesis is rejected (two-tailed) if

\mathrm{Pr} \left\{ |t_{ij}| \ge T_{v_{ij}\rho_{ij}\alpha'/2} | \mathrm{H} \right\}_{ij} = \alpha,

with Welch's approximate solution for calculating the degree of freedom.

v_{ij} = \frac{\left( s^2_i / n_i + s^2_j / n_j \right)^2} {s^4_i / n^2_i \left(n_i - 1\right) + s^4_j / n^2_j \left(n_j - 1\right)}.

Thep-values are computed from thestudentized maximum modulus distributionthat is the equivalent of the multivariate t distributionwith\rho_{ii} = 1, ~ \rho_{ij} = 0 ~ (i \ne j).The functionpmvt is used tocalculate thep-values.

Value

A list with class"PMCMR" containing the following components:

method

a character string indicating what type of test was performed.

data.name

a character string giving the name(s) of the data.

statistic

lower-triangle matrix of the estimatedquantiles of the pairwise test statistics.

p.value

lower-triangle matrix of the p-values for the pairwise tests.

alternative

a character string describing the alternative hypothesis.

p.adjust.method

a character string describing the method for p-valueadjustment.

model

a data frame of the input data.

dist

a string that denotes the test distribution.

References

C. W. Dunnett (1980) Pair wise multiple comparisons in the unequalvariance case,Journal of the American StatisticalAssociation75, 796–800.

See Also

pmvt

Examples

fit <- aov(weight ~ feed, chickwts)shapiro.test(residuals(fit))bartlett.test(weight ~ feed, chickwts)anova(fit)## also works with fitted objects of class aovres <- dunnettT3Test(fit)summary(res)summaryGroup(res)

Dunnett's Many-to-One Comparisons Test

Description

Performs Dunnett's multiple comparisons test with one control.

Usage

dunnettTest(x, ...)## Default S3 method:dunnettTest(x, g, alternative = c("two.sided", "greater", "less"), ...)## S3 method for class 'formula'dunnettTest(  formula,  data,  subset,  na.action,  alternative = c("two.sided", "greater", "less"),  ...)## S3 method for class 'aov'dunnettTest(x, alternative = c("two.sided", "greater", "less"), ...)

Arguments

x

a numeric vector of data values, a list of numeric datavectors or a fitted model object, usually anaov fit.

...

further arguments to be passed to or from methods.

g

a vector or factor object giving the group for thecorresponding elements of"x".Ignored with a warning if"x" is a list.

alternative

the alternative hypothesis. Defaults totwo.sided.

formula

a formula of the formresponse ~ group whereresponse gives the data values andgroup a vector orfactor of the corresponding groups.

data

an optional matrix or data frame (or similar: seemodel.frame) containing the variables in theformulaformula. By default the variables are taken fromenvironment(formula).

subset

an optional vector specifying asubset of observations to be used.

na.action

a function which indicates what should happen whenthe data containNAs. Defaults togetOption("na.action").

Details

For many-to-one comparisons in an one-factorial layoutwith normally distributed residuals Dunnett's testcan be used.LetX_{0j} denote a continuous random variablewith thej-the realization of the control group(1 \le j \le n_0) andX_{ij} thej-the realizationin thei-th treatment group (1 \le i \le k).Furthermore, the total sample size isN = n_0 + \sum_{i=1}^k n_i.A total ofm = k hypotheses can be tested: The null hypothesis isH_{i}: \mu_i = \mu_0 is tested against the alternativeA_{i}: \mu_i \ne \mu_0 (two-tailed). Dunnett's teststatistics are given by

t_{i} \frac{\bar{X}_i - \bar{X_0}} {s_{\mathrm{in}} \left(1/n_0 + 1/n_i\right)^{1/2}}, ~~ (1 \le i \le k)

withs^2_{\mathrm{in}} the within-group ANOVA variance.The null hypothesis is rejected if|t_{ij}| > |T_{kv\rho\alpha}| (two-tailed),withv = N - k degree of freedom andrho the correlation:

\rho_{ij} = \sqrt{\frac{n_i n_j} {\left(n_i + n_0\right) \left(n_j+ n_0\right)}} ~~ (i \ne j).

The p-values are computed with the functionpDunnettthat is a wrapper to the the multivariate-t distribution as implemented in the functionpmvt.

Value

A list with class"PMCMR" containing the following components:

method

a character string indicating what type of test was performed.

data.name

a character string giving the name(s) of the data.

statistic

lower-triangle matrix of the estimatedquantiles of the pairwise test statistics.

p.value

lower-triangle matrix of the p-values for the pairwise tests.

alternative

a character string describing the alternative hypothesis.

p.adjust.method

a character string describing the method for p-valueadjustment.

model

a data frame of the input data.

dist

a string that denotes the test distribution.

References

Dunnett, C. W. (1955) A multiple comparison procedure for comparing severaltreatments with a control.Journal of the American Statistical Association50, 1096–1121.

OECD (ed. 2006)Current approaches in the statistical analysisof ecotoxicity data: A guidance to application - Annexes. OECD Serieson testing and assessment, No. 54.

See Also

pmvtpDunnett

Examples

fit <- aov(Y ~ DOSE, data = trout)shapiro.test(residuals(fit))bartlett.test(Y ~ DOSE, data = trout)## works with fitted object of class aovsummary(dunnettTest(fit, alternative = "less"))

All-Pairs Comparisons Test for Balanced Incomplete Block Designs

Description

Performs Conover-Iman all-pairs comparison test for a balanced incompleteblock design (BIBD).

Usage

durbinAllPairsTest(y, ...)## Default S3 method:durbinAllPairsTest(y, groups, blocks, p.adjust.method = p.adjust.methods, ...)

Arguments

y

a numeric vector of data values, or a list of numeric datavectors.

groups

a vector or factor object giving the group for thecorresponding elements of"x". Ignored with a warning if"x" is a list.

blocks

a vector or factor object giving the block for thecorresponding elements of"x".Ignored with a warning if"x" is a list.

p.adjust.method

method for adjusting p values(seep.adjust)

...

further arguments to be passed to or from methods.

Details

For all-pairs comparisons in a balanced incomplete block designthe proposed test of Conover and Imam can be applied.A total ofm = k(k-1)/2hypotheses can be tested. The null hypothesisH_{ij}: \theta_i = \theta_j is tested in the two-tailed testagainst the alternativeA_{ij}: \theta_i \ne \theta_j, ~~ i \ne j.

The p-values are computed from the t distribution. If no p-value adjustmentis performed (p.adjust.method = "none"),than a simple protected test is recommended, i.e.the all-pairs comparisons should only be applied after a significantdurbinTest. However, any method as implemented inp.adjust.methods can be selected by the user.

Value

A list with class"PMCMR" containing the following components:

method

a character string indicating what type of test was performed.

data.name

a character string giving the name(s) of the data.

statistic

lower-triangle matrix of the estimatedquantiles of the pairwise test statistics.

p.value

lower-triangle matrix of the p-values for the pairwise tests.

alternative

a character string describing the alternative hypothesis.

p.adjust.method

a character string describing the method for p-valueadjustment.

model

a data frame of the input data.

dist

a string that denotes the test distribution.

References

Conover, W. J., Iman, R. L. (1979)On multiple-comparisonsprocedures, Tech. Rep. LA-7677-MS, Los Alamos Scientific Laboratory.

Conover, W. J. (1999)Practical nonparametric Statistics,3rd. Edition, Wiley.

See Also

durbinTest

Examples

## Example for an incomplete block design:## Data from Conover (1999, p. 391).y <- matrix(c(2,NA,NA,NA,3, NA,  3,  3,  3, NA, NA, NA,  3, NA, NA,  1,  2, NA, NA, NA,  1,  1, NA,  1,  1,NA, NA, NA, NA,  2, NA,  2,  1, NA, NA, NA, NA, 3, NA,  2,  1, NA, NA, NA, NA,  3, NA,  2,  2),ncol=7, nrow=7, byrow=FALSE, dimnames=list(1:7, LETTERS[1:7]))durbinAllPairsTest(y)

Durbin Test

Description

Performs Durbin's tests whether k groups(or treatments) in a two-way balanced incomplete block design (BIBD)have identical effects.

Usage

durbinTest(y, ...)## Default S3 method:durbinTest(y, groups, blocks, ...)

Arguments

y

a numeric vector of data values, or a list of numeric datavectors.

groups

a vector or factor object giving the group for thecorresponding elements of"x". Ignored with a warning if"x" is a list.

blocks

a vector or factor object giving the block for thecorresponding elements of"x".Ignored with a warning if"x" is a list.

...

further arguments to be passed to or from methods.

Details

For testing a two factorial layout of a balanced incompleteblock design whether thek groups have identical effects,the Durbin test can be performed. The null hypothesis,H_0: \theta_i = \theta_j ~ (1 \le i < j \le k),is tested against the alternative that at leastone\theta_i \ne \theta_j.

The p-values are computed from the chi-square distribution.

Value

A list with class"htest" containing the following components:

method

a character string indicating what type of test was performed.

data.name

a character string giving the name(s) of the data.

statistic

the estimated quantile of the test statistic.

p.value

the p-value for the test.

parameter

the parameters of the test statistic, if any.

alternative

a character string describing the alternative hypothesis.

estimates

the estimates, if any.

null.value

the estimate under the null hypothesis, if any.

Note

The function does not test, whether it is a true BIBD.This function does not test for ties.

References

Conover,W. J. (1999)Practical nonparametric Statistics,3rd. Edition, Wiley.

Heckert, N. A., Filliben, J. J. (2003)NIST Handbook 148:Dataplot Reference Manual, Volume 2:Let Subcommands and Library Functions.National Institute of Standards and Technology Handbook Series, June 2003.

Examples

## Example for an incomplete block design:## Data from Conover (1999, p. 391).y <- matrix(c(2,NA,NA,NA,3, NA,  3,  3,  3, NA, NA, NA,  3, NA, NA,  1,  2, NA, NA, NA,  1,  1, NA,  1,  1,NA, NA, NA, NA,  2, NA,  2,  1, NA, NA, NA, NA, 3, NA,  2,  1, NA, NA, NA, NA,  3, NA,  2,  2), ncol=7, nrow=7, byrow=FALSE,dimnames=list(1:7, LETTERS[1:7]))durbinTest(y)

Testing Several Treatments With One Control

Description

Performs Fligner-Wolfe non-parametric test forsimultaneous testing of several locations of treatment groupsagainst the location of the control group.

Usage

flignerWolfeTest(x, ...)## Default S3 method:flignerWolfeTest(  x,  g,  alternative = c("greater", "less"),  dist = c("Wilcoxon", "Normal"),  ...)## S3 method for class 'formula'flignerWolfeTest(  formula,  data,  subset,  na.action,  alternative = c("greater", "less"),  dist = c("Wilcoxon", "Normal"),  ...)

Arguments

x

a numeric vector of data values, or a list of numeric datavectors.

...

further arguments to be passed to or from methods.

g

a vector or factor object giving the group for thecorresponding elements of"x".Ignored with a warning if"x" is a list.

alternative

the alternative hypothesis. Defaults to"greater".

dist

the test distribution. Defaults to"Wilcoxon".

formula

a formula of the formresponse ~ group whereresponse gives the data values andgroup a vector orfactor of the corresponding groups.

data

an optional matrix or data frame (or similar: seemodel.frame) containing the variables in theformulaformula. By default the variables are taken fromenvironment(formula).

subset

an optional vector specifying asubset of observations to be used.

na.action

a function which indicates what should happen whenthe data containNAs. Defaults togetOption("na.action").

Details

For a one-factorial layout with non-normally distributed residualsthe Fligner-Wolfe test can be used.

Let there bek-1-treatment groups and one control group, thenthe null hypothesis, H_0: \theta_i - \theta_c = 0 ~ (1 \le i \le k-1)is tested against the alternative (greater),A_1: \theta_i - \theta_c > 0 ~ (1 \le i \le k-1),with at least one inequality being strict.

Letn_c denote the sample size of the control group,N^t = \sum_{i=1}^{k-1} n_i the sum of all treatmentsample sizes andN = N^t + n_c. The test statistic without takenties into account is

W = \sum_{j=1}^{k-1} \sum_{i=1}^{n_i} r_{ij} - \frac{N^t \left(N^t + 1 \right) }{2}

withr_{ij} the rank of variablex_{ij}.The null hypothesis is rejected,ifW > W_{\alpha,m,n} withm = N^t andn = n_c.

In the presence of ties, the statistic is

\hat{z} = \frac{W - n_c N^t / 2}{s_W},

where

s_W = \frac{n_c N^t}{12 N \left(N - 1 \right)} \sum_{j=1}^g t_j \left(t_j^2 - 1\right),

withg the number of tied groups andt_jthe number of tied values in thejth group. The null hypothesisis rejected, if\hat{z} > z_\alpha (as cited in EPA 2006).

Ifdist = Wilcoxon, then thep-values are estimated from theWilcoxondistribution, else theNormal distribution is used. The latter can be used,if ties are present.

Value

A list with class"htest" containing the following components:

method

a character string indicating what type of test was performed.

data.name

a character string giving the name(s) of the data.

statistic

the estimated quantile of the test statistic.

p.value

the p-value for the test.

parameter

the parameters of the test statistic, if any.

alternative

a character string describing the alternative hypothesis.

estimates

the estimates, if any.

null.value

the estimate under the null hypothesis, if any.

Note

Factor labels forg must be assigned in such a way,that they can be increasingly ordered from zero-dosecontrol to the highest dose level, e.g. integers{0, 1, 2, ..., k} or letters {a, b, c, ...}.Otherwise the function may not select the correct valuesfor intended zero-dose control.

It is safer, to i) label the factor levels as given above,and to ii) sort the data according to increasing dose-levelsprior to call the function (seeorder,factor).

References

EPA (2006)Data Quality Assessment:Statistical Methods for Practitioners(Guideline No. EPA QA/G-9S), US-EPA.

Fligner, M.A., Wolfe, D.A. (1982)Distribution-free tests for comparing severaltreatments with a control.Stat Neerl36,119–127.

See Also

kruskalTest andshirleyWilliamsTestof the packagePMCMRplus,kruskal.test of the librarystats.

Examples

## Example from Sachs (1997, p. 402)x <- c(106, 114, 116, 127, 145,       110, 125, 143, 148, 151,       136, 139, 149, 160, 174)g <- gl(3,5)levels(g) <- c("A", "B", "C")## Chacko's testchackoTest(x, g)## Cuzick's testcuzickTest(x, g)## Johnson-Mehrotra testjohnsonTest(x, g)## Jonckheere-Terpstra testjonckheereTest(x, g)## Le's testleTest(x, g)## Spearman type testspearmanTest(x, g)## Murakami's BWS trend testbwsTrendTest(x, g)## Fligner-Wolfe testflignerWolfeTest(x, g)## Shan-Young-Kang testshanTest(x, g)

Conover's All-Pairs Comparisons Test for Unreplicated Blocked Data

Description

Performs Conover's all-pairs comparisons tests of Friedman-type ranked data.

Usage

frdAllPairsConoverTest(y, ...)## Default S3 method:frdAllPairsConoverTest(  y,  groups,  blocks,  p.adjust.method = c("single-step", p.adjust.methods),  ...)

Arguments

y

a numeric vector of data values, or a list of numeric datavectors.

groups

a vector or factor object giving the group for thecorresponding elements of"x". Ignored with a warning if"x" is a list.

blocks

a vector or factor object giving the block for thecorresponding elements of"x".Ignored with a warning if"x" is a list.

p.adjust.method

method for adjusting p values(seep.adjust).

...

further arguments to be passed to or from methods.

Details

For all-pairs comparisons in a two factorial unreplicatedcomplete block designwith non-normally distributed residuals, Conover's test can beperformed on Friedman-type ranked data.

A total ofm = k ( k -1 )/2 hypotheses can be tested.The null hypothesis, H_{ij}: \theta_i = \theta_j, is testedin the two-tailed case against the alternative,A_{ij}: \theta_i \ne \theta_j, ~~ i \ne j.

Ifp.adjust.method == "single-step" the p-values are computedfrom the studentized range distribution. Otherwise,the p-values are computed from the t-distribution usingany of the p-adjustment methods as included inp.adjust.

Value

A list with class"PMCMR" containing the following components:

method

a character string indicating what type of test was performed.

data.name

a character string giving the name(s) of the data.

statistic

lower-triangle matrix of the estimatedquantiles of the pairwise test statistics.

p.value

lower-triangle matrix of the p-values for the pairwise tests.

alternative

a character string describing the alternative hypothesis.

p.adjust.method

a character string describing the method for p-valueadjustment.

model

a data frame of the input data.

dist

a string that denotes the test distribution.

References

Conover, W. J., Iman, R. L. (1979)On multiple-comparisonsprocedures, Tech. Rep. LA-7677-MS, Los Alamos Scientific Laboratory.

Conover, W. J. (1999)Practical nonparametric Statistics,3rd. Edition, Wiley.

See Also

friedmanTest,friedman.test,frdAllPairsExactTest,frdAllPairsMillerTest,frdAllPairsNemenyiTest,frdAllPairsSiegelTest

Examples

 ## Sachs, 1997, p. 675 ## Six persons (block) received six different diuretics ## (A to F, treatment). ## The responses are the Na-concentration (mval) ## in the urine measured 2 hours after each treatment. ## y <- matrix(c( 3.88, 5.64, 5.76, 4.25, 5.91, 4.33, 30.58, 30.14, 16.92, 23.19, 26.74, 10.91, 25.24, 33.52, 25.45, 18.85, 20.45, 26.67, 4.44, 7.94, 4.04, 4.4, 4.23, 4.36, 29.41, 30.72, 32.92, 28.23, 23.35, 12, 38.87, 33.12, 39.15, 28.06, 38.23, 26.65),nrow=6, ncol=6, dimnames=list(1:6, LETTERS[1:6])) print(y) friedmanTest(y) ## Eisinga et al. 2017 frdAllPairsExactTest(y=y, p.adjust = "bonferroni") ## Conover's test frdAllPairsConoverTest(y=y, p.adjust = "bonferroni") ## Nemenyi's test frdAllPairsNemenyiTest(y=y) ## Miller et al. frdAllPairsMillerTest(y=y) ## Siegel-Castellan frdAllPairsSiegelTest(y=y, p.adjust = "bonferroni") ## Irrelevant of group order? x <- as.vector(y) g <- rep(colnames(y), each = length(x)/length(colnames(y))) b <- rep(rownames(y), times = length(x)/length(rownames(y))) xDF <- data.frame(x, g, b) # grouped by colnames frdAllPairsNemenyiTest(xDF$x, groups = xDF$g, blocks = xDF$b) o <- order(xDF$b) # order per block increasingly frdAllPairsNemenyiTest(xDF$x[o], groups = xDF$g[o], blocks = xDF$b[o]) o <- order(xDF$x) # order per value increasingly frdAllPairsNemenyiTest(xDF$x[o], groups = xDF$g[o], blocks = xDF$b[o]) ## formula method (only works for Nemenyi) frdAllPairsNemenyiTest(x ~ g | b, data = xDF)

Exact All-Pairs Comparisons Test for Unreplicated Blocked Data

Description

Performs exact all-pairs comparisons tests of Friedman-type ranked dataaccording to Eisinga et al. (2017).

Usage

frdAllPairsExactTest(y, ...)## Default S3 method:frdAllPairsExactTest(  y,  groups,  blocks,  p.adjust.method = p.adjust.methods,  ...)

Arguments

y

a numeric vector of data values, or a list of numeric datavectors.

groups

a vector or factor object giving the group for thecorresponding elements of"x". Ignored with a warning if"x" is a list.

blocks

a vector or factor object giving the block for thecorresponding elements of"x".Ignored with a warning if"x" is a list.

p.adjust.method

method for adjusting p values(seep.adjust).

...

further arguments to be passed to or from methods.

Details

For all-pairs comparisons in a two factorial unreplicatedcomplete block designwith non-normally distributed residuals, an exact test can beperformed on Friedman-type ranked data.

A total ofm = k ( k -1 )/2 hypotheses can be tested.The null hypothesis, H_{ij}: \theta_i = \theta_j, is testedin the two-tailed case against the alternative,A_{ij}: \theta_i \ne \theta_j, ~~ i \ne j.

The exactp-valuesare computed using the code of"pexactfrsd.R"that was a supplement to the publication of Eisinga et al. (2017).Additionally, any of thep-adjustment methodsas included inp.adjust can be selected, forp-valueadjustment.

Value

A list with class"PMCMR" containing the following components:

method

a character string indicating what type of test was performed.

data.name

a character string giving the name(s) of the data.

statistic

lower-triangle matrix of the estimatedquantiles of the pairwise test statistics.

p.value

lower-triangle matrix of the p-values for the pairwise tests.

alternative

a character string describing the alternative hypothesis.

p.adjust.method

a character string describing the method for p-valueadjustment.

model

a data frame of the input data.

dist

a string that denotes the test distribution.

Source

The functionfrdAllPairsExactTest uses the codeof the filepexactfrsd.R that was a supplement to:

R. Eisinga, T. Heskes, B. Pelzer, M. Te Grotenhuis (2017),Exact p-values for Pairwise Comparison of Friedman Rank Sums,with Application to Comparing Classifiers,BMC Bioinformatics, 18:68.

References

Eisinga, R., Heskes, T., Pelzer, B., Te Grotenhuis, M. (2017)Exact p-values for Pairwise Comparison of Friedman Rank Sums,with Application to Comparing Classifiers,BMC Bioinformatics, 18:68.

See Also

friedmanTest,friedman.test,frdAllPairsConoverTest,frdAllPairsMillerTest,frdAllPairsNemenyiTest,frdAllPairsSiegelTest

Examples

 ## Sachs, 1997, p. 675 ## Six persons (block) received six different diuretics ## (A to F, treatment). ## The responses are the Na-concentration (mval) ## in the urine measured 2 hours after each treatment. ## y <- matrix(c( 3.88, 5.64, 5.76, 4.25, 5.91, 4.33, 30.58, 30.14, 16.92, 23.19, 26.74, 10.91, 25.24, 33.52, 25.45, 18.85, 20.45, 26.67, 4.44, 7.94, 4.04, 4.4, 4.23, 4.36, 29.41, 30.72, 32.92, 28.23, 23.35, 12, 38.87, 33.12, 39.15, 28.06, 38.23, 26.65),nrow=6, ncol=6, dimnames=list(1:6, LETTERS[1:6])) print(y) friedmanTest(y) ## Eisinga et al. 2017 frdAllPairsExactTest(y=y, p.adjust = "bonferroni") ## Conover's test frdAllPairsConoverTest(y=y, p.adjust = "bonferroni") ## Nemenyi's test frdAllPairsNemenyiTest(y=y) ## Miller et al. frdAllPairsMillerTest(y=y) ## Siegel-Castellan frdAllPairsSiegelTest(y=y, p.adjust = "bonferroni") ## Irrelevant of group order? x <- as.vector(y) g <- rep(colnames(y), each = length(x)/length(colnames(y))) b <- rep(rownames(y), times = length(x)/length(rownames(y))) xDF <- data.frame(x, g, b) # grouped by colnames frdAllPairsNemenyiTest(xDF$x, groups = xDF$g, blocks = xDF$b) o <- order(xDF$b) # order per block increasingly frdAllPairsNemenyiTest(xDF$x[o], groups = xDF$g[o], blocks = xDF$b[o]) o <- order(xDF$x) # order per value increasingly frdAllPairsNemenyiTest(xDF$x[o], groups = xDF$g[o], blocks = xDF$b[o]) ## formula method (only works for Nemenyi) frdAllPairsNemenyiTest(x ~ g | b, data = xDF)

Millers's All-Pairs Comparisons Test for Unreplicated Blocked Data

Description

Performs Miller's all-pairs comparisons tests of Friedman-type ranked data.

Usage

frdAllPairsMillerTest(y, ...)## Default S3 method:frdAllPairsMillerTest(y, groups, blocks, ...)

Arguments

y

a numeric vector of data values, or a list of numeric datavectors.

groups

a vector or factor object giving the group for thecorresponding elements of"x". Ignored with a warning if"x" is a list.

blocks

a vector or factor object giving the block for thecorresponding elements of"x".Ignored with a warning if"x" is a list.

...

further arguments to be passed to or from methods.

Details

For all-pairs comparisons in a two factorial unreplicatedcomplete block designwith non-normally distributed residuals, Miller's test can beperformed on Friedman-type ranked data.

A total ofm = k ( k -1 )/2 hypotheses can be tested.The null hypothesis, H_{ij}: \theta_i = \theta_j, is testedin the two-tailed case against the alternative,A_{ij}: \theta_i \ne \theta_j, ~~ i \ne j.

Thep-values are computed from the chi-square distribution.

Value

A list with class"PMCMR" containing the following components:

method

a character string indicating what type of test was performed.

data.name

a character string giving the name(s) of the data.

statistic

lower-triangle matrix of the estimatedquantiles of the pairwise test statistics.

p.value

lower-triangle matrix of the p-values for the pairwise tests.

alternative

a character string describing the alternative hypothesis.

p.adjust.method

a character string describing the method for p-valueadjustment.

model

a data frame of the input data.

dist

a string that denotes the test distribution.

References

Bortz J., Lienert, G. A., Boehnke, K. (1990)VerteilungsfreieMethoden in der Biostatistik. Berlin: Springer.

Miller Jr., R. G. (1996)Simultaneous statistical inference.New York: McGraw-Hill.

Wike, E. L. (2006),Data Analysis. A Statistical Primer forPsychology Students. New Brunswick: Aldine Transaction.

See Also

friedmanTest,friedman.test,frdAllPairsExactTest,frdAllPairsConoverTest,frdAllPairsNemenyiTest,frdAllPairsSiegelTest

Examples

 ## Sachs, 1997, p. 675 ## Six persons (block) received six different diuretics ## (A to F, treatment). ## The responses are the Na-concentration (mval) ## in the urine measured 2 hours after each treatment. ## y <- matrix(c( 3.88, 5.64, 5.76, 4.25, 5.91, 4.33, 30.58, 30.14, 16.92, 23.19, 26.74, 10.91, 25.24, 33.52, 25.45, 18.85, 20.45, 26.67, 4.44, 7.94, 4.04, 4.4, 4.23, 4.36, 29.41, 30.72, 32.92, 28.23, 23.35, 12, 38.87, 33.12, 39.15, 28.06, 38.23, 26.65),nrow=6, ncol=6, dimnames=list(1:6, LETTERS[1:6])) print(y) friedmanTest(y) ## Eisinga et al. 2017 frdAllPairsExactTest(y=y, p.adjust = "bonferroni") ## Conover's test frdAllPairsConoverTest(y=y, p.adjust = "bonferroni") ## Nemenyi's test frdAllPairsNemenyiTest(y=y) ## Miller et al. frdAllPairsMillerTest(y=y) ## Siegel-Castellan frdAllPairsSiegelTest(y=y, p.adjust = "bonferroni") ## Irrelevant of group order? x <- as.vector(y) g <- rep(colnames(y), each = length(x)/length(colnames(y))) b <- rep(rownames(y), times = length(x)/length(rownames(y))) xDF <- data.frame(x, g, b) # grouped by colnames frdAllPairsNemenyiTest(xDF$x, groups = xDF$g, blocks = xDF$b) o <- order(xDF$b) # order per block increasingly frdAllPairsNemenyiTest(xDF$x[o], groups = xDF$g[o], blocks = xDF$b[o]) o <- order(xDF$x) # order per value increasingly frdAllPairsNemenyiTest(xDF$x[o], groups = xDF$g[o], blocks = xDF$b[o]) ## formula method (only works for Nemenyi) frdAllPairsNemenyiTest(x ~ g | b, data = xDF)

Nemenyi's All-Pairs Comparisons Test for Unreplicated Blocked Data

Description

Performs Nemenyi's all-pairs comparisons tests of Friedman-type ranked data.

Usage

frdAllPairsNemenyiTest(y, ...)## Default S3 method:frdAllPairsNemenyiTest(y, groups, blocks, ...)## S3 method for class 'formula'frdAllPairsNemenyiTest(formula, data, subset, na.action, ...)

Arguments

y

a numeric vector of data values, or a list of numeric datavectors.

groups

a vector or factor object giving the group for thecorresponding elements of"x". Ignored with a warning if"x" is a list.

blocks

a vector or factor object giving the block for thecorresponding elements of"x".Ignored with a warning if"x" is a list.

formula

a formula of the forma ~ b | c wherea, b andc give the data values andthe corresponding groups and blocks, respectively.

data

an optional matrix or data frame (or similar: seemodel.frame) containing the variables in theformulaformula. By default the variables are taken fromenvironment(formula).

subset

an optional vector specifying asubset of observations to be used.

na.action

a function which indicates what should happen whenthe data containNAs. Defaults togetOption("na.action").

...

further arguments to be passed to or from methods.

Details

For all-pairs comparisons in a two factorial unreplicatedcomplete block designwith non-normally distributed residuals, Nemenyi's test can beperformed on Friedman-type ranked data.

A total ofm = k ( k -1 )/2 hypotheses can be tested.The null hypothesis, H_{ij}: \theta_i = \theta_j, is testedin the two-tailed case against the alternative,A_{ij}: \theta_i \ne \theta_j, ~~ i \ne j.

Thep-values are computed from the studentized range distribution.

Value

A list with class"PMCMR" containing the following components:

method

a character string indicating what type of test was performed.

data.name

a character string giving the name(s) of the data.

statistic

lower-triangle matrix of the estimatedquantiles of the pairwise test statistics.

p.value

lower-triangle matrix of the p-values for the pairwise tests.

alternative

a character string describing the alternative hypothesis.

p.adjust.method

a character string describing the method for p-valueadjustment.

model

a data frame of the input data.

dist

a string that denotes the test distribution.

References

Demsar, J. (2006) Statistical comparisons of classifiers over multipledata sets,Journal of Machine Learning Research7, 1–30.

Miller Jr., R. G. (1996)Simultaneous statistical inference.New York: McGraw-Hill.

Nemenyi, P. (1963),Distribution-free Multiple Comparisons.Ph.D. thesis, Princeton University.

Sachs, L. (1997)Angewandte Statistik. Berlin: Springer.

See Also

friedmanTest,friedman.test,frdAllPairsExactTest,frdAllPairsConoverTest,frdAllPairsMillerTest,frdAllPairsSiegelTest

Examples

 ## Sachs, 1997, p. 675 ## Six persons (block) received six different diuretics ## (A to F, treatment). ## The responses are the Na-concentration (mval) ## in the urine measured 2 hours after each treatment. ## y <- matrix(c( 3.88, 5.64, 5.76, 4.25, 5.91, 4.33, 30.58, 30.14, 16.92, 23.19, 26.74, 10.91, 25.24, 33.52, 25.45, 18.85, 20.45, 26.67, 4.44, 7.94, 4.04, 4.4, 4.23, 4.36, 29.41, 30.72, 32.92, 28.23, 23.35, 12, 38.87, 33.12, 39.15, 28.06, 38.23, 26.65),nrow=6, ncol=6, dimnames=list(1:6, LETTERS[1:6])) print(y) friedmanTest(y) ## Eisinga et al. 2017 frdAllPairsExactTest(y=y, p.adjust = "bonferroni") ## Conover's test frdAllPairsConoverTest(y=y, p.adjust = "bonferroni") ## Nemenyi's test frdAllPairsNemenyiTest(y=y) ## Miller et al. frdAllPairsMillerTest(y=y) ## Siegel-Castellan frdAllPairsSiegelTest(y=y, p.adjust = "bonferroni") ## Irrelevant of group order? x <- as.vector(y) g <- rep(colnames(y), each = length(x)/length(colnames(y))) b <- rep(rownames(y), times = length(x)/length(rownames(y))) xDF <- data.frame(x, g, b) # grouped by colnames frdAllPairsNemenyiTest(xDF$x, groups = xDF$g, blocks = xDF$b) o <- order(xDF$b) # order per block increasingly frdAllPairsNemenyiTest(xDF$x[o], groups = xDF$g[o], blocks = xDF$b[o]) o <- order(xDF$x) # order per value increasingly frdAllPairsNemenyiTest(xDF$x[o], groups = xDF$g[o], blocks = xDF$b[o]) ## formula method (only works for Nemenyi) frdAllPairsNemenyiTest(x ~ g | b, data = xDF)

Siegel and Castellan's All-Pairs Comparisons Test forUnreplicated Blocked Data

Description

Performs Siegel and Castellan's all-pairs comparisons testsof Friedman-type ranked data.

Usage

frdAllPairsSiegelTest(y, ...)## Default S3 method:frdAllPairsSiegelTest(  y,  groups,  blocks,  p.adjust.method = p.adjust.methods,  ...)

Arguments

y

a numeric vector of data values, or a list of numeric datavectors.

groups

a vector or factor object giving the group for thecorresponding elements of"x". Ignored with a warning if"x" is a list.

blocks

a vector or factor object giving the block for thecorresponding elements of"x".Ignored with a warning if"x" is a list.

p.adjust.method

method for adjusting p values(seep.adjust).

...

further arguments to be passed to or from methods.

Details

For all-pairs comparisons in a two factorial unreplicatedcomplete block designwith non-normally distributed residuals, Siegel and Castellan's test can beperformed on Friedman-type ranked data.

A total ofm = k ( k -1 )/2 hypotheses can be tested.The null hypothesis, H_{ij}: \theta_i = \theta_j, is testedin the two-tailed case against the alternative,A_{ij}: \theta_i \ne \theta_j, ~~ i \ne j.

Thep-values are computed from the standard normal distribution.Any method as implemented inp.adjust can be used forp-value adjustment.

Value

A list with class"PMCMR" containing the following components:

method

a character string indicating what type of test was performed.

data.name

a character string giving the name(s) of the data.

statistic

lower-triangle matrix of the estimatedquantiles of the pairwise test statistics.

p.value

lower-triangle matrix of the p-values for the pairwise tests.

alternative

a character string describing the alternative hypothesis.

p.adjust.method

a character string describing the method for p-valueadjustment.

model

a data frame of the input data.

dist

a string that denotes the test distribution.

References

Siegel, S., Castellan Jr., N. J. (1988)NonparametricStatistics for the Behavioral Sciences. 2nd ed. New York: McGraw-Hill.

See Also

friedmanTest,friedman.test,frdAllPairsExactTest,frdAllPairsConoverTest,frdAllPairsNemenyiTest,frdAllPairsMillerTest

Examples

 ## Sachs, 1997, p. 675 ## Six persons (block) received six different diuretics ## (A to F, treatment). ## The responses are the Na-concentration (mval) ## in the urine measured 2 hours after each treatment. ## y <- matrix(c( 3.88, 5.64, 5.76, 4.25, 5.91, 4.33, 30.58, 30.14, 16.92, 23.19, 26.74, 10.91, 25.24, 33.52, 25.45, 18.85, 20.45, 26.67, 4.44, 7.94, 4.04, 4.4, 4.23, 4.36, 29.41, 30.72, 32.92, 28.23, 23.35, 12, 38.87, 33.12, 39.15, 28.06, 38.23, 26.65),nrow=6, ncol=6, dimnames=list(1:6, LETTERS[1:6])) print(y) friedmanTest(y) ## Eisinga et al. 2017 frdAllPairsExactTest(y=y, p.adjust = "bonferroni") ## Conover's test frdAllPairsConoverTest(y=y, p.adjust = "bonferroni") ## Nemenyi's test frdAllPairsNemenyiTest(y=y) ## Miller et al. frdAllPairsMillerTest(y=y) ## Siegel-Castellan frdAllPairsSiegelTest(y=y, p.adjust = "bonferroni") ## Irrelevant of group order? x <- as.vector(y) g <- rep(colnames(y), each = length(x)/length(colnames(y))) b <- rep(rownames(y), times = length(x)/length(rownames(y))) xDF <- data.frame(x, g, b) # grouped by colnames frdAllPairsNemenyiTest(xDF$x, groups = xDF$g, blocks = xDF$b) o <- order(xDF$b) # order per block increasingly frdAllPairsNemenyiTest(xDF$x[o], groups = xDF$g[o], blocks = xDF$b[o]) o <- order(xDF$x) # order per value increasingly frdAllPairsNemenyiTest(xDF$x[o], groups = xDF$g[o], blocks = xDF$b[o]) ## formula method (only works for Nemenyi) frdAllPairsNemenyiTest(x ~ g | b, data = xDF)

House Test

Description

Performs House nonparametric equivalent of William's testfor contrasting increasing dose levels of a treatment ina complete randomized block design.

Usage

frdHouseTest(y, ...)## Default S3 method:frdHouseTest(y, groups, blocks, alternative = c("greater", "less"), ...)

Arguments

y

a numeric vector of data values, or a list of numeric datavectors.

groups

a vector or factor object giving the group for thecorresponding elements of"x". Ignored with a warning if"x" is a list.

blocks

a vector or factor object giving the block for thecorresponding elements of"x".Ignored with a warning if"x" is a list.

alternative

the alternative hypothesis. Defaults togreater.

...

further arguments to be passed to or from methods.

Details

House test is a non-parametric step-down trend test for testing several treatment levelswith a zero control. Let there bek groups including the control and letthe zero dose level be indicated withi = 0 and the highestdose level withi = m, then the followingm = k - 1 hypotheses are tested:

\begin{array}{ll}\mathrm{H}_{m}: \theta_0 = \theta_1 = \ldots = \theta_m, & \mathrm{A}_{m} = \theta_0 \le \theta_1 \le \ldots \theta_m, \theta_0 < \theta_m \\\mathrm{H}_{m-1}: \theta_0 = \theta_1 = \ldots = \theta_{m-1}, & \mathrm{A}_{m-1} = \theta_0 \le \theta_1 \le \ldots \theta_{m-1}, \theta_0 < \theta_{m-1} \\\vdots & \vdots \\\mathrm{H}_{1}: \theta_0 = \theta_1, & \mathrm{A}_{1} = \theta_0 < \theta_1\\\end{array}

LetY_{ij} ~ (1 \leq i \leq n, 0 \leq j \leq k) be a i.i.d. random variableof at least ordinal scale. Further, let\bar{R}_0,~\bar{R}_1, \ldots,~\bar{R}_kbe Friedman's average ranks and set\bar{R}_0^*, \leq \ldots \leq \bar{R}_k^*to be its isotonic regression estimators under the order restriction\theta_0 \leq \ldots \leq \theta_k.

The statistics is

T_j = \left(\bar{R}_j^* - \bar{R}_0 \right)~ \left[ \left(V_j - H_j \right)\left(2 / n \right) \right]^{-1/2} \qquad (1 \leq j \leq k),

with

V_j = \left(j + 1\right) ~ \left(j + 2 \right) / 12

and

H_j = \left(t^3 - t \right) / \left(12 j n \right),

wheret is the number of tied ranks.

The criticalt'_{i,v,\alpha}-valuesas given in the tables of Williams (1972) for\alpha = 0.05 (one-sided)are looked up according to the degree of freedoms (v = \infty) and the order number of thedose level (j).

For the comparison of the first dose level(j = 1) with the control, the criticalz-value from the standard normal distribution is used (Normal).

Value

A list with class"PMCMR" containing the following components:

method

a character string indicating what type of test was performed.

data.name

a character string giving the name(s) of the data.

statistic

lower-triangle matrix of the estimatedquantiles of the pairwise test statistics.

p.value

lower-triangle matrix of the p-values for the pairwise tests.

alternative

a character string describing the alternative hypothesis.

p.adjust.method

a character string describing the method for p-valueadjustment.

model

a data frame of the input data.

dist

a string that denotes the test distribution.

References

Chen, Y.-I., 1999. Rank-Based Tests for Dose Finding inNonmonotonic Dose–Response Settings.Biometrics55, 1258–1262.doi:10.1111/j.0006-341X.1999.01258.x

House, D.E., 1986. A Nonparametric Version of Williams’ Test forRandomized Block Design.Biometrics42, 187–190.

See Also

friedmanTest,friedman.test,frdManyOneExactTest,frdManyOneDemsarTest

Examples

 ## Sachs, 1997, p. 675 ## Six persons (block) received six different diuretics ## (A to F, treatment). ## The responses are the Na-concentration (mval) ## in the urine measured 2 hours after each treatment. ## Assume A is the control. y <- matrix(c( 3.88, 5.64, 5.76, 4.25, 5.91, 4.33, 30.58, 30.14, 16.92, 23.19, 26.74, 10.91, 25.24, 33.52, 25.45, 18.85, 20.45, 26.67, 4.44, 7.94, 4.04, 4.4, 4.23, 4.36, 29.41, 30.72, 32.92, 28.23, 23.35, 12, 38.87, 33.12, 39.15, 28.06, 38.23, 26.65),nrow=6, ncol=6, dimnames=list(1:6, LETTERS[1:6])) ## Global Friedman test friedmanTest(y) ## Demsar's many-one test summary(frdManyOneDemsarTest(y=y, p.adjust = "bonferroni",                      alternative = "greater")) ## Exact many-one test summary(frdManyOneExactTest(y=y, p.adjust = "bonferroni",                     alternative = "greater")) ## Nemenyi's many-one test summary(frdManyOneNemenyiTest(y=y, alternative = "greater")) ## House test frdHouseTest(y, alternative = "greater")

Demsar's Many-to-One Testfor Unreplicated Blocked Data

Description

Performs Demsar's non-parametric many-to-one comparison testfor Friedman-type ranked data.

Usage

frdManyOneDemsarTest(y, ...)## Default S3 method:frdManyOneDemsarTest(  y,  groups,  blocks,  alternative = c("two.sided", "greater", "less"),  p.adjust.method = p.adjust.methods,  ...)

Arguments

y

a numeric vector of data values, or a list of numeric datavectors.

groups

a vector or factor object giving the group for thecorresponding elements of"x". Ignored with a warning if"x" is a list.

blocks

a vector or factor object giving the block for thecorresponding elements of"x".Ignored with a warning if"x" is a list.

alternative

the alternative hypothesis. Defaults totwo.sided.

p.adjust.method

method for adjusting p values(seep.adjust).

...

further arguments to be passed to or from methods.

Details

For many-to-one comparisons (pairwise comparisons with one control)in a two factorial unreplicated complete block designwith non-normally distributed residuals, Demsar's test can beperformed on Friedman-type ranked data.

Let there bek groups including the control,then the number of treatment levels ism = k - 1.A total ofm pairwise comparisons can be performed betweenthei-th treatment level and the control.H_i: \theta_0 = \theta_i is tested in the two-tailed case againstA_i: \theta_0 \ne \theta_i, ~~ (1 \le i \le m).

Thep-values are computed from the standard normal distribution.Any of thep-adjustment methods as included inp.adjustcan be used for the adjustment ofp-values.

Value

A list with class"PMCMR" containing the following components:

method

a character string indicating what type of test was performed.

data.name

a character string giving the name(s) of the data.

statistic

lower-triangle matrix of the estimatedquantiles of the pairwise test statistics.

p.value

lower-triangle matrix of the p-values for the pairwise tests.

alternative

a character string describing the alternative hypothesis.

p.adjust.method

a character string describing the method for p-valueadjustment.

model

a data frame of the input data.

dist

a string that denotes the test distribution.

References

Demsar, J. (2006) Statistical comparisons of classifiers over multipledata sets,Journal of Machine Learning Research7, 1–30.

See Also

friedmanTest,friedman.test,frdManyOneExactTest,frdManyOneNemenyiTest.

Examples

 ## Sachs, 1997, p. 675 ## Six persons (block) received six different diuretics ## (A to F, treatment). ## The responses are the Na-concentration (mval) ## in the urine measured 2 hours after each treatment. ## Assume A is the control. y <- matrix(c( 3.88, 5.64, 5.76, 4.25, 5.91, 4.33, 30.58, 30.14, 16.92, 23.19, 26.74, 10.91, 25.24, 33.52, 25.45, 18.85, 20.45, 26.67, 4.44, 7.94, 4.04, 4.4, 4.23, 4.36, 29.41, 30.72, 32.92, 28.23, 23.35, 12, 38.87, 33.12, 39.15, 28.06, 38.23, 26.65),nrow=6, ncol=6, dimnames=list(1:6, LETTERS[1:6])) ## Global Friedman test friedmanTest(y) ## Demsar's many-one test summary(frdManyOneDemsarTest(y=y, p.adjust = "bonferroni",                      alternative = "greater")) ## Exact many-one test summary(frdManyOneExactTest(y=y, p.adjust = "bonferroni",                     alternative = "greater")) ## Nemenyi's many-one test summary(frdManyOneNemenyiTest(y=y, alternative = "greater")) ## House test frdHouseTest(y, alternative = "greater")

Exact Many-to-One Testfor Unreplicated Blocked Data

Description

Performs an exact non-parametric many-to-one comparison testfor Friedman-type ranked data according to Eisinga et al. (2017).

Usage

frdManyOneExactTest(y, ...)## Default S3 method:frdManyOneExactTest(y, groups, blocks, p.adjust.method = p.adjust.methods, ...)

Arguments

y

a numeric vector of data values, or a list of numeric datavectors.

groups

a vector or factor object giving the group for thecorresponding elements of"x". Ignored with a warning if"x" is a list.

blocks

a vector or factor object giving the block for thecorresponding elements of"x".Ignored with a warning if"x" is a list.

p.adjust.method

method for adjusting p values(seep.adjust).

...

further arguments to be passed to or from methods.

Details

For many-to-one comparisons (pairwise comparisons with one control)in a two factorial unreplicated complete block designwith non-normally distributed residuals, an exact test can beperformed on Friedman-type ranked data.

Let there bek groups including the control,then the number of treatment levels ism = k - 1.A total ofm pairwise comparisons can be performed betweenthei-th treatment level and the control.H_i: \theta_0 = \theta_i is tested in the two-tailed case againstA_i: \theta_0 \ne \theta_i, ~~ (1 \le i \le m).

The exactp-valuesare computed using the code of"pexactfrsd.R"that was a supplement to the publication of Eisinga et al. (2017).Additionally, any of thep-adjustment methodsas included inp.adjust can be selected, forp-valueadjustment.

Value

A list with class"PMCMR" containing the following components:

method

a character string indicating what type of test was performed.

data.name

a character string giving the name(s) of the data.

statistic

lower-triangle matrix of the estimatedquantiles of the pairwise test statistics.

p.value

lower-triangle matrix of the p-values for the pairwise tests.

alternative

a character string describing the alternative hypothesis.

p.adjust.method

a character string describing the method for p-valueadjustment.

model

a data frame of the input data.

dist

a string that denotes the test distribution.

References

Eisinga, R., Heskes, T., Pelzer, B., Te Grotenhuis, M. (2017)Exact p-values for Pairwise Comparison of Friedman Rank Sums,with Application to Comparing Classifiers,BMC Bioinformatics, 18:68.

See Also

friedmanTest,friedman.test,frdManyOneDemsarTest,frdManyOneNemenyiTest.

Examples

 ## Sachs, 1997, p. 675 ## Six persons (block) received six different diuretics ## (A to F, treatment). ## The responses are the Na-concentration (mval) ## in the urine measured 2 hours after each treatment. ## Assume A is the control. y <- matrix(c( 3.88, 5.64, 5.76, 4.25, 5.91, 4.33, 30.58, 30.14, 16.92, 23.19, 26.74, 10.91, 25.24, 33.52, 25.45, 18.85, 20.45, 26.67, 4.44, 7.94, 4.04, 4.4, 4.23, 4.36, 29.41, 30.72, 32.92, 28.23, 23.35, 12, 38.87, 33.12, 39.15, 28.06, 38.23, 26.65),nrow=6, ncol=6, dimnames=list(1:6, LETTERS[1:6])) ## Global Friedman test friedmanTest(y) ## Demsar's many-one test summary(frdManyOneDemsarTest(y=y, p.adjust = "bonferroni",                      alternative = "greater")) ## Exact many-one test summary(frdManyOneExactTest(y=y, p.adjust = "bonferroni",                     alternative = "greater")) ## Nemenyi's many-one test summary(frdManyOneNemenyiTest(y=y, alternative = "greater")) ## House test frdHouseTest(y, alternative = "greater")

Nemenyi's Many-to-One Testfor Unreplicated Blocked Data

Description

Performs Nemenyi's non-parametric many-to-one comparison testfor Friedman-type ranked data.

Usage

frdManyOneNemenyiTest(y, ...)## Default S3 method:frdManyOneNemenyiTest(  y,  groups,  blocks,  alternative = c("two.sided", "greater", "less"),  ...)

Arguments

y

a numeric vector of data values, or a list of numeric datavectors.

groups

a vector or factor object giving the group for thecorresponding elements of"x". Ignored with a warning if"x" is a list.

blocks

a vector or factor object giving the block for thecorresponding elements of"x".Ignored with a warning if"x" is a list.

alternative

the alternative hypothesis. Defaults totwo.sided.

...

further arguments to be passed to or from methods.

Details

For many-to-one comparisons (pairwise comparisons with one control)in a two factorial unreplicated complete block designwith non-normally distributed residuals, Nemenyi's test can beperformed on Friedman-type ranked data.

Let there bek groups including the control,then the number of treatment levels ism = k - 1.A total ofm pairwise comparisons can be performed betweenthei-th treatment level and the control.H_i: \theta_0 = \theta_i is tested in the two-tailed case againstA_i: \theta_0 \ne \theta_i, ~~ (1 \le i \le m).

Thep-values are computed from the multivariate normal distribution.Aspmvnorm applies a numerical method, the estimatedp-values are seet depended.

Value

A list with class"PMCMR" containing the following components:

method

a character string indicating what type of test was performed.

data.name

a character string giving the name(s) of the data.

statistic

lower-triangle matrix of the estimatedquantiles of the pairwise test statistics.

p.value

lower-triangle matrix of the p-values for the pairwise tests.

alternative

a character string describing the alternative hypothesis.

p.adjust.method

a character string describing the method for p-valueadjustment.

model

a data frame of the input data.

dist

a string that denotes the test distribution.

References

Hollander, M., Wolfe, D. A., Chicken, E. (2014),Nonparametric Statistical Methods. 3rd ed. New York: Wiley. 2014.

Miller Jr., R. G. (1996),Simultaneous Statistical Inference.New York: McGraw-Hill.

Nemenyi, P. (1963),Distribution-free Multiple Comparisons.Ph.D. thesis, Princeton University.

Siegel, S., Castellan Jr., N. J. (1988),NonparametricStatistics for the Behavioral Sciences. 2nd ed.New York: McGraw-Hill.

Zarr, J. H. (1999),Biostatistical Analysis. 4th ed.Upper Saddle River: Prentice-Hall.

See Also

friedmanTest,friedman.test,frdManyOneExactTest,frdManyOneDemsarTestpmvnorm,set.seed

Examples

 ## Sachs, 1997, p. 675 ## Six persons (block) received six different diuretics ## (A to F, treatment). ## The responses are the Na-concentration (mval) ## in the urine measured 2 hours after each treatment. ## Assume A is the control. y <- matrix(c( 3.88, 5.64, 5.76, 4.25, 5.91, 4.33, 30.58, 30.14, 16.92, 23.19, 26.74, 10.91, 25.24, 33.52, 25.45, 18.85, 20.45, 26.67, 4.44, 7.94, 4.04, 4.4, 4.23, 4.36, 29.41, 30.72, 32.92, 28.23, 23.35, 12, 38.87, 33.12, 39.15, 28.06, 38.23, 26.65),nrow=6, ncol=6, dimnames=list(1:6, LETTERS[1:6])) ## Global Friedman test friedmanTest(y) ## Demsar's many-one test summary(frdManyOneDemsarTest(y=y, p.adjust = "bonferroni",                      alternative = "greater")) ## Exact many-one test summary(frdManyOneExactTest(y=y, p.adjust = "bonferroni",                     alternative = "greater")) ## Nemenyi's many-one test summary(frdManyOneNemenyiTest(y=y, alternative = "greater")) ## House test frdHouseTest(y, alternative = "greater")

Friedman Rank Sum Test

Description

Performs a Friedman rank sum test. The null hypothesisH_0: \theta_i = \theta_j~~(i \ne j) is tested against thealternative H_{\mathrm{A}}: \theta_i \ne \theta_j, with at leastone inequality beeing strict.

Usage

friedmanTest(y, ...)## Default S3 method:friedmanTest(y, groups, blocks, dist = c("Chisquare", "FDist"), ...)

Arguments

y

a numeric vector of data values, or a list of numeric datavectors.

groups

a vector or factor object giving the group for thecorresponding elements of"x". Ignored with a warning if"x" is a list.

blocks

a vector or factor object giving the block for thecorresponding elements of"x".Ignored with a warning if"x" is a list.

dist

the test distribution. Defaults toChisquare.

...

further arguments to be passed to or from methods.

Details

The function has implemented Friedman's test as well asthe extension of Conover anf Iman (1981). Friedman'stest statistic is assymptotically chi-squared distributed.Consequently, the default test distribution isdist = "Chisquare".

Ifdist = "FDist" is selected, than the approach ofConover and Imam (1981) is performed.The Friedman Test using theF-distribution leads tothe same results as doing an two-way Analysis of Variance withoutinteraction on rank transformed data.

Value

A list with class"htest" containing the following components:

method

a character string indicating what type of test was performed.

data.name

a character string giving the name(s) of the data.

statistic

the estimated quantile of the test statistic.

p.value

the p-value for the test.

parameter

the parameters of the test statistic, if any.

alternative

a character string describing the alternative hypothesis.

estimates

the estimates, if any.

null.value

the estimate under the null hypothesis, if any.

References

Conover, W.J., Iman, R.L. (1981) Rank Transformations as a BridgeBetween Parametric and Nonparametric Statistics.Am Stat35, 124–129.

Sachs, L. (1997)Angewandte Statistik. Berlin: Springer.

See Also

friedman.test

Examples

## Hollander & Wolfe (1973), p. 140ff.## Comparison of three methods ("round out", "narrow angle", and##  "wide angle") for rounding first base.  For each of 18 players##  and the three method, the average time of two runs from a point on##  the first base line 35ft from home plate to a point 15ft short of##  second base is recorded.RoundingTimes <-matrix(c(5.40, 5.50, 5.55,        5.85, 5.70, 5.75,        5.20, 5.60, 5.50,        5.55, 5.50, 5.40,        5.90, 5.85, 5.70,        5.45, 5.55, 5.60,        5.40, 5.40, 5.35,        5.45, 5.50, 5.35,        5.25, 5.15, 5.00,        5.85, 5.80, 5.70,        5.25, 5.20, 5.10,        5.65, 5.55, 5.45,        5.60, 5.35, 5.45,        5.05, 5.00, 4.95,        5.50, 5.50, 5.40,        5.45, 5.55, 5.50,        5.55, 5.55, 5.35,        5.45, 5.50, 5.55,        5.50, 5.45, 5.25,        5.65, 5.60, 5.40,        5.70, 5.65, 5.55,        6.30, 6.30, 6.25),      nrow = 22,      byrow = TRUE,      dimnames = list(1 : 22,                      c("Round Out", "Narrow Angle", "Wide Angle")))## Chisquare distributionfriedmanTest(RoundingTimes)## check with friedman.test from R statsfriedman.test(RoundingTimes)## F-distributionfriedmanTest(RoundingTimes, dist = "FDist")## Check with One-way repeated measure ANOVArmat <- RoundingTimesfor (i in 1:length(RoundingTimes[,1])) rmat[i,] <- rank(rmat[i,])dataf <- data.frame(    y = y <- as.vector(rmat),    g = g <- factor(c(col(RoundingTimes))),    b = b <- factor(c(row(RoundingTimes))))summary(aov(y ~ g + Error(b), data = dataf))

Games-Howell Test

Description

Performs Games-Howell all-pairs comparison test for normally distributeddata with unequal group variances.

Usage

gamesHowellTest(x, ...)## Default S3 method:gamesHowellTest(x, g, ...)## S3 method for class 'formula'gamesHowellTest(formula, data, subset, na.action, ...)## S3 method for class 'aov'gamesHowellTest(x, ...)

Arguments

x

a numeric vector of data values, a list of numeric datavectors or a fitted model object, usually anaov fit.

...

further arguments to be passed to or from methods.

g

a vector or factor object giving the group for thecorresponding elements of"x".Ignored with a warning if"x" is a list.

formula

a formula of the formresponse ~ group whereresponse gives the data values andgroup a vector orfactor of the corresponding groups.

data

an optional matrix or data frame (or similar: seemodel.frame) containing the variables in theformulaformula. By default the variables are taken fromenvironment(formula).

subset

an optional vector specifying asubset of observations to be used.

na.action

a function which indicates what should happen whenthe data containNAs. Defaults togetOption("na.action").

Details

For all-pairs comparisons in an one-factorial layoutwith normally distributed residuals but unequal between-groups variancesthe Games-Howell Test can be performed. LetX_{ij} denote a continuous random variablewith thej-the realization (1 \le j \le n_i)in thei-th group (1 \le i \le k). Furthermore, the totalsample size isN = \sum_{i=1}^k n_i. A total ofm = k(k-1)/2hypotheses can be tested: The null hypothesis isH_{ij}: \mu_i = \mu_j ~~ (i \ne j) is tested against the alternativeA_{ij}: \mu_i \ne \mu_j (two-tailed). Games-Howell Test all-pairstest statistics are given by

t_{ij} \frac{\bar{X}_i - \bar{X_j}} {\left( s^2_j / n_j + s^2_i / n_i \right)^{1/2}}, ~~ (i \ne j)

withs^2_i the variance of thei-th group.The null hypothesis is rejected (two-tailed) if

\mathrm{Pr} \left\{ |t_{ij}| \sqrt{2} \ge q_{m v_{ij} \alpha} | \mathrm{H} \right\}_{ij} = \alpha,

with Welch's approximate solution for calculating the degree of freedom.

v_{ij} = \frac{\left( s^2_i / n_i + s^2_j / n_j \right)^2} {s^4_i / n^2_i \left(n_i - 1\right) + s^4_j / n^2_j \left(n_j - 1\right)}.

Thep-values are computed from theTukey distribution.

Value

A list with class"PMCMR" containing the following components:

method

a character string indicating what type of test was performed.

data.name

a character string giving the name(s) of the data.

statistic

lower-triangle matrix of the estimatedquantiles of the pairwise test statistics.

p.value

lower-triangle matrix of the p-values for the pairwise tests.

alternative

a character string describing the alternative hypothesis.

p.adjust.method

a character string describing the method for p-valueadjustment.

model

a data frame of the input data.

dist

a string that denotes the test distribution.

See Also

Tukey

Examples

fit <- aov(weight ~ feed, chickwts)shapiro.test(residuals(fit))bartlett.test(weight ~ feed, chickwts) # var1 = varNanova(fit)## also works with fitted objects of class aovres <- gamesHowellTest(fit)summary(res)summaryGroup(res)

Generalized Extreme Studentized Deviate Many-Outlier Test

Description

Performs Rosner's generalized extreme studentized deviateprocedure to detect up-tomaxr outliers in aunivariate sample that follows an approximately normal distribution.

Usage

gesdTest(x, maxr)

Arguments

x

a numeric vector of data.

maxr

the maximum number of outliers to be tested.

References

Rosner, B. (1983) Percentage Points for a Generalized ESDMany-Outlier Procedure,Technometrics25, 165–172.

Examples

## Taken from Rosner (1983):x <- c(-0.25,0.68,0.94,1.15,1.20,1.26,1.26,1.34,1.38,1.43,1.49,1.49,1.55,1.56,1.58,1.65,1.69,1.70,1.76,1.77,1.81,1.91,1.94,1.96,1.99,2.06,2.09,2.10,2.14,2.15,2.23,2.24,2.26,2.35,2.37,2.40,2.47,2.54,2.62,2.64,2.90,2.92,2.92,2.93,3.21,3.26,3.30,3.59,3.68,4.30,4.64,5.34,5.42,6.01)out <- gesdTest(x, 10)## print methodout## summary methodsummary(out)

Gore Test

Description

Performs Gore's test. The null hypothesisH_0: \theta_i = \theta_j~~(i \ne j) is tested against thealternative H_{\mathrm{A}}: \theta_i \ne \theta_j, with at leastone inequality beeing strict.

Usage

goreTest(y, groups, blocks)

Arguments

y

a numeric vector of data values.

groups

a vector or factor object giving the group for thecorresponding elements of"y".

blocks

a vector or factor object giving the group for thecorresponding elements of"y".

Details

The function has implemented Gore's test for testingmain effects in unbalanced CRB designs,i.e. there are one ore more observations per cell.The statistic is assymptotically chi-squared distributed.

Value

A list with class"htest" containing the following components:

method

a character string indicating what type of test was performed.

data.name

a character string giving the name(s) of the data.

statistic

the estimated quantile of the test statistic.

p.value

the p-value for the test.

parameter

the parameters of the test statistic, if any.

alternative

a character string describing the alternative hypothesis.

estimates

the estimates, if any.

null.value

the estimate under the null hypothesis, if any.

References

Gore, A. P. (1975) Some nonparametric tests and selectionprocedures for main effects in two-way layouts.Ann. Inst. Stat. Math.27, 487–500.

See Also

friedmanTest,skillingsMackTest,durbinTest

Examples

## Crop Yield of 3 varieties on two## soil classesX <-c("130,A,Light115,A,Light123,A,Light142,A,Light117,A,Heavy125,A,Heavy139,A,Heavy108,B,Light114,B,Light124,B,Light106,B,Light91,B,Heavy111,B,Heavy110,B,Heavy155,C,Light146,C,Light151,C,Light165,C,Light97,C,Heavy108,C,Heavy")con <- textConnection(X)x <- read.table(con, header=FALSE, sep=",")close(con)colnames(x) <- c("Yield", "Variety", "SoilType")goreTest(y = x$Yield, groups = x$Variety, blocks = x$SoilType)

Grubbs Outlier Test

Description

Performs Grubbs single outlier test.

Usage

grubbsTest(x, alternative = c("two.sided", "greater", "less"))

Arguments

x

a numeric vector of data.

alternative

the alternative hypothesis.Defaults to"two.sided".

Details

LetX denote an identically and independently distributed continuousvariate with realizationsx_i ~~ (1 \le i \le k).Further, let the increasingly ordered realizationsdenotex_{(1)} \le x_{(2)} \le \ldots \le x_{(n)}. Thenthe following model for a single maximum outlier can be proposed:

x_{(i)} = \left\{ \begin{array}{lcl} \mu + \epsilon_{(i)}, & \qquad & i = 1, \ldots, n - 1 \\ \mu + \Delta + \epsilon_{(n)} & & \\ \end{array} \right.

with\epsilon \approx N(0,\sigma). The null hypothesis,H_0: \Delta = 0 is tested against the alternative,H_{\mathrm{A}}: \Delta > 0.

For testing a single minimum outlier, the model can be proposedas

x_{(i)} = \left\{ \begin{array}{lcl} \mu + \Delta + \epsilon_{(1)} & & \\ \mu + \epsilon_{(i)}, & \qquad & i = 2, \ldots, n \\ \end{array} \right.

The null hypothesis is tested against the alternative,H_{\mathrm{A}}: \Delta < 0.

The p-value is computed with the functionpgrubbs.

Value

A list with class"htest" containing the following components:

method

a character string indicating what type of test was performed.

data.name

a character string giving the name(s) of the data.

statistic

the estimated quantile of the test statistic.

p.value

the p-value for the test.

parameter

the parameters of the test statistic, if any.

alternative

a character string describing the alternative hypothesis.

estimates

the estimates, if any.

null.value

the estimate under the null hypothesis, if any.

References

Grubbs, F. E. (1950) Sample criteria for testing outlying observations.Ann. Math. Stat.21, 27–58.

Wilrich, P.-T. (2011) Critical values of Mandel's h and k,Grubbs and the Cochran test statistic.Adv. Stat. Anal..doi:10.1007/s10182-011-0185-y.

Examples

data(Pentosan)dat <- subset(Pentosan, subset = (material == "A"))labMeans <- tapply(dat$value, dat$lab, mean)grubbsTest(x = labMeans, alternative = "two.sided")

Hartley's Maximum F-Ratio Test of Homogeneity ofVariances

Description

Performs Hartley's maximum F-ratio test of the null thatvariances in each of the groups (samples) are the same.

Usage

hartleyTest(x, ...)## Default S3 method:hartleyTest(x, g, ...)## S3 method for class 'formula'hartleyTest(formula, data, subset, na.action, ...)

Arguments

x

a numeric vector of data values, or a list of numeric datavectors.

...

further arguments to be passed to or from methods.

g

a vector or factor object giving the group for thecorresponding elements of"x".Ignored with a warning if"x" is a list.

formula

a formula of the formresponse ~ group whereresponse gives the data values andgroup a vector orfactor of the corresponding groups.

data

an optional matrix or data frame (or similar: seemodel.frame) containing the variables in theformulaformula. By default the variables are taken fromenvironment(formula).

subset

an optional vector specifying asubset of observations to be used.

na.action

a function which indicates what should happen whenthe data containNAs. Defaults togetOption("na.action").

Details

Ifx is a list, its elements are taken as the samplesto be compared for homogeneity of variances. In thiscase, the elements must all be numeric data vectors,g is ignored, and one can simply usehartleyTest(x) to perform the test. If the samples are notyet contained in a list, usehartleyTest(list(x, ...)).

Otherwise,x must be a numeric data vector, andg mustbe a vector or factor object of the same length asx giving thegroup for the corresponding elements ofx.

Hartley's parametric test requires normality anda nearly balanced design. The p-value of the testis calculated with the functionpmaxFratioof the packageSuppDists.

Value

A list with class"htest" containing the following components:

method

a character string indicating what type of test was performed.

data.name

a character string giving the name(s) of the data.

statistic

the estimated quantile of the test statistic.

p.value

the p-value for the test.

parameter

the parameters of the test statistic, if any.

alternative

a character string describing the alternative hypothesis.

estimates

the estimates, if any.

null.value

the estimate under the null hypothesis, if any.

References

Hartley, H.O. (1950) The maximum F-ratioas a short cut test for heterogeneity of variance,Biometrika37, 308–312.

See Also

bartlett.test,pmaxFratio

Examples

hartleyTest(count ~ spray, data = InsectSprays)

Hayter-Stone Test

Description

Performs the non-parametric Hayter-Stone procedureto test against an monotonically increasing alternative.

Usage

hayterStoneTest(x, ...)## Default S3 method:hayterStoneTest(  x,  g,  alternative = c("greater", "less"),  method = c("look-up", "boot", "asympt"),  nperm = 10000,  ...)## S3 method for class 'formula'hayterStoneTest(  formula,  data,  subset,  na.action,  alternative = c("greater", "less"),  method = c("look-up", "boot", "asympt"),  nperm = 10000,  ...)

Arguments

x

a numeric vector of data values, or a list of numeric datavectors.

...

further arguments to be passed to or from methods.

g

a vector or factor object giving the group for thecorresponding elements of"x".Ignored with a warning if"x" is a list.

alternative

the alternative hypothesis. Defaults togreater.

method

a character string specifying the test statistic to use.Defaults to"look-up" that uses published Table values.

nperm

number of permutations for the asymptotic permutation test.Defaults to1000. Ignored, ifmethod = "look-up".

formula

a formula of the formresponse ~ group whereresponse gives the data values andgroup a vector orfactor of the corresponding groups.

data

an optional matrix or data frame (or similar: seemodel.frame) containing the variables in theformulaformula. By default the variables are taken fromenvironment(formula).

subset

an optional vector specifying asubset of observations to be used.

na.action

a function which indicates what should happen whenthe data containNAs. Defaults togetOption("na.action").

Details

LetX be an identically and idepentendly distributed variablethat wasn times observed atk increasing treatment levels.Hayter and Stone (1991) proposed a non-parametric procedureto test the null hypothesis, H:\theta_i = \theta_j ~~ (i < j \le k)against a simple order alternative, A:\theta_i < \theta_j, with at leastone inequality being strict.

The statistic for a global test is calculated as,

h = \max_{1 \le i < j \le k} \frac{2 \sqrt{6} \left(U_{ij} - n_i n_j / 2 \right)} {\sqrt{n_i n_j \left(n_i + n_j + 1 \right)}},

with the Mann-Whittney counts:

U_{ij} = \sum_{a=1}^{n_i} \sum_{b=1}^{n_j} I\left\{x_{ia} < x_{ja}\right\}.

Under the large sample approximation, the test statistich is distributedash_{k,\alpha,v}. Thus, the null hypothesis is rejected, ifh > h_{k,\alpha,v}, withv = \inftydegree of freedom.

Ifmethod = "look-up" the function will not returnp-values. Instead the critical h-valuesas given in the tables of Hayter (1990) for\alpha = 0.05 (one-sided)are looked up according to the number of groups (k) andthe degree of freedoms (v = \infty).

Ifmethod = "boot" an asymptotic permutation testis conducted and ap-value is returned.

Ifmethod = "asympt" is selected the asymptoticp-value is estimated as implemented in thefunctionpHayStonLSA of the packageNSM3.

Value

Either a list of classhtest or alist with class"osrt" that contains the followingcomponents:

method

a character string indicating what type of test was performed.

data.name

a character string giving the name(s) of the data.

statistic

the estimated statistic(s)

crit.value

critical values for\alpha = 0.05.

alternative

a character string describing the alternative hypothesis.

parameter

the parameter(s) of the test distribution.

dist

a string that denotes the test distribution.

There are print and summary methods available.

Source

Ifmethod = "asympt" is selected, this function callsan internal probability functionpHS. The GPL-2 code forthis function was taken frompHayStonLSA of thethe packageNSM3:

Grant Schneider, Eric Chicken and Rachel Becvarik (2020) NSM3:Functions and Datasets to Accompany Hollander, Wolfe, andChicken - Nonparametric Statistical Methods, Third Edition. Rpackage version 1.15.https://CRAN.R-project.org/package=NSM3

References

Hayter, A. J.(1990) A One-Sided Studentised RangeTest for Testing Against a Simple Ordered Alternative,J Amer Stat Assoc85, 778–785.

Hayter, A.J., Stone, G. (1991)Distribution free multiple comparisons for monotonically ordered treatment effects.Austral J Statist33, 335–346.

See Also

osrtTest,hsAllPairsTest,sample,pHayStonLSA

Examples

## Example from Shirley (1977)## Reaction times of mice to stimuli to their tails.x <- c(2.4, 3, 3, 2.2, 2.2, 2.2, 2.2, 2.8, 2, 3, 2.8, 2.2, 3.8, 9.4, 8.4, 3, 3.2, 4.4, 3.2, 7.4, 9.8, 3.2, 5.8, 7.8, 2.6, 2.2, 6.2, 9.4, 7.8, 3.4, 7, 9.8, 9.4, 8.8, 8.8, 3.4, 9, 8.4, 2.4, 7.8)g <- gl(4, 10)## Shirley's test## one-sided test using look-up tableshirleyWilliamsTest(x ~ g, alternative = "greater")## Chacko's global hypothesis test for 'greater'chackoTest(x , g)## post-hoc test, default is standard normal distribution (NPT'-test)summary(chaAllPairsNashimotoTest(x, g, p.adjust.method = "none"))## same but h-distribution (NPY'-test)chaAllPairsNashimotoTest(x, g, dist = "h")## NPM-testNPMTest(x, g)## Hayter-Stone testhayterStoneTest(x, g)## all-pairs comparisonshsAllPairsTest(x, g)

Hayter-Stone All-Pairs Comparison Test

Description

Performs the non-parametric Hayter-Stone all-pairs procedureto test against monotonically increasing alternatives.

Usage

hsAllPairsTest(x, ...)## Default S3 method:hsAllPairsTest(  x,  g,  alternative = c("greater", "less"),  method = c("look-up", "boot", "asympt"),  nperm = 10000,  ...)## S3 method for class 'formula'hsAllPairsTest(  formula,  data,  subset,  na.action,  alternative = c("greater", "less"),  method = c("look-up", "boot", "asympt"),  nperm = 10000,  ...)

Arguments

x

a numeric vector of data values, or a list of numeric datavectors.

...

further arguments to be passed to or from methods.

g

a vector or factor object giving the group for thecorresponding elements of"x".Ignored with a warning if"x" is a list.

alternative

the alternative hypothesis. Defaults togreater.

method

a character string specifying the test statistic to use.Defaults to"look-up" that uses published Table values of Williams (1972).

nperm

number of permutations for the asymptotic permutation test.Defaults to1000. Ignored, ifmethod = "look-up".

formula

a formula of the formresponse ~ group whereresponse gives the data values andgroup a vector orfactor of the corresponding groups.

data

an optional matrix or data frame (or similar: seemodel.frame) containing the variables in theformulaformula. By default the variables are taken fromenvironment(formula).

subset

an optional vector specifying asubset of observations to be used.

na.action

a function which indicates what should happen whenthe data containNAs. Defaults togetOption("na.action").

Details

LetX be an identically and idepentendly distributed variablethat wasn times observed atk increasing treatment levels.Hayter and Stone (1991) proposed a non-parametric procedureto test the null hypothesis, H:\theta_i = \theta_j ~~ (i < j \le k)against a simple order alternative, A:\theta_i < \theta_j.

The statistic for all-pairs comparisons is calculated as,

S_{ij} = \frac{2 \sqrt{6} \left(U_{ij} - n_i n_j / 2 \right)} {\sqrt{n_i n_j \left(n_i + n_j + 1 \right)}},

with the Mann-Whittney counts:

U_{ij} = \sum_{a=1}^{n_i} \sum_{b=1}^{n_j} I\left\{x_{ia} < x_{ja}\right\}.

Under the large sample approximation, the test statisticS_{ij} is distributedash_{k,\alpha,v}. Thus, the null hypothesis is rejected,ifS_{ij} > h_{k,\alpha,v}, withv = \infty degree of freedom.

Ifmethod = "look-up" the function will not returnp-values. Instead the critical h-valuesas given in the tables of Hayter (1990) for\alpha = 0.05 (one-sided)are looked up according to the number of groups (k) andthe degree of freedoms (v = \infty).

Ifmethod = "boot" an asymetric permutation testis conducted andp-values are returned.

Ifmethod = "asympt" is selected the asymptoticp-value is estimated as implemented in thefunctionpHayStonLSA of the packageNSM3.

Value

Either a list of class"PMCMR" or alist with class"osrt" that contains the followingcomponents:

method

a character string indicating what type of test was performed.

data.name

a character string giving the name(s) of the data.

statistic

the estimated statistic(s)

crit.value

critical values for\alpha = 0.05.

alternative

a character string describing the alternative hypothesis.

parameter

the parameter(s) of the test distribution.

dist

a string that denotes the test distribution.

There are print and summary methods available.

A list with class"PMCMR" containing the following components:

method

a character string indicating what type of test was performed.

data.name

a character string giving the name(s) of the data.

statistic

lower-triangle matrix of the estimatedquantiles of the pairwise test statistics.

p.value

lower-triangle matrix of the p-values for the pairwise tests.

alternative

a character string describing the alternative hypothesis.

p.adjust.method

a character string describing the method for p-valueadjustment.

model

a data frame of the input data.

dist

a string that denotes the test distribution.

Source

Ifmethod = "asympt" is selected, this function callsan internal probability functionpHS. The GPL-2 code forthis function was taken frompHayStonLSA of thethe packageNSM3:

Grant Schneider, Eric Chicken and Rachel Becvarik (2020) NSM3:Functions and Datasets to Accompany Hollander, Wolfe, andChicken - Nonparametric Statistical Methods, Third Edition. Rpackage version 1.15.https://CRAN.R-project.org/package=NSM3

References

Hayter, A. J.(1990) A One-Sided Studentised RangeTest for Testing Against a Simple Ordered Alternative,Journal of the American Statistical Association85, 778–785.

Hayter, A.J., Stone, G. (1991)Distribution free multiple comparisons for monotonically ordered treatment effects.Austral J Statist33, 335–346.

See Also

hayterStoneTestsample

Examples

## Example from Shirley (1977)## Reaction times of mice to stimuli to their tails.x <- c(2.4, 3, 3, 2.2, 2.2, 2.2, 2.2, 2.8, 2, 3, 2.8, 2.2, 3.8, 9.4, 8.4, 3, 3.2, 4.4, 3.2, 7.4, 9.8, 3.2, 5.8, 7.8, 2.6, 2.2, 6.2, 9.4, 7.8, 3.4, 7, 9.8, 9.4, 8.8, 8.8, 3.4, 9, 8.4, 2.4, 7.8)g <- gl(4, 10)## Shirley's test## one-sided test using look-up tableshirleyWilliamsTest(x ~ g, alternative = "greater")## Chacko's global hypothesis test for 'greater'chackoTest(x , g)## post-hoc test, default is standard normal distribution (NPT'-test)summary(chaAllPairsNashimotoTest(x, g, p.adjust.method = "none"))## same but h-distribution (NPY'-test)chaAllPairsNashimotoTest(x, g, dist = "h")## NPM-testNPMTest(x, g)## Hayter-Stone testhayterStoneTest(x, g)## all-pairs comparisonshsAllPairsTest(x, g)

Testing against Ordered Alternatives (Johnson-Mehrotra Test)

Description

Performs the Johnson-Mehrotra test for testing against ordered alternativesin a balanced one-factorial sampling design.

Usage

johnsonTest(x, ...)## Default S3 method:johnsonTest(x, g, alternative = c("two.sided", "greater", "less"), ...)## S3 method for class 'formula'johnsonTest(  formula,  data,  subset,  na.action,  alternative = c("two.sided", "greater", "less"),  ...)

Arguments

x

a numeric vector of data values, or a list of numeric datavectors.

...

further arguments to be passed to or from methods.

g

a vector or factor object giving the group for thecorresponding elements of"x".Ignored with a warning if"x" is a list.

alternative

the alternative hypothesis. Defaults to"two.sided".

formula

a formula of the formresponse ~ group whereresponse gives the data values andgroup a vector orfactor of the corresponding groups.

data

an optional matrix or data frame (or similar: seemodel.frame) containing the variables in theformulaformula. By default the variables are taken fromenvironment(formula).

subset

an optional vector specifying asubset of observations to be used.

na.action

a function which indicates what should happen whenthe data containNAs. Defaults togetOption("na.action").

Details

The null hypothesis, H_0: \theta_1 = \theta_2 = \ldots = \theta_kis tested against a simple order hypothesis,H_\mathrm{A}: \theta_1 \le \theta_2 \le \ldots \le\theta_k,~\theta_1 < \theta_k.

The p-values are estimated from the standard normal distribution.

Value

A list with class"htest" containing the following components:

method

a character string indicating what type of test was performed.

data.name

a character string giving the name(s) of the data.

statistic

the estimated quantile of the test statistic.

p.value

the p-value for the test.

parameter

the parameters of the test statistic, if any.

alternative

a character string describing the alternative hypothesis.

estimates

the estimates, if any.

null.value

the estimate under the null hypothesis, if any.

Note

Factor labels forg must be assigned in such a way,that they can be increasingly ordered from zero-dosecontrol to the highest dose level, e.g. integers{0, 1, 2, ..., k} or letters {a, b, c, ...}.Otherwise the function may not select the correct valuesfor intended zero-dose control.

It is safer, to i) label the factor levels as given above,and to ii) sort the data according to increasing dose-levelsprior to call the function (seeorder,factor).

References

Bortz, J. (1993).Statistik für Sozialwissenschaftler (4th ed.).Berlin: Springer.

Johnson, R. A., Mehrotra, K. G. (1972) Some c-samplenonparametric tests for ordered alternatives.Journal of the Indian Statistical Association9, 8–23.

See Also

kruskalTest andshirleyWilliamsTestof the packagePMCMRplus,kruskal.test of the librarystats.

Examples

## Example from Sachs (1997, p. 402)x <- c(106, 114, 116, 127, 145,       110, 125, 143, 148, 151,       136, 139, 149, 160, 174)g <- gl(3,5)levels(g) <- c("A", "B", "C")## Chacko's testchackoTest(x, g)## Cuzick's testcuzickTest(x, g)## Johnson-Mehrotra testjohnsonTest(x, g)## Jonckheere-Terpstra testjonckheereTest(x, g)## Le's testleTest(x, g)## Spearman type testspearmanTest(x, g)## Murakami's BWS trend testbwsTrendTest(x, g)## Fligner-Wolfe testflignerWolfeTest(x, g)## Shan-Young-Kang testshanTest(x, g)

Testing against Ordered Alternatives (Jonckheere-Terpstra Test)

Description

Performs the Jonckheere-Terpstra test for testing against ordered alternatives.

Usage

jonckheereTest(x, ...)## Default S3 method:jonckheereTest(  x,  g,  alternative = c("two.sided", "greater", "less"),  continuity = FALSE,  ...)## S3 method for class 'formula'jonckheereTest(  formula,  data,  subset,  na.action,  alternative = c("two.sided", "greater", "less"),  continuity = FALSE,  ...)

Arguments

x

a numeric vector of data values, or a list of numeric datavectors.

...

further arguments to be passed to or from methods.

g

a vector or factor object giving the group for thecorresponding elements of"x".Ignored with a warning if"x" is a list.

alternative

the alternative hypothesis. Defaults to"two.sided".

continuity

logical indicator whether a continuity correctionshall be performed. Defaults toFALSE.

formula

a formula of the formresponse ~ group whereresponse gives the data values andgroup a vector orfactor of the corresponding groups.

data

an optional matrix or data frame (or similar: seemodel.frame) containing the variables in theformulaformula. By default the variables are taken fromenvironment(formula).

subset

an optional vector specifying asubset of observations to be used.

na.action

a function which indicates what should happen whenthe data containNAs. Defaults togetOption("na.action").

Details

The null hypothesis, H_0: \theta_1 = \theta_2 = \ldots = \theta_kis tested against a simple order hypothesis,H_\mathrm{A}: \theta_1 \le \theta_2 \le \ldots \le\theta_k,~\theta_1 < \theta_k.

The p-values are estimated from the standard normal distribution.

Value

A list with class"htest" containing the following components:

method

a character string indicating what type of test was performed.

data.name

a character string giving the name(s) of the data.

statistic

the estimated quantile of the test statistic.

p.value

the p-value for the test.

parameter

the parameters of the test statistic, if any.

alternative

a character string describing the alternative hypothesis.

estimates

the estimates, if any.

null.value

the estimate under the null hypothesis, if any.

Source

The code for the computation of the standard deviationfor the Jonckheere-Terpstra test in the presence of ties was taken from:

Kloke, J., McKean, J. (2016)npsm: Package for Nonparametric Statistical Methods using R.R package version 0.5.https://CRAN.R-project.org/package=npsm

Note

jonckheereTest(x, g, alternative = "two.sided", continuity = TRUE) isequivalent to

cor.test(x, as.numeric(g), method = "kendall", alternative = "two.sided", continuity = TRUE)

Factor labels forg must be assigned in such a way,that they can be increasingly ordered from zero-dosecontrol to the highest dose level, e.g. integers{0, 1, 2, ..., k} or letters {a, b, c, ...}.Otherwise the function may not select the correct valuesfor intended zero-dose control.

It is safer, to i) label the factor levels as given above,and to ii) sort the data according to increasing dose-levelsprior to call the function (seeorder,factor).

References

Jonckheere, A. R. (1954) A distribution-free k-sample testagainst ordered alternatives.Biometrica41, 133–145.

Kloke, J., McKean, J. W. (2015)Nonparametric statistical methods using R.Boca Raton, FL: Chapman & Hall/CRC.

See Also

kruskalTest andshirleyWilliamsTestof the packagePMCMRplus,kruskal.test of the librarystats.

Examples

## Example from Sachs (1997, p. 402)x <- c(106, 114, 116, 127, 145,       110, 125, 143, 148, 151,       136, 139, 149, 160, 174)g <- gl(3,5)levels(g) <- c("A", "B", "C")## Chacko's testchackoTest(x, g)## Cuzick's testcuzickTest(x, g)## Johnson-Mehrotra testjohnsonTest(x, g)## Jonckheere-Terpstra testjonckheereTest(x, g)## Le's testleTest(x, g)## Spearman type testspearmanTest(x, g)## Murakami's BWS trend testbwsTrendTest(x, g)## Fligner-Wolfe testflignerWolfeTest(x, g)## Shan-Young-Kang testshanTest(x, g)

Kruskal-Wallis Rank Sum Test

Description

Performs a Kruskal-Wallis rank sum test.

Usage

kruskalTest(x, ...)## Default S3 method:kruskalTest(x, g, dist = c("Chisquare", "KruskalWallis", "FDist"), ...)## S3 method for class 'formula'kruskalTest(  formula,  data,  subset,  na.action,  dist = c("Chisquare", "KruskalWallis", "FDist"),  ...)

Arguments

x

a numeric vector of data values, or a list of numeric datavectors.

...

further arguments to be passed to or from methods.

g

a vector or factor object giving the group for thecorresponding elements of"x".Ignored with a warning if"x" is a list.

dist

the test distribution. Defaults's to"Chisquare".

formula

a formula of the formresponse ~ group whereresponse gives the data values andgroup a vector orfactor of the corresponding groups.

data

an optional matrix or data frame (or similar: seemodel.frame) containing the variables in theformulaformula. By default the variables are taken fromenvironment(formula).

subset

an optional vector specifying asubset of observations to be used.

na.action

a function which indicates what should happen whenthe data containNAs. Defaults togetOption("na.action").

Details

For one-factorial designs with non-normally distributedresiduals the Kruskal-Wallis rank sum test can be performed to testthe H_0: F_1(x) = F_2(x) = \ldots = F_k(x) againstthe H_\mathrm{A}: F_i (x) \ne F_j(x)~ (i \ne j) with at leastone strict inequality.

LetR_{ij} be the joint rank ofX_{ij},withR_{(1)(1)} = 1, \ldots, R_{(n)(n)} = N, ~~ N = \sum_{i=1}^k n_i,The test statistic is calculated as

H = \sum_{i=1}^k n_i \left(\bar{R}_i - \bar{R}\right) / \sigma_R,

with the mean rank of thei-th group

\bar{R}_i = \sum_{j = 1}^{n_{i}} R_{ij} / n_i,

the expected value

\bar{R} = \left(N +1\right) / 2

and the expected variance as

\sigma_R^2 = N \left(N + 1\right) / 12.

In case of ties the statisticH is divided by\left(1 - \sum_{i=1}^r t_i^3 - t_i \right) / \left(N^3 - N\right)

According to Conover and Imam (1981), the statisticH is relatedto theF-quantile as

F = \frac{H / \left(k - 1\right)} {\left(N - 1 - H\right) / \left(N - k\right)}

which is equivalent to a one-way ANOVA F-test using rank transformed data(see examples).

The function provides three differentdist forp-value estimation:

Chisquare

p-values are computed from theChisquaredistribution withv = k - 1 degree of freedom.

KruskalWallis

p-values are computed from thepKruskalWallis of the packageSuppDists.

FDist

p-values are computed from theFDist distributionwithv_1 = k-1, ~ v_2 = N -k degree of freedom.

Value

A list with class"htest" containing the following components:

method

a character string indicating what type of test was performed.

data.name

a character string giving the name(s) of the data.

statistic

the estimated quantile of the test statistic.

p.value

the p-value for the test.

parameter

the parameters of the test statistic, if any.

alternative

a character string describing the alternative hypothesis.

estimates

the estimates, if any.

null.value

the estimate under the null hypothesis, if any.

References

Conover, W.J., Iman, R.L. (1981) Rank Transformations as a BridgeBetween Parametric and Nonparametric Statistics.Am Stat35, 124–129.

Kruskal, W.H., Wallis, W.A. (1952) Use of Ranks in One-Criterion Variance Analysis.J Am Stat Assoc47, 583–621.

Sachs, L. (1997)Angewandte Statistik. Berlin: Springer.

See Also

kruskal.test,pKruskalWallis,Chisquare,FDist

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 subjectsy <- c(3.8, 2.7, 4.0, 2.4)      # with obstructive airway diseasez <- c(2.8, 3.4, 3.7, 2.2, 2.0) # with asbestosisg <- 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-TestadKSampleTest(x ~ g, data = dat)## BWS-TestbwsKSampleTest(x ~ g, data = dat)## Kruskal-Test## Using incomplete beta approximationkruskalTest(x ~ g, dat, dist="KruskalWallis")## Using chisquare distributionkruskalTest(x ~ g, dat, dist="Chisquare")## Not run: ## Check with kruskal.test from R statskruskal.test(x ~ g, dat)## End(Not run)## Using Conover's FkruskalTest(x ~ g, dat, dist="FDist")## Not run: ## Check with aov on ranksanova(aov(rank(x) ~ g, dat))## Check with oneway.testoneway.test(rank(x) ~ g, dat, var.equal = TRUE)## End(Not run)## Median Test asymptoticmedianTest(x ~ g, dat)## Median Test with simulated p-valuesset.seed(112)medianTest(x ~ g, dat, simulate.p.value = TRUE)

Conover's All-Pairs Rank Comparison Test

Description

Performs Conover's non-parametric all-pairs comparison testfor Kruskal-type ranked data.

Usage

kwAllPairsConoverTest(x, ...)## Default S3 method:kwAllPairsConoverTest(  x,  g,  p.adjust.method = c("single-step", p.adjust.methods),  ...)## S3 method for class 'formula'kwAllPairsConoverTest(  formula,  data,  subset,  na.action,  p.adjust.method = c("single-step", p.adjust.methods),  ...)

Arguments

x

a numeric vector of data values, or a list of numeric datavectors.

...

further arguments to be passed to or from methods.

g

a vector or factor object giving the group for thecorresponding elements of"x".Ignored with a warning if"x" is a list.

p.adjust.method

method for adjusting p values(seep.adjust).

formula

a formula of the formresponse ~ group whereresponse gives the data values andgroup a vector orfactor of the corresponding groups.

data

an optional matrix or data frame (or similar: seemodel.frame) containing the variables in theformulaformula. By default the variables are taken fromenvironment(formula).

subset

an optional vector specifying asubset of observations to be used.

na.action

a function which indicates what should happen whenthe data containNAs. Defaults togetOption("na.action").

Details

For all-pairs comparisons in an one-factorial layoutwith non-normally distributed residuals Conover's non-parametric testcan be performed. A total ofm = k(k-1)/2hypotheses can be tested. The null hypothesisH_{ij}: \mu_i(x) = \mu_j(x) is tested in the two-tailed testagainst the alternativeA_{ij}: \mu_i(x) \ne \mu_j(x), ~~ i \ne j.

Ifp.adjust.method == "single-step" the p-values are computedfrom the studentized range distribution. Otherwise,the p-values are computed from the t-distribution usingany of the p-adjustment methods as included inp.adjust.

Value

A list with class"PMCMR" containing the following components:

method

a character string indicating what type of test was performed.

data.name

a character string giving the name(s) of the data.

statistic

lower-triangle matrix of the estimatedquantiles of the pairwise test statistics.

p.value

lower-triangle matrix of the p-values for the pairwise tests.

alternative

a character string describing the alternative hypothesis.

p.adjust.method

a character string describing the method for p-valueadjustment.

model

a data frame of the input data.

dist

a string that denotes the test distribution.

References

Conover, W. J, Iman, R. L. (1979)On multiple-comparisonsprocedures, Tech. Rep. LA-7677-MS, Los Alamos Scientific Laboratory.

See Also

Tukey,TDist,p.adjust,kruskalTest,kwAllPairsDunnTest,kwAllPairsNemenyiTest

Examples

## Data set InsectSprays## Global testkruskalTest(count ~ spray, data = InsectSprays)## Conover's all-pairs comparison test## single-step means Tukey's p-adjustmentans <- kwAllPairsConoverTest(count ~ spray, data = InsectSprays,                             p.adjust.method = "single-step")summary(ans)## Dunn's all-pairs comparison testans <- kwAllPairsDunnTest(count ~ spray, data = InsectSprays,                             p.adjust.method = "bonferroni")summary(ans)## Nemenyi's all-pairs comparison testans <- kwAllPairsNemenyiTest(count ~ spray, data = InsectSprays)summary(ans)## Brown-Mood all-pairs median testans <- medianAllPairsTest(count ~ spray, data = InsectSprays)summary(ans)

Dunn's All-Pairs Rank Comparison Test

Description

Performs Dunn's non-parametric all-pairs comparison testfor Kruskal-type ranked data.

Usage

kwAllPairsDunnTest(x, ...)## Default S3 method:kwAllPairsDunnTest(x, g, p.adjust.method = p.adjust.methods, ...)## S3 method for class 'formula'kwAllPairsDunnTest(  formula,  data,  subset,  na.action,  p.adjust.method = p.adjust.methods,  ...)

Arguments

x

a numeric vector of data values, or a list of numeric datavectors.

...

further arguments to be passed to or from methods.

g

a vector or factor object giving the group for thecorresponding elements of"x".Ignored with a warning if"x" is a list.

p.adjust.method

method for adjusting p values(seep.adjust).

formula

a formula of the formresponse ~ group whereresponse gives the data values andgroup a vector orfactor of the corresponding groups.

data

an optional matrix or data frame (or similar: seemodel.frame) containing the variables in theformulaformula. By default the variables are taken fromenvironment(formula).

subset

an optional vector specifying asubset of observations to be used.

na.action

a function which indicates what should happen whenthe data containNAs. Defaults togetOption("na.action").

Details

For all-pairs comparisons in an one-factorial layoutwith non-normally distributed residuals Dunn's non-parametric testcan be performed. A total ofm = k(k-1)/2hypotheses can be tested. The null hypothesisH_{ij}: \mu_i(x) = \mu_j(x) is tested in the two-tailed testagainst the alternativeA_{ij}: \mu_i(x) \ne \mu_j(x), ~~ i \ne j.

The p-values are computed from the standard normal distribution usingany of the p-adjustment methods as included inp.adjust.Originally, Dunn (1964) proposed Bonferroni's p-adjustment method.

Value

A list with class"PMCMR" containing the following components:

method

a character string indicating what type of test was performed.

data.name

a character string giving the name(s) of the data.

statistic

lower-triangle matrix of the estimatedquantiles of the pairwise test statistics.

p.value

lower-triangle matrix of the p-values for the pairwise tests.

alternative

a character string describing the alternative hypothesis.

p.adjust.method

a character string describing the method for p-valueadjustment.

model

a data frame of the input data.

dist

a string that denotes the test distribution.

References

Dunn, O. J. (1964) Multiple comparisons using rank sums,Technometrics6, 241–252.

Siegel, S., Castellan Jr., N. J. (1988)Nonparametric Statisticsfor The Behavioral Sciences. New York: McGraw-Hill.

See Also

Normal,p.adjust,kruskalTest,kwAllPairsConoverTest,kwAllPairsNemenyiTest

Examples

## Data set InsectSprays## Global testkruskalTest(count ~ spray, data = InsectSprays)## Conover's all-pairs comparison test## single-step means Tukey's p-adjustmentans <- kwAllPairsConoverTest(count ~ spray, data = InsectSprays,                             p.adjust.method = "single-step")summary(ans)## Dunn's all-pairs comparison testans <- kwAllPairsDunnTest(count ~ spray, data = InsectSprays,                             p.adjust.method = "bonferroni")summary(ans)## Nemenyi's all-pairs comparison testans <- kwAllPairsNemenyiTest(count ~ spray, data = InsectSprays)summary(ans)## Brown-Mood all-pairs median testans <- medianAllPairsTest(count ~ spray, data = InsectSprays)summary(ans)

Nemenyi's All-Pairs Rank Comparison Test

Description

Performs Nemenyi's non-parametric all-pairs comparison testfor Kruskal-type ranked data.

Usage

kwAllPairsNemenyiTest(x, ...)## Default S3 method:kwAllPairsNemenyiTest(x, g, dist = c("Tukey", "Chisquare"), ...)## S3 method for class 'formula'kwAllPairsNemenyiTest(  formula,  data,  subset,  na.action,  dist = c("Tukey", "Chisquare"),  ...)

Arguments

x

a numeric vector of data values, or a list of numeric datavectors.

...

further arguments to be passed to or from methods.

g

a vector or factor object giving the group for thecorresponding elements of"x".Ignored with a warning if"x" is a list.

dist

the distribution for determining the p-value.Defaults to"Tukey".

formula

a formula of the formresponse ~ group whereresponse gives the data values andgroup a vector orfactor of the corresponding groups.

data

an optional matrix or data frame (or similar: seemodel.frame) containing the variables in theformulaformula. By default the variables are taken fromenvironment(formula).

subset

an optional vector specifying asubset of observations to be used.

na.action

a function which indicates what should happen whenthe data containNAs. Defaults togetOption("na.action").

Details

For all-pairs comparisons in an one-factorial layoutwith non-normally distributed residuals Nemenyi's non-parametric testcan be performed. A total ofm = k(k-1)/2hypotheses can be tested. The null hypothesisH_{ij}: \theta_i(x) = \theta_j(x) is tested in the two-tailed testagainst the alternativeA_{ij}: \theta_i(x) \ne \theta_j(x), ~~ i \ne j.

LetR_{ij} be the rank ofX_{ij},whereX_{ij} is jointly rankedfrom\left\{1, 2, \ldots, N \right\}, ~~ N = \sum_{i=1}^k n_i,then the test statistic under the absence of ties is calculated as

t_{ij} = \frac{\bar{R}_j - \bar{R}_i}{\sigma_R \left(1/n_i + 1/n_j\right)^{1/2}} \qquad \left(i \ne j\right),

with\bar{R}_j, \bar{R}_i the mean rank of thei-th andj-th group and the expected variance as

\sigma_R^2 = N \left(N + 1\right) / 12.

A pairwise difference is significant, if|t_{ij}|/\sqrt{2} > q_{kv},withk the number of groups andv = \inftythe degree of freedom.

Sachs(1997) has given a modified approach forNemenyi's test in the presence of ties forN > 6, k > 4provided that thekruskalTest indicates significance:In the presence of ties, the test statistic iscorrected according to\hat{t}_{ij} = t_{ij} / C, with

C = 1 - \frac{\sum_{i=1}^r t_i^3 - t_i}{N^3 - N}.

The function provides two differentdistforp-value estimation:

Tukey

Thep-values are computed from the studentizedrange distribution (aliasTukey),\mathrm{Pr} \left\{ t_{ij} \sqrt{2} \ge q_{k\infty\alpha} | mathrm{H} \right\} = \alpha.

Chisquare

Thep-values are computed from theChisquare distribution withv = k - 1 degreeof freedom.

Value

A list with class"PMCMR" containing the following components:

method

a character string indicating what type of test was performed.

data.name

a character string giving the name(s) of the data.

statistic

lower-triangle matrix of the estimatedquantiles of the pairwise test statistics.

p.value

lower-triangle matrix of the p-values for the pairwise tests.

alternative

a character string describing the alternative hypothesis.

p.adjust.method

a character string describing the method for p-valueadjustment.

model

a data frame of the input data.

dist

a string that denotes the test distribution.

References

Nemenyi, P. (1963)Distribution-free Multiple Comparisons.Ph.D. thesis, Princeton University.

Sachs, L. (1997)Angewandte Statistik. Berlin: Springer.

Wilcoxon, F., Wilcox, R. A. (1964)Some rapid approximate statistical procedures.Pearl River: Lederle Laboratories.

See Also

Tukey,Chisquare,p.adjust,kruskalTest,kwAllPairsDunnTest,kwAllPairsConoverTest

Examples

## Data set InsectSprays## Global testkruskalTest(count ~ spray, data = InsectSprays)## Conover's all-pairs comparison test## single-step means Tukey's p-adjustmentans <- kwAllPairsConoverTest(count ~ spray, data = InsectSprays,                             p.adjust.method = "single-step")summary(ans)## Dunn's all-pairs comparison testans <- kwAllPairsDunnTest(count ~ spray, data = InsectSprays,                             p.adjust.method = "bonferroni")summary(ans)## Nemenyi's all-pairs comparison testans <- kwAllPairsNemenyiTest(count ~ spray, data = InsectSprays)summary(ans)## Brown-Mood all-pairs median testans <- medianAllPairsTest(count ~ spray, data = InsectSprays)summary(ans)

Conover's Many-to-One Rank Comparison Test

Description

Performs Conover's non-parametric many-to-one comparisontest for Kruskal-type ranked data.

Usage

kwManyOneConoverTest(x, ...)## Default S3 method:kwManyOneConoverTest(  x,  g,  alternative = c("two.sided", "greater", "less"),  p.adjust.method = c("single-step", p.adjust.methods),  ...)## S3 method for class 'formula'kwManyOneConoverTest(  formula,  data,  subset,  na.action,  alternative = c("two.sided", "greater", "less"),  p.adjust.method = c("single-step", p.adjust.methods),  ...)

Arguments

x

a numeric vector of data values, or a list of numeric datavectors.

...

further arguments to be passed to or from methods.

g

a vector or factor object giving the group for thecorresponding elements of"x".Ignored with a warning if"x" is a list.

alternative

the alternative hypothesis. Defaults totwo.sided.

p.adjust.method

method for adjusting p values(seep.adjust).

formula

a formula of the formresponse ~ group whereresponse gives the data values andgroup a vector orfactor of the corresponding groups.

data

an optional matrix or data frame (or similar: seemodel.frame) containing the variables in theformulaformula. By default the variables are taken fromenvironment(formula).

subset

an optional vector specifying asubset of observations to be used.

na.action

a function which indicates what should happen whenthe data containNAs. Defaults togetOption("na.action").

Details

For many-to-one comparisons (pairwise comparisons with one control)in an one-factorial layout with non-normally distributedresiduals Conover's non-parametric test can be performed.Let there bek groups including the control,then the number of treatment levels ism = k - 1.Thenm pairwise comparisons can be performed betweenthei-th treatment level and the control.H_i: \theta_0 = \theta_i is tested in the two-tailed case againstA_i: \theta_0 \ne \theta_i, ~~ (1 \le i \le m).

Ifp.adjust.method == "single-step" is selected,thep-values will be computedfrom the multivariatet distribution. Otherwise,thep-values are computed from thet-distribution usingany of thep-adjustment methods as included inp.adjust.

Value

A list with class"PMCMR" containing the following components:

method

a character string indicating what type of test was performed.

data.name

a character string giving the name(s) of the data.

statistic

lower-triangle matrix of the estimatedquantiles of the pairwise test statistics.

p.value

lower-triangle matrix of the p-values for the pairwise tests.

alternative

a character string describing the alternative hypothesis.

p.adjust.method

a character string describing the method for p-valueadjustment.

model

a data frame of the input data.

dist

a string that denotes the test distribution.

Note

Factor labels forg must be assigned in such a way,that they can be increasingly ordered from zero-dosecontrol to the highest dose level, e.g. integers{0, 1, 2, ..., k} or letters {a, b, c, ...}.Otherwise the function may not select the correct valuesfor intended zero-dose control.

It is safer, to i) label the factor levels as given above,and to ii) sort the data according to increasing dose-levelsprior to call the function (seeorder,factor).

References

Conover, W. J, Iman, R. L. (1979)On multiple-comparisonsprocedures, Tech. Rep. LA-7677-MS, Los Alamos Scientific Laboratory.

See Also

pmvt,TDist,kruskalTest,kwManyOneDunnTest,kwManyOneNdwTest

Examples

## Data set PlantGrowth## Global testkruskalTest(weight ~ group, data = PlantGrowth)## Conover's many-one comparison test## single-step means p-value from multivariate t distributionans <- kwManyOneConoverTest(weight ~ group, data = PlantGrowth,                             p.adjust.method = "single-step")summary(ans)## Conover's many-one comparison testans <- kwManyOneConoverTest(weight ~ group, data = PlantGrowth,                             p.adjust.method = "holm")summary(ans)## Dunn's many-one comparison testans <- kwManyOneDunnTest(weight ~ group, data = PlantGrowth,                             p.adjust.method = "holm")summary(ans)## Nemenyi's many-one comparison testans <- kwManyOneNdwTest(weight ~ group, data = PlantGrowth,                        p.adjust.method = "holm")summary(ans)## Many one U testans <- manyOneUTest(weight ~ group, data = PlantGrowth,                        p.adjust.method = "holm")summary(ans)## Chen Testans <- chenTest(weight ~ group, data = PlantGrowth,                    p.adjust.method = "holm")summary(ans)

Dunn's Many-to-One Rank Comparison Test

Description

Performs Dunn's non-parametric many-to-one comparisontest for Kruskal-type ranked data.

Usage

kwManyOneDunnTest(x, ...)## Default S3 method:kwManyOneDunnTest(  x,  g,  alternative = c("two.sided", "greater", "less"),  p.adjust.method = c("single-step", p.adjust.methods),  ...)## S3 method for class 'formula'kwManyOneDunnTest(  formula,  data,  subset,  na.action,  alternative = c("two.sided", "greater", "less"),  p.adjust.method = c("single-step", p.adjust.methods),  ...)

Arguments

x

a numeric vector of data values, or a list of numeric datavectors.

...

further arguments to be passed to or from methods.

g

a vector or factor object giving the group for thecorresponding elements of"x".Ignored with a warning if"x" is a list.

alternative

the alternative hypothesis. Defaults totwo.sided.

p.adjust.method

method for adjusting p values(seep.adjust).

formula

a formula of the formresponse ~ group whereresponse gives the data values andgroup a vector orfactor of the corresponding groups.

data

an optional matrix or data frame (or similar: seemodel.frame) containing the variables in theformulaformula. By default the variables are taken fromenvironment(formula).

subset

an optional vector specifying asubset of observations to be used.

na.action

a function which indicates what should happen whenthe data containNAs. Defaults togetOption("na.action").

Details

For many-to-one comparisons (pairwise comparisons with one control)in an one-factorial layout with non-normally distributedresiduals Dunn's non-parametric test can be performed.Let there bek groups including the control,then the number of treatment levels ism = k - 1.Thenm pairwise comparisons can be performed betweenthei-th treatment level and the control.H_i: \theta_0 = \theta_i is tested in the two-tailed case againstA_i: \theta_0 \ne \theta_i, ~~ (1 \le i \le m).

Ifp.adjust.method == "single-step" is selected,thep-values will be computedfrom the multivariate normal distribution. Otherwise,thep-values are computed from the standard normal distribution usingany of thep-adjustment methods as included inp.adjust.

Value

A list with class"PMCMR" containing the following components:

method

a character string indicating what type of test was performed.

data.name

a character string giving the name(s) of the data.

statistic

lower-triangle matrix of the estimatedquantiles of the pairwise test statistics.

p.value

lower-triangle matrix of the p-values for the pairwise tests.

alternative

a character string describing the alternative hypothesis.

p.adjust.method

a character string describing the method for p-valueadjustment.

model

a data frame of the input data.

dist

a string that denotes the test distribution.

Note

Factor labels forg must be assigned in such a way,that they can be increasingly ordered from zero-dosecontrol to the highest dose level, e.g. integers{0, 1, 2, ..., k} or letters {a, b, c, ...}.Otherwise the function may not select the correct valuesfor intended zero-dose control.

It is safer, to i) label the factor levels as given above,and to ii) sort the data according to increasing dose-levelsprior to call the function (seeorder,factor).

References

Dunn, O. J. (1964) Multiple comparisons using rank sums,Technometrics6, 241–252.

Siegel, S., Castellan Jr., N. J. (1988)Nonparametric Statisticsfor The Behavioral Sciences. New York: McGraw-Hill.

See Also

pmvnorm,TDist,kruskalTest,kwManyOneConoverTest,kwManyOneNdwTest

Examples

## Data set PlantGrowth## Global testkruskalTest(weight ~ group, data = PlantGrowth)## Conover's many-one comparison test## single-step means p-value from multivariate t distributionans <- kwManyOneConoverTest(weight ~ group, data = PlantGrowth,                             p.adjust.method = "single-step")summary(ans)## Conover's many-one comparison testans <- kwManyOneConoverTest(weight ~ group, data = PlantGrowth,                             p.adjust.method = "holm")summary(ans)## Dunn's many-one comparison testans <- kwManyOneDunnTest(weight ~ group, data = PlantGrowth,                             p.adjust.method = "holm")summary(ans)## Nemenyi's many-one comparison testans <- kwManyOneNdwTest(weight ~ group, data = PlantGrowth,                        p.adjust.method = "holm")summary(ans)## Many one U testans <- manyOneUTest(weight ~ group, data = PlantGrowth,                        p.adjust.method = "holm")summary(ans)## Chen Testans <- chenTest(weight ~ group, data = PlantGrowth,                    p.adjust.method = "holm")summary(ans)

Nemenyi-Damico-Wolfe Many-to-One Rank Comparison Test

Description

Performs Nemenyi-Damico-Wolfe non-parametric many-to-one comparisontest for Kruskal-type ranked data.

Usage

kwManyOneNdwTest(x, ...)## Default S3 method:kwManyOneNdwTest(  x,  g,  alternative = c("two.sided", "greater", "less"),  p.adjust.method = c("single-step", p.adjust.methods),  ...)## S3 method for class 'formula'kwManyOneNdwTest(  formula,  data,  subset,  na.action,  alternative = c("two.sided", "greater", "less"),  p.adjust.method = c("single-step", p.adjust.methods),  ...)

Arguments

x

a numeric vector of data values, or a list of numeric datavectors.

...

further arguments to be passed to or from methods.

g

a vector or factor object giving the group for thecorresponding elements of"x".Ignored with a warning if"x" is a list.

alternative

the alternative hypothesis. Defaults totwo.sided.

p.adjust.method

method for adjusting p values(seep.adjust).

formula

a formula of the formresponse ~ group whereresponse gives the data values andgroup a vector orfactor of the corresponding groups.

data

an optional matrix or data frame (or similar: seemodel.frame) containing the variables in theformulaformula. By default the variables are taken fromenvironment(formula).

subset

an optional vector specifying asubset of observations to be used.

na.action

a function which indicates what should happen whenthe data containNAs. Defaults togetOption("na.action").

Details

For many-to-one comparisons (pairwise comparisons with one control)in an one-factorial layout with non-normally distributedresiduals the Nemenyi-Damico-Wolfe non-parametric test can be performed.Let there bek groups including the control,then the number of treatment levels ism = k - 1.Thenm pairwise comparisons can be performed betweenthei-th treatment level and the control.H_i: \theta_0 = \theta_i is tested in the two-tailed case againstA_i: \theta_0 \ne \theta_i, ~~ (1 \le i \le m).

Ifp.adjust.method == "single-step" is selected,thep-values will be computedfrom the multivariate normal distribution. Otherwise,thep-values are computed from the standard normal distribution usingany of thep-adjustment methods as included inp.adjust.

Value

A list with class"PMCMR" containing the following components:

method

a character string indicating what type of test was performed.

data.name

a character string giving the name(s) of the data.

statistic

lower-triangle matrix of the estimatedquantiles of the pairwise test statistics.

p.value

lower-triangle matrix of the p-values for the pairwise tests.

alternative

a character string describing the alternative hypothesis.

p.adjust.method

a character string describing the method for p-valueadjustment.

model

a data frame of the input data.

dist

a string that denotes the test distribution.

Note

This function is essentially the same askwManyOneDunnTest, butthere is no tie correction included. Therefore, the implementation ofDunn's test is superior, when ties are present.

References

Damico, J. A., Wolfe, D. A. (1989) Extended tables of the exact distribution ofa rank statistic for treatments versus control multiple comparisons in one-waylayout designs,Communications in Statistics - Theory and Methods18,3327–3353.

Nemenyi, P. (1963)Distribution-free Multiple Comparisons,Ph.D. thesis, Princeton University.

See Also

pmvt,TDist,kruskalTest,kwManyOneDunnTest,kwManyOneConoverTest

Examples

## Data set PlantGrowth## Global testkruskalTest(weight ~ group, data = PlantGrowth)## Conover's many-one comparison test## single-step means p-value from multivariate t distributionans <- kwManyOneConoverTest(weight ~ group, data = PlantGrowth,                             p.adjust.method = "single-step")summary(ans)## Conover's many-one comparison testans <- kwManyOneConoverTest(weight ~ group, data = PlantGrowth,                             p.adjust.method = "holm")summary(ans)## Dunn's many-one comparison testans <- kwManyOneDunnTest(weight ~ group, data = PlantGrowth,                             p.adjust.method = "holm")summary(ans)## Nemenyi's many-one comparison testans <- kwManyOneNdwTest(weight ~ group, data = PlantGrowth,                        p.adjust.method = "holm")summary(ans)## Many one U testans <- manyOneUTest(weight ~ group, data = PlantGrowth,                        p.adjust.method = "holm")summary(ans)## Chen Testans <- chenTest(weight ~ group, data = PlantGrowth,                    p.adjust.method = "holm")summary(ans)

Testing against Ordered Alternatives (Le's Test)

Description

Performs Le's test for testing against ordered alternatives.

Usage

leTest(x, ...)## Default S3 method:leTest(x, g, alternative = c("two.sided", "greater", "less"), ...)## S3 method for class 'formula'leTest(  formula,  data,  subset,  na.action,  alternative = c("two.sided", "greater", "less"),  ...)

Arguments

x

a numeric vector of data values, or a list of numeric datavectors.

...

further arguments to be passed to or from methods.

g

a vector or factor object giving the group for thecorresponding elements of"x".Ignored with a warning if"x" is a list.

alternative

the alternative hypothesis. Defaults to"two.sided".

formula

a formula of the formresponse ~ group whereresponse gives the data values andgroup a vector orfactor of the corresponding groups.

data

an optional matrix or data frame (or similar: seemodel.frame) containing the variables in theformulaformula. By default the variables are taken fromenvironment(formula).

subset

an optional vector specifying asubset of observations to be used.

na.action

a function which indicates what should happen whenthe data containNAs. Defaults togetOption("na.action").

Details

The null hypothesis, H_0: \theta_1 = \theta_2 = \ldots = \theta_kis tested against a simple order hypothesis,H_\mathrm{A}: \theta_1 \le \theta_2 \le \ldots \le\theta_k,~\theta_1 < \theta_k.

The p-values are estimated from the standard normal distribution.

Value

A list with class"htest" containing the following components:

method

a character string indicating what type of test was performed.

data.name

a character string giving the name(s) of the data.

statistic

the estimated quantile of the test statistic.

p.value

the p-value for the test.

parameter

the parameters of the test statistic, if any.

alternative

a character string describing the alternative hypothesis.

estimates

the estimates, if any.

null.value

the estimate under the null hypothesis, if any.

Note

Factor labels forg must be assigned in such a way,that they can be increasingly ordered from zero-dosecontrol to the highest dose level, e.g. integers{0, 1, 2, ..., k} or letters {a, b, c, ...}.Otherwise the function may not select the correct valuesfor intended zero-dose control.

It is safer, to i) label the factor levels as given above,and to ii) sort the data according to increasing dose-levelsprior to call the function (seeorder,factor).

References

Le, C. T. (1988) A new rank test against ordered alternativesin k-sample problems,Biometrical Journal30, 87–92.

See Also

kruskalTest andshirleyWilliamsTestof the packagePMCMRplus,kruskal.test of the librarystats.

Examples

## Example from Sachs (1997, p. 402)x <- c(106, 114, 116, 127, 145,       110, 125, 143, 148, 151,       136, 139, 149, 160, 174)g <- gl(3,5)levels(g) <- c("A", "B", "C")## Chacko's testchackoTest(x, g)## Cuzick's testcuzickTest(x, g)## Johnson-Mehrotra testjohnsonTest(x, g)## Jonckheere-Terpstra testjonckheereTest(x, g)## Le's testleTest(x, g)## Spearman type testspearmanTest(x, g)## Murakami's BWS trend testbwsTrendTest(x, g)## Fligner-Wolfe testflignerWolfeTest(x, g)## Shan-Young-Kang testshanTest(x, g)

Least Significant Difference Test

Description

Performs the least significant difference all-pairs comparisonstest for normally distributed data with equal group variances.

Usage

lsdTest(x, ...)## Default S3 method:lsdTest(x, g, ...)## S3 method for class 'formula'lsdTest(formula, data, subset, na.action, ...)## S3 method for class 'aov'lsdTest(x, ...)

Arguments

x

a numeric vector of data values, a list of numeric datavectors or a fitted model object, usually anaov fit.

...

further arguments to be passed to or from methods.

g

a vector or factor object giving the group for thecorresponding elements of"x".Ignored with a warning if"x" is a list.

formula

a formula of the formresponse ~ group whereresponse gives the data values andgroup a vector orfactor of the corresponding groups.

data

an optional matrix or data frame (or similar: seemodel.frame) containing the variables in theformulaformula. By default the variables are taken fromenvironment(formula).

subset

an optional vector specifying asubset of observations to be used.

na.action

a function which indicates what should happen whenthe data containNAs. Defaults togetOption("na.action").

Details

For all-pairs comparisons in an one-factorial layoutwith normally distributed residuals and equal variancesthe least signifiant difference test can be performedafter a significant ANOVA F-test.LetX_{ij} denote a continuous random variablewith thej-the realization (1 \le j \le n_i)in thei-th group (1 \le i \le k). Furthermore, the totalsample size isN = \sum_{i=1}^k n_i. A total ofm = k(k-1)/2hypotheses can be tested: The null hypothesis isH_{ij}: \mu_i = \mu_j ~~ (i \ne j) is tested against the alternativeA_{ij}: \mu_i \ne \mu_j (two-tailed). Fisher's LSD all-pairs teststatistics are given by

t_{ij} \frac{\bar{X}_i - \bar{X_j}} {s_{\mathrm{in}} \left(1/n_j + 1/n_i\right)^{1/2}}, ~~ (i \ne j)

withs^2_{\mathrm{in}} the within-group ANOVA variance.The null hypothesis is rejected if|t_{ij}| > t_{v\alpha/2},withv = N - k degree of freedom. The p-values (two-tailed)are computed from theTDist distribution.

Value

A list with class"PMCMR" containing the following components:

method

a character string indicating what type of test was performed.

data.name

a character string giving the name(s) of the data.

statistic

lower-triangle matrix of the estimatedquantiles of the pairwise test statistics.

p.value

lower-triangle matrix of the p-values for the pairwise tests.

alternative

a character string describing the alternative hypothesis.

p.adjust.method

a character string describing the method for p-valueadjustment.

model

a data frame of the input data.

dist

a string that denotes the test distribution.

Note

As there is no p-value adjustment included, this function is equivalentto Fisher's protected LSD test, provided that the LSD test isonly applied after a significant one-way ANOVA F-test.If one is interested in other types of LSD test (i.e.with p-value adustment) see functionpairwise.t.test.

References

Sachs, L. (1997)Angewandte Statistik, New York: Springer.

See Also

TDist,pairwise.t.test

Examples

fit <- aov(weight ~ feed, chickwts)shapiro.test(residuals(fit))bartlett.test(weight ~ feed, chickwts)anova(fit)## also works with fitted objects of class aovres <- lsdTest(fit)summary(res)summaryGroup(res)

Mack-Wolfe Test for Umbrella Alternatives

Description

Performs Mack-Wolfe non-parametric test for umbrella alternatives.

Usage

mackWolfeTest(x, ...)## Default S3 method:mackWolfeTest(x, g, p = NULL, nperm = 1000, ...)## S3 method for class 'formula'mackWolfeTest(formula, data, subset, na.action, p = NULL, nperm = 1000, ...)

Arguments

x

a numeric vector of data values, or a list of numeric datavectors.

...

further arguments to be passed to or from methods.

g

a vector or factor object giving the group for thecorresponding elements of"x".Ignored with a warning if"x" is a list.

p

the a-priori known peak as an ordinal number of the treatmentgroup including the zero dose level, i.e.p = \{1, \ldots, k\}.Defaults toNULL.

nperm

number of permutations for the assymptotic permutation test.Defaults to1000.

formula

a formula of the formresponse ~ group whereresponse gives the data values andgroup a vector orfactor of the corresponding groups.

data

an optional matrix or data frame (or similar: seemodel.frame) containing the variables in theformulaformula. By default the variables are taken fromenvironment(formula).

subset

an optional vector specifying asubset of observations to be used.

na.action

a function which indicates what should happen whenthe data containNAs. Defaults togetOption("na.action").

Details

In dose-finding studies one may assume an increasing treatmenteffect with increasing dose level. However, the testsubject may actually succumb to toxic effects at high doses,which leads to decresing treatment effects.

The scope of the Mack-Wolfe Test is to test for umbrella alternativesfor either a known or unknown pointp (i.e. dose-level),where the peak (umbrella point) is present.

H_i: \theta_0 = \theta_i = \ldots = \theta_k is testedagainst the alternative A_i: \theta_1 \le \ldots \theta_p \ge\theta_k for somep, with at least one strict inequality.

Ifp = NULL (peak unknown), the upper-tailp-value is computedvia an asymptotic bootstrap permutation test.

If an integer value forp is given (peak known), theupper-tailp-value is computed from the standard normaldistribution (pnorm).

Value

A list with class"htest" containing the following components:

method

a character string indicating what type of test was performed.

data.name

a character string giving the name(s) of the data.

statistic

the estimated quantile of the test statistic.

p.value

the p-value for the test.

parameter

the parameters of the test statistic, if any.

alternative

a character string describing the alternative hypothesis.

estimates

the estimates, if any.

null.value

the estimate under the null hypothesis, if any.

Note

One may increase the number of permutations to e.g.nperm = 10000in order to get more precise p-values. However, this will be onthe expense of computational time.

References

Chen, I. Y. (1991) Notes on the Mack-Wolfe and Chen-WolfeTests for Umbrella Alternatives,Biom. J.33, 281–290.

Mack, G. A., Wolfe, D. A. (1981) K-sample rank tests forumbrella alternatives,J. Amer. Statist. Assoc.76, 175–181.

See Also

pnorm,sample.

Examples

## Example from Table 6.10 of Hollander and Wolfe (1999).## Plates with Salmonella bacteria of strain TA98 were exposed to## various doses of Acid Red 114 (in mu g / ml).## The data are the numbers of visible revertant colonies on 12 plates.## Assume a peak at D333 (i.e. p = 3).x <- c(22, 23, 35, 60, 59, 54, 98, 78, 50, 60, 82, 59, 22, 44,  33, 23, 21, 25)g <- as.ordered(rep(c(0, 100, 333, 1000, 3333, 10000), each=3))plot(x ~ g)mackWolfeTest(x=x, g=g, p=3)

Mandel's h Test According to E 691 ASTM

Description

The function calculates theconsistency statistics h and correspondingp-values for each group (lab) according toPractice E 691 ASTM.

Usage

mandelhTest(x, ...)## Default S3 method:mandelhTest(x, g, ...)## S3 method for class 'formula'mandelhTest(formula, data, subset, na.action, ...)

Arguments

x

a numeric vector of data values, or a list of numeric datavectors.

...

further arguments to be passed to or from methods.

g

a vector or factor object giving the group for thecorresponding elements of"x".Ignored with a warning if"x" is a list.

formula

a formula of the formresponse ~ group whereresponse gives the data values andgroup a vector orfactor of the corresponding groups.

data

an optional matrix or data frame (or similar: seemodel.frame) containing the variables in theformulaformula. By default the variables are taken fromenvironment(formula).

subset

an optional vector specifying asubset of observations to be used.

na.action

a function which indicates what should happen whenthe data containNAs. Defaults togetOption("na.action").

Value

A list with class"mandel" containing the following components:

method

a character stringindicating what type of test was performed.

data.name

a character string giving the name(s) of the data.

p.value

the p-value for the test.

statistic

the estimated quantiles of Mandel's statistic.

alternative

a character string describingthe alternative hypothesis.

grouplev

a character vector describing thelevels of the groups.

nrofrepl

the number of replicates for each group.

References

Practice E 691 (2005)Standard Practice forConducting an Interlaboratory Study to Determine thePrecision of a Test Method, ASTM International.

See Also

qmandelhpmandelh

Examples

data(Pentosan)mandelhTest(value ~ lab, data=Pentosan, subset=(material == "A"))

Mandel's k Test According to E 691 ASTM

Description

The function calculates theconsistency statistics k and correspondingp-values for each group (lab) according to Practice E 691 ASTM.

Usage

mandelkTest(x, ...)## Default S3 method:mandelkTest(x, g, ...)## S3 method for class 'formula'mandelkTest(formula, data, subset, na.action, ...)

Arguments

x

a numeric vector of data values, or a list of numeric datavectors.

...

further arguments to be passed to or from methods.

g

a vector or factor object giving the group for thecorresponding elements of"x".Ignored with a warning if"x" is a list.

formula

a formula of the formresponse ~ group whereresponse gives the data values andgroup a vector orfactor of the corresponding groups.

data

an optional matrix or data frame (or similar: seemodel.frame) containing the variables in theformulaformula. By default the variables are taken fromenvironment(formula).

subset

an optional vector specifying asubset of observations to be used.

na.action

a function which indicates what should happen whenthe data containNAs. Defaults togetOption("na.action").

Value

A list with class"mandel" containing the following components:

method

a character stringindicating what type of test was performed.

data.name

a character string giving the name(s) of the data.

p.value

the p-value for the test.

statistic

the estimated quantiles of Mandel's statistic.

alternative

a character string describingthe alternative hypothesis.

grouplev

a character vector describing thelevels of the groups.

nrofrepl

the number of replicates for each group.

References

Practice E 691 (2005)Standard Practice forConducting an Interlaboratory Study to Determine thePrecision of a Test Method, ASTM International.

See Also

qmandelkpmandelk

Examples

data(Pentosan)mandelkTest(value ~ lab, data=Pentosan, subset=(material == "A"))

Multiple Comparisons with One Control (U-test)

Description

Performs pairwise comparisons of multiple group levels withone control.

Usage

manyOneUTest(x, ...)## Default S3 method:manyOneUTest(  x,  g,  alternative = c("two.sided", "greater", "less"),  p.adjust.method = c("single-step", p.adjust.methods),  ...)## S3 method for class 'formula'manyOneUTest(  formula,  data,  subset,  na.action,  alternative = c("two.sided", "greater", "less"),  p.adjust.method = c("single-step", p.adjust.methods),  ...)

Arguments

x

a numeric vector of data values, or a list of numeric datavectors.

...

further arguments to be passed to or from methods.

g

a vector or factor object giving the group for thecorresponding elements of"x".Ignored with a warning if"x" is a list.

alternative

the alternative hypothesis. Defaults totwo.sided.

p.adjust.method

method for adjusting p values(seep.adjust)

formula

a formula of the formresponse ~ group whereresponse gives the data values andgroup a vector orfactor of the corresponding groups.

data

an optional matrix or data frame (or similar: seemodel.frame) containing the variables in theformulaformula. By default the variables are taken fromenvironment(formula).

subset

an optional vector specifying asubset of observations to be used.

na.action

a function which indicates what should happen whenthe data containNAs. Defaults togetOption("na.action").

Details

This functions performs Wilcoxon, Mann and Whitney's U-testfor a one factorial design where each factor level is tested againstone control (m = k -1 tests). As the data are re-rankedfor each comparison, this test is only suitable forbalanced (or almost balanced) experimental designs.

For the two-tailed test andp.adjust.method = "single-step"the multivariate normal distribution is used for controllingType 1 error and to calculate p-values. Otherwise,the p-values are calculated from the standard normal distributionwith any latter p-adjustment as available byp.adjust.

Value

A list with class"PMCMR" containing the following components:

method

a character string indicating what type of test was performed.

data.name

a character string giving the name(s) of the data.

statistic

lower-triangle matrix of the estimatedquantiles of the pairwise test statistics.

p.value

lower-triangle matrix of the p-values for the pairwise tests.

alternative

a character string describing the alternative hypothesis.

p.adjust.method

a character string describing the method for p-valueadjustment.

model

a data frame of the input data.

dist

a string that denotes the test distribution.

Note

Factor labels forg must be assigned in such a way,that they can be increasingly ordered from zero-dosecontrol to the highest dose level, e.g. integers{0, 1, 2, ..., k} or letters {a, b, c, ...}.Otherwise the function may not select the correct valuesfor intended zero-dose control.

It is safer, to i) label the factor levels as given above,and to ii) sort the data according to increasing dose-levelsprior to call the function (seeorder,factor).

References

OECD (ed. 2006)Current approaches in the statistical analysisof ecotoxicity data: A guidance to application, OECD Serieson testing and assessment, No. 54.

See Also

wilcox.test,pmvnorm,Normal

Examples

## Data set PlantGrowth## Global testkruskalTest(weight ~ group, data = PlantGrowth)## Conover's many-one comparison test## single-step means p-value from multivariate t distributionans <- kwManyOneConoverTest(weight ~ group, data = PlantGrowth,                             p.adjust.method = "single-step")summary(ans)## Conover's many-one comparison testans <- kwManyOneConoverTest(weight ~ group, data = PlantGrowth,                             p.adjust.method = "holm")summary(ans)## Dunn's many-one comparison testans <- kwManyOneDunnTest(weight ~ group, data = PlantGrowth,                             p.adjust.method = "holm")summary(ans)## Nemenyi's many-one comparison testans <- kwManyOneNdwTest(weight ~ group, data = PlantGrowth,                        p.adjust.method = "holm")summary(ans)## Many one U testans <- manyOneUTest(weight ~ group, data = PlantGrowth,                        p.adjust.method = "holm")summary(ans)## Chen Testans <- chenTest(weight ~ group, data = PlantGrowth,                    p.adjust.method = "holm")summary(ans)

Brown-Mood All Pairs Median Test

Description

Performs Brown-Mood All Pairs Median Test.

Usage

medianAllPairsTest(x, ...)## Default S3 method:medianAllPairsTest(x, g, p.adjust.method = p.adjust.methods, ...)## S3 method for class 'formula'medianAllPairsTest(  formula,  data,  subset,  na.action,  p.adjust.method = p.adjust.methods,  ...)

Arguments

x

a numeric vector of data values, or a list of numeric datavectors.

...

further arguments to be passed to or from methods.

g

a vector or factor object giving the group for thecorresponding elements of"x".Ignored with a warning if"x" is a list.

p.adjust.method

method for adjusting p values(seep.adjust).

formula

a formula of the formresponse ~ group whereresponse gives the data values andgroup a vector orfactor of the corresponding groups.

data

an optional matrix or data frame (or similar: seemodel.frame) containing the variables in theformulaformula. By default the variables are taken fromenvironment(formula).

subset

an optional vector specifying asubset of observations to be used.

na.action

a function which indicates what should happen whenthe data containNAs. Defaults togetOption("na.action").

Details

For all-pairs comparisons in an one-factorial layoutwith non-normally distributed residuals Brown-Moodnon-parametric Median testcan be performed. A total ofm = k(k-1)/2hypotheses can be tested. The null hypothesisH_{ij}: \mu_i(x) = \mu_j(x) is tested in the two-tailed testagainst the alternativeA_{ij}: \mu_i(x) \ne \mu_j(x), ~~ i \ne j.

In this procedure the joined median is used for classification,but pairwise Pearson Chisquare-Tests are conducted. Any methodas given byp.adjust.methods can be usedto account for multiplicity.

Value

A list with class"PMCMR" containing the following components:

method

a character string indicating what type of test was performed.

data.name

a character string giving the name(s) of the data.

statistic

lower-triangle matrix of the estimatedquantiles of the pairwise test statistics.

p.value

lower-triangle matrix of the p-values for the pairwise tests.

alternative

a character string describing the alternative hypothesis.

p.adjust.method

a character string describing the method for p-valueadjustment.

model

a data frame of the input data.

dist

a string that denotes the test distribution.

References

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

See Also

chisq.test.

Examples

## Data set InsectSprays## Global testkruskalTest(count ~ spray, data = InsectSprays)## Conover's all-pairs comparison test## single-step means Tukey's p-adjustmentans <- kwAllPairsConoverTest(count ~ spray, data = InsectSprays,                             p.adjust.method = "single-step")summary(ans)## Dunn's all-pairs comparison testans <- kwAllPairsDunnTest(count ~ spray, data = InsectSprays,                             p.adjust.method = "bonferroni")summary(ans)## Nemenyi's all-pairs comparison testans <- kwAllPairsNemenyiTest(count ~ spray, data = InsectSprays)summary(ans)## Brown-Mood all-pairs median testans <- medianAllPairsTest(count ~ spray, data = InsectSprays)summary(ans)

Brown-Mood Median Test

Description

Performs Brown-Mood Median Test.

Usage

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 datavectors.

...

further arguments to be passed to or from methods.

g

a vector or factor object giving the group for thecorresponding elements of"x".Ignored with a warning if"x" is a list.

simulate.p.value

a logical indicating whether to computep-values by Monte-Carlo simulation.

B

an integer specifying the number of replicates usedin the Monte-Carlo test.

formula

a formula of the formresponse ~ group whereresponse gives the data values andgroup a vector orfactor of the corresponding groups.

data

an optional matrix or data frame (or similar: seemodel.frame) containing the variables in theformulaformula. By default the variables are taken fromenvironment(formula).

subset

an optional vector specifying asubset of observations to be used.

na.action

a function which indicates what should happen whenthe data containNAs. Defaults togetOption("na.action").

Details

The null hypothesis, H_0: \theta_1 = \theta_2 =\ldots = \theta_kis tested against the alternative,H_\mathrm{A}: \theta_i \ne \theta_j ~~(i \ne j), with at leastone unequality beeing strict.

Value

A list with class ‘htest’. For details seechisq.test.

References

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

See Also

chisq.test.

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 subjectsy <- c(3.8, 2.7, 4.0, 2.4)      # with obstructive airway diseasez <- c(2.8, 3.4, 3.7, 2.2, 2.0) # with asbestosisg <- 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-TestadKSampleTest(x ~ g, data = dat)## BWS-TestbwsKSampleTest(x ~ g, data = dat)## Kruskal-Test## Using incomplete beta approximationkruskalTest(x ~ g, dat, dist="KruskalWallis")## Using chisquare distributionkruskalTest(x ~ g, dat, dist="Chisquare")## Not run: ## Check with kruskal.test from R statskruskal.test(x ~ g, dat)## End(Not run)## Using Conover's FkruskalTest(x ~ g, dat, dist="FDist")## Not run: ## Check with aov on ranksanova(aov(rank(x) ~ g, dat))## Check with oneway.testoneway.test(rank(x) ~ g, dat, var.equal = TRUE)## End(Not run)## Median Test asymptoticmedianTest(x ~ g, dat)## Median Test with simulated p-valuesset.seed(112)medianTest(x ~ g, dat, simulate.p.value = TRUE)

Madhava Rao-Raghunath Test for Testing Treatment vs. Control

Description

The function has implemented the nonparametric test ofMadhava Rao and Raghunath (2016) for testing paired two-samplesfor symmetry. The null hypothesisH: F(x,y) = F(y,x)is tested against the alternativeA: F(x,y) \ne F(y,x).

Usage

mrrTest(x, ...)## Default S3 method:mrrTest(x, y = NULL, m = NULL, ...)## S3 method for class 'formula'mrrTest(formula, data, subset, na.action, ...)

Arguments

x

numeric vector of data values. Non-finite (e.g., infinite or missing) values will be omitted.

...

further arguments to be passed to or from methods.

y

an optional numeric vector of data values:as with x non-finite values will be omitted.

m

numeric, optional integer number, whereasn = k m needs to befull filled.

formula

a formula of the formresponse ~ group whereresponse gives the data values andgroup a vector orfactor of the corresponding groups.

data

an optional matrix or data frame (or similar: seemodel.frame) containing the variables in theformulaformula. By default the variables are taken fromenvironment(formula).

subset

an optional vector specifying asubset of observations to be used.

na.action

a function which indicates what should happen whenthe data containNAs. Defaults togetOption("na.action").

Details

LetX_i andY_i, ~ i \le n denotecontinuous variables that were observedon the sameith test item (e.g. patient)withi = 1, \ldots n. Let

U_i = X_i + Y_i \qquad V_i = X_i - Y_i

LetU_{(i)} be theith order statistic,U_{(1)} \le U_{(2)} \le \ldots U_{(n)} andk thenumber of clusters, with the condition:

n = k ~ m.

Further, let the divider denoted_0 = -\infty,d_k = \infty, and else

d_j = \frac{ U_{(jm)} + U_{(jm+1)} }{2}, ~ 1 \le j \le k -1

The two counts are

n_j^{+} = \left\{ \begin{array}{lr} 1 & \mathrm{if}~ d_{j-1} < u_i < d_j, v_i > 0 \\ 0 & \end{array} \right.

and

n_j^{-} = \left\{ \begin{array}{lr} 1 & \mathrm{if}~ d_{j-1} < u_i < d_j, v_i \le 0 \\ 0 & \end{array} \right.

The test statistic is

M = \sum_{j = 1}^k \frac{\left(n_j^{+} - n_j^{-}\right)^2} {m}

The exact p-values for5 \le n \le 30 are taken from aninternal look-up table. The exact p-values were takenfrom Table 7, Appendix B of Madhava Rao and Raghunath (2016).

Ifm = NULL the function usesn = m forall prime numbers, otherwise it tries to find an value form in such a way, that fork = n / m all variablesare integer.

Value

A list with class"htest" containing the following components:

method

a character string indicating what type of test was performed.

data.name

a character string giving the name(s) of the data.

statistic

the estimated quantile of the test statistic.

p.value

the p-value for the test.

parameter

the parameters of the test statistic, if any.

alternative

a character string describing the alternative hypothesis.

estimates

the estimates, if any.

null.value

the estimate under the null hypothesis, if any.

Note

The function returns an error code if a value formis provided that does not lead to an integer of the ratiok = n /m.

The function also returns an error code, if a tabulatedvalue for givenn,m and calculatedMcan not be found in the look-up table.

References

Madhava Rao, K.S., Ragunath, M. (2016) A Simple Nonparametric Testfor Testing Treatment Versus Control.J Stat Adv Theory Appl16,133–162.doi:10.18642/jsata_7100121717

Examples

## Madhava Rao and Raghunath (2016), p. 151## Inulin clearance of living donors## and recipients of their kidneysx <- c(61.4, 63.3, 63.7, 80.0, 77.3, 84.0, 105.0)y <- c(70.8, 89.2, 65.8, 67.1, 87.3, 85.1, 88.1)mrrTest(x, y)## formula method## Student's Sleep DatamrrTest(extra ~ group, data = sleep)

Lu-Smith All-Pairs Comparison Normal Scores Test

Description

Performs Lu-Smith all-pairs comparisonnormal scores test.

Usage

normalScoresAllPairsTest(x, ...)## Default S3 method:normalScoresAllPairsTest(  x,  g,  p.adjust.method = c("single-step", p.adjust.methods),  ...)## S3 method for class 'formula'normalScoresAllPairsTest(  formula,  data,  subset,  na.action,  p.adjust.method = c("single-step", p.adjust.methods),  ...)

Arguments

x

a numeric vector of data values, or a list of numeric datavectors.

...

further arguments to be passed to or from methods.

g

a vector or factor object giving the group for thecorresponding elements of"x".Ignored with a warning if"x" is a list.

p.adjust.method

method for adjusting p values (seep.adjust).

formula

a formula of the formresponse ~ group whereresponse gives the data values andgroup a vector orfactor of the corresponding groups.

data

an optional matrix or data frame (or similar: seemodel.frame) containing the variables in theformulaformula. By default the variables are taken fromenvironment(formula).

subset

an optional vector specifying asubset of observations to be used.

na.action

a function which indicates what should happen whenthe data containNAs. Defaults togetOption("na.action").

Details

For all-pairs comparisons in an one-factorial layoutwith non-normally distributed residuals Lu and Smith'snormal scores transformation can be used prior toan all-pairs comparison test. A total ofm = k(k-1)/2hypotheses can be tested. The null hypothesisH_{ij}: F_i(x) = F_j(x) is tested in the two-tailed testagainst the alternativeA_{ij}: F_i(x) \ne F_j(x), ~~ i \ne j.Forp.adjust.method = "single-step" theTukey's studentized range distribution is used to calculatep-values (seeTukey). Otherwise, thet-distribution is used for the calculation of p-valueswith a latter p-value adjustment asperformed byp.adjust.

Value

A list with class"PMCMR" containing the following components:

method

a character string indicating what type of test was performed.

data.name

a character string giving the name(s) of the data.

statistic

lower-triangle matrix of the estimatedquantiles of the pairwise test statistics.

p.value

lower-triangle matrix of the p-values for the pairwise tests.

alternative

a character string describing the alternative hypothesis.

p.adjust.method

a character string describing the method for p-valueadjustment.

model

a data frame of the input data.

dist

a string that denotes the test distribution.

References

Lu, H., Smith, P. (1979) Distribution of normal scores statisticfor nonparametric one-way analysis of variance.Journal of the American Statistical Association74, 715–722.

See Also

normalScoresTest,normalScoresManyOneTest,normOrder.


Lu-Smith Many-One Comparisons Normal Scores Test

Description

Performs Lu-Smith multiple comparisonnormal scores test with one control.

Usage

normalScoresManyOneTest(x, ...)## Default S3 method:normalScoresManyOneTest(  x,  g,  alternative = c("two.sided", "greater", "less"),  p.adjust.method = c("single-step", p.adjust.methods),  ...)## S3 method for class 'formula'normalScoresManyOneTest(  formula,  data,  subset,  na.action,  alternative = c("two.sided", "greater", "less"),  p.adjust.method = c("single-step", p.adjust.methods),  ...)

Arguments

x

a numeric vector of data values, or a list of numeric datavectors.

...

further arguments to be passed to or from methods.

g

a vector or factor object giving the group for thecorresponding elements of"x".Ignored with a warning if"x" is a list.

alternative

the alternative hypothesis. Defaults totwo.sided.

p.adjust.method

method for adjusting p values (seep.adjust).

formula

a formula of the formresponse ~ group whereresponse gives the data values andgroup a vector orfactor of the corresponding groups.

data

an optional matrix or data frame (or similar: seemodel.frame) containing the variables in theformulaformula. By default the variables are taken fromenvironment(formula).

subset

an optional vector specifying asubset of observations to be used.

na.action

a function which indicates what should happen whenthe data containNAs. Defaults togetOption("na.action").

Details

For many-to-one comparisons in an one-factorial layoutwith non-normally distributed residuals Lu and Smith'snormal scores transformation can be used prior toa many-to-one comparison test. A total ofm = k-1hypotheses can be tested. The null hypothesisH_{i}: F_0(x) = F_i(x) is tested in the two-tailed testagainst the alternativeA_{i}: F_0(x) \ne F_i(x), ~~ 1 \le i \le k-1.Forp.adjust.method = "single-step" themultivariate t distribution is used to calculatep-values (seepmvt). Otherwise, thet-distribution is used for the calculation of p-valueswith a latter p-value adjustment asperformed byp.adjust.

Value

A list with class"PMCMR" containing the following components:

method

a character string indicating what type of test was performed.

data.name

a character string giving the name(s) of the data.

statistic

lower-triangle matrix of the estimatedquantiles of the pairwise test statistics.

p.value

lower-triangle matrix of the p-values for the pairwise tests.

alternative

a character string describing the alternative hypothesis.

p.adjust.method

a character string describing the method for p-valueadjustment.

model

a data frame of the input data.

dist

a string that denotes the test distribution.

Note

Factor labels forg must be assigned in such a way,that they can be increasingly ordered from zero-dosecontrol to the highest dose level, e.g. integers{0, 1, 2, ..., k} or letters {a, b, c, ...}.Otherwise the function may not select the correct valuesfor intended zero-dose control.

It is safer, to i) label the factor levels as given above,and to ii) sort the data according to increasing dose-levelsprior to call the function (seeorder,factor).

References

Lu, H., Smith, P. (1979) Distribution of normal scores statisticfor nonparametric one-way analysis of variance.Journal of the American Statistical Association74, 715–722.

See Also

normalScoresTest,normalScoresAllPairsTest,normOrder,pmvt.

Examples

## Data set PlantGrowth## Global testnormalScoresTest(weight ~ group, data = PlantGrowth)## Lu-Smith's many-one comparison testans <- normalScoresManyOneTest(weight ~ group, data = PlantGrowth, p.adjust.method = "holm")summary(ans)

Lu-Smith Normal Scores Test

Description

Performs the Lu-Smith normal score test

Usage

normalScoresTest(x, ...)## Default S3 method:normalScoresTest(x, g, ...)## S3 method for class 'formula'normalScoresTest(formula, data, subset, na.action, ...)

Arguments

x

a numeric vector of data values, or a list of numeric datavectors.

...

further arguments to be passed to or from methods.

g

a vector or factor object giving the group for thecorresponding elements of"x".Ignored with a warning if"x" is a list.

formula

a formula of the formresponse ~ group whereresponse gives the data values andgroup a vector orfactor of the corresponding groups.

data

an optional matrix or data frame (or similar: seemodel.frame) containing the variables in theformulaformula. By default the variables are taken fromenvironment(formula).

subset

an optional vector specifying asubset of observations to be used.

na.action

a function which indicates what should happen whenthe data containNAs. Defaults togetOption("na.action").

Details

For one-factorial designs with non-normally distributedresiduals the Lu-Smith normal score test can be performed to testthe H_0: F_1(x) = F_2(x) = \ldots = F_k(x) againstthe H_\mathrm{A}: F_i (x) \ne F_j(x) ~ (i \ne j) with at leastone strict inequality. This function is basically a wrapper function topNormScore of the packageSuppDists.

Value

A list with class"htest" containing the following components:

method

a character string indicating what type of test was performed.

data.name

a character string giving the name(s) of the data.

statistic

the estimated quantile of the test statistic.

p.value

the p-value for the test.

parameter

the parameters of the test statistic, if any.

alternative

a character string describing the alternative hypothesis.

estimates

the estimates, if any.

null.value

the estimate under the null hypothesis, if any.

References

Lu, H., Smith, P. (1979) Distribution of normal scores statisticfor nonparametric one-way analysis of variance.Journal of the American Statistical Association74, 715–722.

See Also

vanWaerdenTest,kruskalTest,pNormScore

Examples

normalScoresTest(count ~ spray, data = InsectSprays)

One-Sided Studentized Range Test

Description

Performs Hayter's one-sided studentized rangetest against an ordered alternative for normal datawith equal variances.

Usage

osrtTest(x, ...)## Default S3 method:osrtTest(x, g, alternative = c("greater", "less"), ...)## S3 method for class 'formula'osrtTest(  formula,  data,  subset,  na.action,  alternative = c("greater", "less"),  ...)## S3 method for class 'aov'osrtTest(x, alternative = c("greater", "less"), ...)

Arguments

x

a numeric vector of data values, or a list of numeric datavectors.

...

further arguments to be passed to or from methods.

g

a vector or factor object giving the group for thecorresponding elements of"x".Ignored with a warning if"x" is a list.

alternative

the alternative hypothesis. Defaults togreater.

formula

a formula of the formresponse ~ group whereresponse gives the data values andgroup a vector orfactor of the corresponding groups.

data

an optional matrix or data frame (or similar: seemodel.frame) containing the variables in theformulaformula. By default the variables are taken fromenvironment(formula).

subset

an optional vector specifying asubset of observations to be used.

na.action

a function which indicates what should happen whenthe data containNAs. Defaults togetOption("na.action").

Details

Hayter's one-sided studentized range test (OSRT) can be usedfor testing several treatment levels with a zero control in a balancedone-factorial design with normally distributed variables that have acommon variance. The null hypothesis, H:\mu_i = \mu_j ~~ (i < j)is tested against a simple order alternative,A:\mu_i < \mu_j, with at least one inequality being strict.

The test statistic is calculated as,

\hat{h} = \max_{1 \le i < j \le k} \frac{ \left(\bar{x}_j - \bar{x}_i \right)} {s_{\mathrm{in}} / \sqrt{n}},

withk the number of groups,n = n_1, n_2, \ldots, n_k ands_{\mathrm{in}}^2 the within ANOVA variance. The null hypothesisis rejected, if\hat{h} > h_{k,\alpha,v}, withv = N - kdegree of freedom.

For the unbalanced case with moderate imbalance the test statistic is

\hat{h} = \max_{1 \le i < j \le k} \frac{ \left(\bar{x}_j - \bar{x}_i \right)} {s_{\mathrm{in}} \sqrt{1/n_j + 1/n_i}},

The function does not return p-values. Instead the critical h-valuesas given in the tables of Hayter (1990) for\alpha = 0.05 (one-sided)are looked up according to the number of groups (k) andthe degree of freedoms (v).Non tabulated values are linearly interpolated with the functionapprox.

Value

A list with class"osrt" that contains the following components:

method

a character string indicating what type of test was performed.

data.name

a character string giving the name(s) of the data.

statistic

the estimated statistic(s)

crit.value

critical values for\alpha = 0.05.

alternative

a character string describing the alternative hypothesis.

parameter

the parameter(s) of the test distribution.

dist

a string that denotes the test distribution.

There are print and summary methods available.

Note

Hayter (1990) has tabulated critical h-values for balanced designs only.For some unbalanced designs somek = 3 critical h-valuescan be found in Hayter et al. 2001. ' The function will givea warning for the unbalanced case and returns thecritical valueh_{k,\alpha,v} / \sqrt{2}.

References

Hayter, A. J.(1990) A One-Sided Studentised RangeTest for Testing Against a Simple Ordered Alternative,Journal of the American Statistical Association85, 778–785.

Hayter, A.J., Miwa, T., Liu, W. (2001)Efficient Directional Inference Methodologies for theComparisons of Three Ordered Treatment Effects.J Japan Statist Soc31, 153–174.

See Also

link{hayterStoneTest}MTest

Examples

##md <- aov(weight ~ group, PlantGrowth)anova(md)osrtTest(md)MTest(md)

Page Rank Sum Test

Description

Performs Page's ordered aligned rank sum test.

Usage

pageTest(y, ...)## Default S3 method:pageTest(  y,  groups,  blocks,  alternative = c("two.sided", "greater", "less"),  ...)

Arguments

y

a numeric vector of data values, or a list of numeric datavectors.

groups

a vector or factor object giving the group for thecorresponding elements of"x". Ignored with a warning if"x" is a list.

blocks

a vector or factor object giving the block for thecorresponding elements of"x".Ignored with a warning if"x" is a list.

alternative

the alternative hypothesis.Defaults totwo.sided.

...

further arguments to be passed to or from methods.

Value

A list with class"htest" containing the following components:

method

a character string indicating what type of test was performed.

data.name

a character string giving the name(s) of the data.

statistic

the estimated quantile of the test statistic.

p.value

the p-value for the test.

parameter

the parameters of the test statistic, if any.

alternative

a character string describing the alternative hypothesis.

estimates

the estimates, if any.

null.value

the estimate under the null hypothesis, if any.

References

Page, E. B. (1963) Ordered hypotheses for multiple treatments: Asignificance test for linear ranks,Journal of theAmerican Statistical Association58, 216–230.

Sachs, L. (1997)Angewandte Statistik. Berlin: Springer.

See Also

friedmanTest

Examples

## Sachs (1997), pp. 671 ff.## 9 reviewers (blocks)## assigned ranks to 4 objects (groups).data(reviewers)## See Sachs (1997) p. 677pageTest(reviewers, alternative = "greater")

Plotting PMCMR Objects

Description

Plotting method for objects inheriting from class"PMCMR".

Usage

## S3 method for class 'PMCMR'plot(x, alpha = 0.05, ...)

Arguments

x

an object of class"PMCMR".

alpha

the selected alpha-level. Defaults to 0.05.

...

further arguments for methodboxplot.

Value

A box-whisker plot for each factor level. The range of the whiskers indicatethe extremes (boxplot = x, ..., range=0). Letter symbols are depicted on top of each box.Different letters indicate significantdifferences between groups on the selected level of alpha.

See Also

boxplot

Examples

## data set InsectSpraysans <- kwAllPairsNemenyiTest(count ~ spray, data = InsectSprays)plot(ans)plot(ans, col="red",main="My title", xlab="Spray", "Count")

Plotting mandel Objects

Description

Plotting method for objects inheriting from class"mandel".

Usage

## S3 method for class 'mandel'plot(x, alpha = 0.005, ...)

Arguments

x

an object with class"mandel".

alpha

level of significance. Defaults to0.005.

...

further arguments, currently ignored.

See Also

demo(Pentosan)

Examples

#### Not run: data(Pentosan)md <- mandelkTest(value ~ lab, Pentosan, subset = (material == "B"))plot(md)## End(Not run)

Power Calculations for Balanced Dunnett'sMany-to-One Comparison Test

Description

Compute average per-pair power of Dunnetts's multiple comparisontest with one control.

Usage

power.dunnett.test(n, groups, delta, within.var, sig.level = 0.05)

Arguments

n

Number of observations (per group)

groups

Number of groups (including control)

delta

true difference in means

within.var

Within group variance

sig.level

Significance level (Type I error probability)

Details

The function has implemented the following Eq.to estimate average per-pair power for two-sided tests:

1 - \beta = 1 - t( T_{\alpha \rho v}, v, \mathrm{ncp}) + t(-T_{\alpha \rho v}, v, \mathrm{ncp}),

withT_{\alpha \rho v} the two-sided\alpha quantile ofthe multivariate t-distribution, withv = k (n - 1)degree of freedom,k the number of groupsand correlation matrix\rho_{ij} = 0.5 ~ (i \neq j).

The non-centrality parameter for the non-central student t-distributionis

\mathrm{ncp} = |\Delta| / \sqrt{s_{\mathrm{in}}^2 ~ 2 / n }.

Value

Object of class ‘power.htest’,a list of the arguments(including the computed one) augmented withmethod andnote elements.

Note

The results for power are seed depending.

Source

The Eqs. were taken from Lecture 5,Determining Sample Size,Statistics 514, Fall 2015, Purdue University, IN, USA.

See Also

TDistqmvtpowerMCTests

Examples

set.seed(113)power.dunnett.test(n = 9, groups = 5, delta = 30, within.var = 333.7)## compare with t-test, bonferroni correctedpower.t.test(n = 9, delta = 30, sd = sqrt(333.7),sig.level = 0.05 / 4)## Not run: ## asymptotic Monte-Carlo power analysis set.seed(113) powerMCTests(mu = c(rep(0,4), 30), n = 9, parms = list(mean = 0, sd = sqrt(333.7)), test = "dunnettTest", alternative = "two.sided")## End(Not run)

Power Calculations for Balanced Tukey'sMultiple Comparison Test

Description

Compute average per-pair power of Tukey's test formultiple comparison of means.

Usage

power.tukey.test(n, groups, delta, within.var, sig.level = 0.05)

Arguments

n

number of observations (per group)

groups

number of groups

delta

true difference in means

within.var

within group variance

sig.level

significance level (Type I error probability)

Details

The function has implemented the following Eq.to estimate average per-pair power for two-sided tests:

1 - \beta = 1 - t(q_{\alpha v k}/\sqrt{2}, v, \mathrm{ncp}) + t(-q_{\alpha v k}/\sqrt{2}, v, \mathrm{ncp}),

withq_{\alpha v k} the upper\alpha quantile ofthe studentised range distribution, withv = k (n - 1)degree of freedom andk the number of groups;andt(. ~\mathrm{ncp})the probability function of the non-central student t-distributionwith non-centrality parameter

\mathrm{ncp} = |\Delta| / \sqrt{s_{\mathrm{in}}^2 ~ 2 / n }.

Value

Object of class ‘power.htest’,a list of the arguments(including the computed one) augmented withmethod andnote elements.

Source

The Eqs. were taken from Lecture 5,Determining Sample Size,Statistics 514, Fall 2015, Purdue University, IN, USA.

See Also

TDistTukeypowerMCTests

Examples

power.tukey.test(n = 11, groups = 5, delta = 30, within.var = 333.7)## compare with t-test, Bonferroni-correctionpower.t.test(n = 11, delta = 30, sd = sqrt(333.7),sig.level = 0.05 / 10)## Not run: powerMCTests(mu = c(rep(0,4), 30), n = 11, parms = list(mean = 0,sd = sqrt(333.7)), test = "tukeyTest")## End(Not run)

Power calculations forminimum detectable difference of the Williams' test

Description

Compute the power of a Williams' test,or determine parameters to obtain a target power.

Usage

power.williams.test(n = NULL, k, delta, sd = 1, power = NULL, ...)

Arguments

n

number of observations (per group).

k

number of treatment groups.

delta

clinically meaningful minimal difference(between a treatment group and control).

sd

common standard deviation.

power

power of test (1 minus Type II error probability).

...

further arguments, currently ignored.

Details

Exactly one of the parametersn orpowermust be passed asNULL, and thatparameter is determined from the others.

The function has implemented the following Eq. in order toestimate power (Chow et al. 2008):

1 - \beta = 1 - \Phi \left(T_{K \alpha v} - |\Delta| / \sigma \sqrt{2/n}\right)

with|\Delta| the clinically meaningful minimal difference,T_{K \alpha v} the critical Williams' t-statisticfor\alpha = 0.05,v = \infty degree of freedomand\Phi the probability function of the standard normal function.

The required sample size (balanced design) is estimatedbased on the expression as given by the PASS manual, p. 595-2:

n = 2 \sigma^2 ~ \left(T_{K \alpha v} + z_{\beta} \right)^2 ~ / ~ \Delta^2

Value

Object of class ‘power.htest’, a list of the arguments(including thecomputed one) augmented with method and note elements.

Note

The current function calculates power forsig.level = 0.05significance level (Type I error probability) only (one-sided test).

References

Chow, S.-C., Shao, J., Wan, H., 2008,Sample Size Calculations in Clinical Research, 2nd ed,Chapman & Hall/CRC: Boca Raton, FL.

See Also

optimisewilliamsTest

Examples

## Chow et al. 2008, p. 288 depicts 53 (rounded),## better use ceiling for roundingpower.williams.test(power = 0.8, k = 3, delta = 11, sd = 22)power.williams.test(n = 54, k = 3, delta = 11, sd = 22)## PASS manual example:## up-rounded n values are:## 116, 52, 29, 14, 8 and 5## according to PASS manual, p. 595-5D <- c(10, 15, 20, 30, 40, 50)y <- sapply(D, function(delta) { power.williams.test(power = 0.9, k = 4, delta = delta, sd = 25)$n })ceiling(y)## Not run:  ## compare with power.t.test ## and bonferroni correction power.t.test(power = 0.9, delta = 50, sd = 25, sig.level = 0.05 / 4, alternative = "one.sided")## End(Not run)

Power Simulation for One-Factorial All-Pairs and Many-To-One Comparison Tests

Description

Performs power simulation for one-factorial all-pairs and Many-To-One comparison tests.

Usage

powerMCTests(  mu,  n = 10,  errfn = c("Normal", "Lognormal", "Exponential", "Chisquare", "TDist", "Cauchy",    "Weibull"),  parms = list(mean = 0, sd = 1),  test = c("kwManyOneConoverTest", "kwManyOneDunnTest", "kwManyOneNdwTest",    "vanWaerdenManyOneTest", "normalScoresManyOneTest", "dunnettTest",    "tamhaneDunnettTest", "ManyOneUTest", "chenTest", "kwAllPairsNemenyiTest",    "kwAllPairsDunnTest", "kwAllPairsConoverTest", "normalScoresAllPairsTest",    "vanWaerdenAllPairsTest", "dscfAllPairsTest", "gamesHowellTest", "lsdTest",    "scheffeTest", "tamhaneT2Test", "tukeyTest", "dunnettT3Test", "pairwise.t.test",    "pairwise.wilcox.test", "adManyOneTest", "adAllPairsTest", "bwsManyOneTest",         "bwsAllPairsTest", "welchManyOneTTest"),  alternative = c("two.sided", "greater", "less"),  p.adjust.method = c("single-step", p.adjust.methods),  alpha = 0.05,  FWER = TRUE,  replicates = 1000)

Arguments

mu

numeric vector of group means.

n

number of replicates per group. Ifn is a scalar, thena balanced design is assumed. Otherwise,n must be a vector of samelength asmu.

errfn

the error function. Defaults to"Normal".

parms

a list that denotes the arguments for the error function.Defaults tolist(mean=0, sd=1).

test

the multiple comparison test for which the power analysis isto be performed. Defaults to"kwManyOneConoverTest".

alternative

the alternative hypothesis. Defaults to"two.sided",ignored if the selected error function does not use this argument.

p.adjust.method

method for adjusting p values (seep.adjust).

alpha

the nominal level of Type I Error.

FWER

logical, indicates whether the family-wise error should be computed.Defaults toTRUE.

replicates

the number of Monte Carlo replicates or runs. Defaults to1000.

Details

The linear model of a one-way ANOVA can be written as:

X_{ij} = \mu_i + \epsilon_{ij}

For each Monte Carlo run, the function simulates\epsilon_{ij} based on the given error function andthe corresponding parameters. Then the specified all-pairsor many-to-one comparison test is performed.Finally, several effect sizes (Cohen's f ans R-squared),error rates (per comparison error rate,false discovery rate and familywise error rate)and test powers (any-pair power, average per-pair powerand all-pairs power) are calculated.

Value

An object with classpowerPMCMR.

Examples

## Not run: mu <- c(0, 0, 1, 2)n <- c(5, 4, 5, 5)set.seed(100)powerMCTests(mu, n, errfn="Normal", parms=list(mean=0, sd=1), test="dunnettTest", replicates=1E4)powerMCTests(mu, n, errfn="Normal", parms=list(mean=0, sd=1), test="kwManyOneDunnTest", p.adjust.method = "bonferroni", replicates=1E4)## End(Not run)

Power Simulation for One-Factorial Single Hypothesis Tests

Description

Performs power simulation for one-factorialsingle hypothesis tests.

Usage

powerOneWayTests(  mu,  n = 10,  errfn = c("Normal", "Lognormal", "Exponential", "Chisquare", "TDist", "Cauchy",    "Weibull"),  parms = list(mean = 0, sd = 1),  test = c("kruskalTest", "leTest", "vanWaerdenTest", "normalScoresTest", "spearmanTest",    "cuzickTest", "jonckheereTest", "johnsonTest", "oneway.test", "adKSampleTest",    "bwsKSampleTest", "bwsTrendTest", "mackWolfeTest", "chackoTest", "flignerWolfeTest"),  alternative = c("two.sided", "greater", "less"),  var.equal = TRUE,  dist = NULL,  alpha = 0.05,  FWER = TRUE,  replicates = 1000,  p = NULL)

Arguments

mu

numeric vector of group means.

n

number of replicates per group. Ifn is a scalar, thena balanced design is assumed. Otherwise,n must be a vector of samelength asmu.

errfn

the error function. Defaults to"Normal".

parms

a list that denotes the arguments for the error function.Defaults tolist(mean=0, sd=1).

test

the test for which the power analysis isto be performed. Defaults to"kwManyOneConoverTest".

alternative

the alternative hypothesis. Defaults to"two.sided",ignored if the selected error function does not use this argument.

var.equal

a logical variable indicating whether to treat the variancesin the samples as equal."TRUE", then a simple F test forthe equality of means in a one-way analysis of variance isperformed. If"FALSE", an approximate method of Welch (1951)is used, which generalizes the commonly known 2-sample Welchtest to the case of arbitrarily many samples. Defaults to"TRUE"; only relevant,iftest = "oneway.test", otherwise ignored.

dist

the test distribution. Only relevant forkruskalTest. Defaults's toNULL.

alpha

the nominal level of Type I Error.

FWER

logical, indicates whether the family-wise error should be computed.Defaults toTRUE.

replicates

the number of Monte Carlo replicates or runs. Defaults to1000.

p

the a-priori known peak as an ordinal number of the treatmentgroup including the zero dose level, i.e.p = \{1, \ldots, k\}.Defaults toNULL. Only relevant, if"mackWolfeTest" is selected.

Details

The linear model of a one-way ANOVA can be written as:

X_{ij} = \mu_i + \epsilon_{ij}

For each Monte Carlo run, the function simulates\epsilon_{ij} based on the given error function andthe corresponding parameters. Then the specified test is performed.Finally, Type I and Type II error rates are calculated.

Value

An object with classpowerOneWayPMCMR.

See Also

powerMCTests,pwr.anova.test,power.anova.test

Examples

## Not run: set.seed(12)mu <- c(0, 0, 1, 2)n <- c(5, 4, 5, 5)parms <- list(mean=0, sd=1)powerOneWayTests(mu, n, parms, test = "cuzickTest",alternative = "two.sided", replicates = 1E4)## Compare power estimation for## one-way ANOVA with balanced design## as given by functions## power.anova.test, pwr.anova.test## and powerOneWayTestgroupmeans <- c(120, 130, 140, 150)SEsq <- 500  # within-variancen <- 10k <- length(groupmeans)df <- n * k - kSSQ.E <- SEsq * dfSSQ.A <- n * var(groupmeans) * (k - 1)sd.errfn <- sqrt(SSQ.E / (n * k - 1))R2 <- c("R-squared" = SSQ.A / (SSQ.A + SSQ.E))cohensf <- sqrt(R2 / (1 - R2))names(cohensf) <- "Cohens f"## R stats power functionpower.anova.test(groups = k,                 between.var = var(groupmeans),                 within.var = SEsq,                 n = n)## pwr power functionpwr.anova.test(k = k, n = n, f = cohensf, sig.level=0.05)## this Monte-Carlo based estimationset.seed(200)powerOneWayTests(mu = groupmeans,                 n = n,                 parms = list(mean=0, sd=sd.errfn),                 test = "oneway.test",                 var.equal = TRUE,                 replicates = 5E3)## Compare with effect sizesR2cohensf## End(Not run)

PMCMR Printing

Description

print.PMCMR is thePMCMR method of the genericprint function which prints its argumentand returns itinvisibly (viainvisible(x)).

Usage

## S3 method for class 'PMCMR'print(x, ...)

Arguments

x

an object used to select a method.

...

further arguments. Currently ignored.


gesdTest Printing

Description

print.gesdTest is thegesdTest method of the genericprint function which prints its argumentand returns itinvisibly (viainvisible(x)).

Usage

## S3 method for class 'gesdTest'print(x, ...)

Arguments

x

an object used to select a method.

...

further arguments. Currently ignored.


Mandel Printing

Description

print.mandel is themandel method of the genericprint function which prints its argumentand returns itinvisibly (viainvisible(x)).

Usage

## S3 method for class 'mandel'print(x, ...)

Arguments

x

an object used to select a method.

...

further arguments. Currently ignored.

See Also

mandelhTest,mandelkTest


osrt Printing

Description

print.osrt is theosrt method of the genericprint function which prints its argumentand returns itinvisibly (viainvisible(x)).

Usage

## S3 method for class 'osrt'print(x, ...)

Arguments

x

an object used to select a method.

...

further arguments. Currently ignored.

See Also

summary.osrt


PowerOneWayPMCMR Printing

Description

print.powerOneWayPMCMR is thepowerOneWayPMCMR method of the genericprint function which prints its argumentand returns itinvisibly (viainvisible(x)).

Usage

## S3 method for class 'powerOneWayPMCMR'print(x, ...)

Arguments

x

an object used to select a method.

...

further arguments. Currently ignored.


PowerPMCMR Printing

Description

print.powerPMCMR is thepowerPMCMR method of the genericprint function which prints its argumentand returns itinvisibly (viainvisible(x)).

Usage

## S3 method for class 'powerPMCMR'print(x, ...)

Arguments

x

an object used to select a method.

...

further arguments. Currently ignored.

See Also

powerMCTests,powerOneWayTests


trendPMCMR Printing

Description

print.trendPMCMR is thetrendPMCMR method of the genericprint function which prints its argumentand returns itinvisibly (viainvisible(x)).

Usage

## S3 method for class 'trendPMCMR'print(x, ...)

Arguments

x

an object used to select a method.

...

further arguments. Currently ignored.


Dunnett Distribution

Description

Distribution function and quantile functionfor the distribution of Dunnett's many-to-onecomparisons test.

Usage

qDunnett(p, n0, n)pDunnett(q, n0, n, lower.tail = TRUE)

Arguments

p

vector of probabilities.

n0

sample size for control group.

n

vector of sample sizes for treatment groups.

q

vector of quantiles.

lower.tail

logical; if TRUE (default),probabilities areP[X \leq x] otherwise,P[X > x].

Details

Dunnett's distribution is a special case of themultivariate t distribution.

Let the total sample size beN = n_0 + \sum_i^m n_i, withm thenumber of treatment groups, than the quantileT_{m v \rho \alpha}is calculated withv = N - k degree of freedom andthe correlation\rho

\rho_{ij} = \sqrt{\frac{n_i n_j} {\left(n_i + n_0\right) \left(n_j+ n_0\right)}} ~~ (i \ne j).

The functions determinesm via the length of the inputvectorn.

Quantiles and p-values are computed with the functionsof the packagemvtnorm.

Value

pDunnett gives the distribution function andqDunnett gives its inverse, the quantile function.

Note

The results are seed depending.

See Also

qmvtpmvtdunnettTest

Examples

## Table gives 2.34 for df = 6, m = 2, one-sidedset.seed(112)qval <- qDunnett(p = 0.05, n0 = 3, n = rep(3,2))round(qval, 2)set.seed(112)pDunnett(qval, n0=3, n = rep(3,2), lower.tail = FALSE)## Table gives 2.65 for df = 20, m = 4, two-sidedset.seed(112)qval <- qDunnett(p = 0.05/2, n0 = 5, n = rep(5,4))round(qval, 2)set.seed(112)2 * pDunnett(qval, n0= 5, n = rep(5,4), lower.tail= FALSE)

qPCR Curve Analysis Methods

Description

The data set contains 4 classifiers (blocks), i.e.bias, linearity, precision and resolution, for 11different qPCR analysis methods. The null hypothesisis that there is no preferred ranking of the method resultsper gene for the performance parameters analyzed.The rank scores were obtained by averaging resultsacross a large set of 69 genes in a biomarker data file.

Format

A data frame with 4 observations on the following 11 variables.

Cy0

a numeric vector

LinRegPCR

a numeric vector

Standard_Cq

a numeric vector

PCR_Miner

a numeric vector

MAK2

a numeric vector

LRE_E100

a numeric vector

5PSM

a numeric vector

DART

a numeric vector

FPLM

a numeric vector

LRE_Emax

a numeric vector

FPK_PCR

a numeric vector

Source

Data were taken from Table 2 of Ruijter et al. (2013, p. 38).See also Eisinga et al. (2017, pp. 14–15).

References

Eisinga, R., Heskes, T., Pelzer, B., Te Grotenhuis, M. (2017)Exact p-values for pairwise comparison of Friedman rank sums,with application to comparing classifiers.BMC Bioinformatics, 18:68.

Ruijter, J. M. et al. (2013) Evaluation of qPCR curve analysismethods for reliable biomarker discovery: Bias, resolution,precision, and implications,Methods59, 32–46.


All-Pairs Comparisons forUnreplicated Blocked Data (Quade's All-Pairs Test)

Description

Performs Quade multiple-comparison test for unreplicatedblocked data.

Usage

quadeAllPairsTest(y, ...)## Default S3 method:quadeAllPairsTest(  y,  groups,  blocks,  dist = c("TDist", "Normal"),  p.adjust.method = p.adjust.methods,  ...)

Arguments

y

a numeric vector of data values, or a list of numeric datavectors.

groups

a vector or factor object giving the group for thecorresponding elements of"x". Ignored with a warning if"x" is a list.

blocks

a vector or factor object giving the block for thecorresponding elements of"x".Ignored with a warning if"x" is a list.

dist

the test distribution. Defaults to"TDist".

p.adjust.method

method for adjusting p values(seep.adjust).

...

further arguments to be passed to or from methods.

Details

For all-pairs comparisons of unreplicated blocked dataQuade's test can be applied.A total ofm = k(k-1)/2hypotheses can be tested. The null hypothesisH_{ij}: \theta_i = \theta_j is tested in the two-tailed testagainst the alternativeA_{ij}: \theta_i \ne \theta_j, ~~ i \ne j.

The function has included two methods for approximate p-value estimation:

TDist

p-values are computed from the t distribution

Normal

p-values are computed from the standard normal distribution

If no p-value adjustment is performed (p.adjust.method = "none"),than a simple protected test is recommended, i.e.all-pairs comparisons should only be applied after a significantquade.test. However, any method as implemented inp.adjust.methods can be selected by the user.

Value

A list with class"PMCMR" containing the following components:

method

a character string indicating what type of test was performed.

data.name

a character string giving the name(s) of the data.

statistic

lower-triangle matrix of the estimatedquantiles of the pairwise test statistics.

p.value

lower-triangle matrix of the p-values for the pairwise tests.

alternative

a character string describing the alternative hypothesis.

p.adjust.method

a character string describing the method for p-valueadjustment.

model

a data frame of the input data.

dist

a string that denotes the test distribution.

References

W. J. Conover (1999),Practical nonparametric Statistics,3rd. Edition, Wiley.

N. A. Heckert and J. J. Filliben (2003). NIST Handbook 148:Dataplot Reference Manual, Volume 2: Let Subcommands and Library Functions.National Institute of Standards and Technology Handbook Series, June 2003.

D. Quade (1979), Using weighted rankings in the analysis of completeblocks with additive block effects.Journal of the AmericanStatistical Association, 74, 680-683.

See Also

quade.test,friedmanTest

Examples

## Sachs, 1997, p. 675## Six persons (block) received six different diuretics## (A to F, treatment).## The responses are the Na-concentration (mval)## in the urine measured 2 hours after each treatment.##y <- matrix(c(3.88, 5.64, 5.76, 4.25, 5.91, 4.33, 30.58, 30.14, 16.92,23.19, 26.74, 10.91, 25.24, 33.52, 25.45, 18.85, 20.45,26.67, 4.44, 7.94, 4.04, 4.4, 4.23, 4.36, 29.41, 30.72,32.92, 28.23, 23.35, 12, 38.87, 33.12, 39.15, 28.06, 38.23,26.65),nrow=6, ncol=6,dimnames=list(1:6, LETTERS[1:6]))print(y)## Global testquade.test(y)## All-pairs comparisonsquadeAllPairsTest(y, dist="TDist", p.adjust.method="holm")

Reviewers

Description

9 reviewers (blocks) assigned ranks to 4 objects (groups).

Format

The format is a 9 x 4 Matrix with Friedman type rankings:

rows

reviewers, 1, 2, ..., 9

columns

groups, A, B, ..., D

Source

Sachs (1997), p. 671 ff.

References

Sachs, L. (1997)Angewandte Statistik, New York: Springer.

Examples

data(reviewers)friedmanTest(reviewers)pageTest(reviewers)frdAllPairsExactTest(reviewers, p.adjust = "bonferroni")

Scheffe's Test

Description

Performs Scheffe's all-pairs comparisons test for normally distributeddata with equal group variances.

Usage

scheffeTest(x, ...)## Default S3 method:scheffeTest(x, g, ...)## S3 method for class 'formula'scheffeTest(formula, data, subset, na.action, ...)## S3 method for class 'aov'scheffeTest(x, ...)

Arguments

x

a numeric vector of data values, a list of numeric datavectors or a fitted model object, usually anaov fit.

...

further arguments to be passed to or from methods.

g

a vector or factor object giving the group for thecorresponding elements of"x".Ignored with a warning if"x" is a list.

formula

a formula of the formresponse ~ group whereresponse gives the data values andgroup a vector orfactor of the corresponding groups.

data

an optional matrix or data frame (or similar: seemodel.frame) containing the variables in theformulaformula. By default the variables are taken fromenvironment(formula).

subset

an optional vector specifying asubset of observations to be used.

na.action

a function which indicates what should happen whenthe data containNAs. Defaults togetOption("na.action").

Details

For all-pairs comparisons in an one-factorial layoutwith normally distributed residuals and equal variancesScheffe's test can be performed.LetX_{ij} denote a continuous random variablewith thej-the realization (1 \le j \le n_i)in thei-th group (1 \le i \le k). Furthermore, the totalsample size isN = \sum_{i=1}^k n_i. A total ofm = k(k-1)/2hypotheses can be tested: The null hypothesis isH_{ij}: \mu_i = \mu_j ~~ (i \ne j) is tested against the alternativeA_{ij}: \mu_i \ne \mu_j (two-tailed). Scheffe's all-pairs teststatistics are given by

t_{ij} \frac{\bar{X}_i - \bar{X_j}} {s_{\mathrm{in}} \left(1/n_j + 1/n_i\right)^{1/2}}, ~~ (i \ne j)

withs^2_{\mathrm{in}} the within-group ANOVA variance.The null hypothesis is rejected ift^2_{ij} > F_{v_{1}v_{2}\alpha},withv_1 = k - 1, ~ v_2 = N - k degree of freedom. The p-valuesare computed from theFDist distribution.

Value

A list with class"PMCMR" containing the following components:

method

a character string indicating what type of test was performed.

data.name

a character string giving the name(s) of the data.

statistic

lower-triangle matrix of the estimatedquantiles of the pairwise test statistics.

p.value

lower-triangle matrix of the p-values for the pairwise tests.

alternative

a character string describing the alternative hypothesis.

p.adjust.method

a character string describing the method for p-valueadjustment.

model

a data frame of the input data.

dist

a string that denotes the test distribution.

References

Bortz, J. (1993)Statistik für Sozialwissenschaftler. 4. Aufl.,Berlin: Springer.

Sachs, L. (1997)Angewandte Statistik, New York: Springer.

Scheffe, H. (1953) A Method for Judging all Contrasts in the Analysisof Variance,Biometrika40, 87–110.

See Also

FDist,tukeyTest

Examples

fit <- aov(weight ~ feed, chickwts)shapiro.test(residuals(fit))bartlett.test(weight ~ feed, chickwts)anova(fit)## also works with fitted objects of class aovres <- scheffeTest(fit)summary(res)summaryGroup(res)

Testing against Ordered Alternatives (Shan-Young-Kang Test)

Description

Performs the Shan-Young-Kang test for testing against ordered alternatives.

Usage

shanTest(x, ...)## Default S3 method:shanTest(x, g, alternative = c("greater", "less"), ...)## S3 method for class 'formula'shanTest(  formula,  data,  subset,  na.action,  alternative = c("greater", "less"),  ...)

Arguments

x

a numeric vector of data values, or a list of numeric datavectors.

...

further arguments to be passed to or from methods.

g

a vector or factor object giving the group for thecorresponding elements of"x".Ignored with a warning if"x" is a list.

alternative

the alternative hypothesis.Defaults to"greater".

formula

a formula of the formresponse ~ group whereresponse gives the data values andgroup a vector orfactor of the corresponding groups.

data

an optional matrix or data frame (or similar: seemodel.frame) containing the variables in theformulaformula. By default the variables are taken fromenvironment(formula).

subset

an optional vector specifying asubset of observations to be used.

na.action

a function which indicates what should happen whenthe data containNAs. Defaults togetOption("na.action").

Details

The null hypothesis, H_0: \theta_1 = \theta_2 = \ldots = \theta_kis tested against a simple order hypothesis,H_\mathrm{A}: \theta_1 \le \theta_2 \le \ldots \le\theta_k,~\theta_1 < \theta_k.

LetR_{ij} be the rank ofX_{ij},whereX_{ij} is jointly rankedfrom\left\{1, 2, \ldots, N \right\}, ~~ N = \sum_{i=1}^k n_i,the the test statistic is

S = \sum_{i = 1}^{k-1} \sum_{j = i + 1}^k D_{ij},

with

D_{ij} = \sum_{l = 1}^{n_i} \sum_{m=1}^{n_j} \left(R_{jm} - R_{il} \right)~ \mathrm{I}\left(X_{jm} > X_{il} \right),

where

\mathrm{I}(u) = \left\{ \begin{array}{c} 1, \qquad \forall~ u > 0 \\ 0, \qquad \forall~ u \le 0 \end{array} \right..

The test statistic is asymptotically normal distributed:

z = \frac{S - \mu_{\mathrm{S}}}{\sqrt{s^2_{\mathrm{S}}}}

The p-values are estimated from the standard normal distribution.

Value

A list with class"htest" containing the following components:

method

a character string indicating what type of test was performed.

data.name

a character string giving the name(s) of the data.

statistic

the estimated quantile of the test statistic.

p.value

the p-value for the test.

parameter

the parameters of the test statistic, if any.

alternative

a character string describing the alternative hypothesis.

estimates

the estimates, if any.

null.value

the estimate under the null hypothesis, if any.

Note

The variance estimation (see Theorem 2.1, Shan et al. 2014)can become negative for certain combinations ofN,~n_i,~k\qquad (1 \le i \le k). In these cases the function will returna warning and the returned p-value will beNaN.

Factor labels forg must be assigned in such a way,that they can be increasingly ordered from zero-dosecontrol to the highest dose level, e.g. integers{0, 1, 2, ..., k} or letters {a, b, c, ...}.Otherwise the function may not select the correct valuesfor intended zero-dose control.

It is safer, to i) label the factor levels as given above,and to ii) sort the data according to increasing dose-levelsprior to call the function (seeorder,factor).

References

Shan, G., Young, D., Kang, L. (2014) A New Powerful NonparametricRank Test for Ordered Alternative Problem. PLOS ONE 9, e112924.https://doi.org/10.1371/journal.pone.0112924

See Also

kruskalTest andshirleyWilliamsTestof the packagePMCMRplus,kruskal.test of the librarystats.

Examples

## Example from Sachs (1997, p. 402)x <- c(106, 114, 116, 127, 145,       110, 125, 143, 148, 151,       136, 139, 149, 160, 174)g <- gl(3,5)levels(g) <- c("A", "B", "C")## Chacko's testchackoTest(x, g)## Cuzick's testcuzickTest(x, g)## Johnson-Mehrotra testjohnsonTest(x, g)## Jonckheere-Terpstra testjonckheereTest(x, g)## Le's testleTest(x, g)## Spearman type testspearmanTest(x, g)## Murakami's BWS trend testbwsTrendTest(x, g)## Fligner-Wolfe testflignerWolfeTest(x, g)## Shan-Young-Kang testshanTest(x, g)

Shirley-Williams Test

Description

Performs Shirley's nonparametric equivalent of William's testfor contrasting increasing dose levels of a treatment.

Usage

shirleyWilliamsTest(x, ...)## Default S3 method:shirleyWilliamsTest(  x,  g,  alternative = c("two.sided", "greater", "less"),  method = c("look-up", "boot"),  nperm = 10000,  ...)## S3 method for class 'formula'shirleyWilliamsTest(  formula,  data,  subset,  na.action,  alternative = c("two.sided", "greater", "less"),  method = c("look-up", "boot"),  nperm = 10000,  ...)

Arguments

x

a numeric vector of data values, or a list of numeric datavectors.

...

further arguments to be passed to or from methods.

g

a vector or factor object giving the group for thecorresponding elements of"x".Ignored with a warning if"x" is a list.

alternative

the alternative hypothesis. Defaults totwo.sided

method

a character string specifying the test statistic to use.Defaults to"look-up" that uses published Table values of Williams (1972).

nperm

number of permutations for the asymptotic permutation test.Defaults to1000. Ignored, ifmethod = "look-up".

formula

a formula of the formresponse ~ group whereresponse gives the data values andgroup a vector orfactor of the corresponding groups.

data

an optional matrix or data frame (or similar: seemodel.frame) containing the variables in theformulaformula. By default the variables are taken fromenvironment(formula).

subset

an optional vector specifying asubset of observations to be used.

na.action

a function which indicates what should happen whenthe data containNAs. Defaults togetOption("na.action").

Details

The Shirley-William test is a non-parametric step-down trend test for testing several treatment levelswith a zero control. Let there bek groups including the control and letthe zero dose level be indicated withi = 0 and the highestdose level withi = m, then the followingm = k - 1 hypotheses are tested:

\begin{array}{ll}\mathrm{H}_{m}: \theta_0 = \theta_1 = \ldots = \theta_m, & \mathrm{A}_{m} = \theta_0 \le \theta_1 \le \ldots \theta_m, \theta_0 < \theta_m \\\mathrm{H}_{m-1}: \theta_0 = \theta_1 = \ldots = \theta_{m-1}, & \mathrm{A}_{m-1} = \theta_0 \le \theta_1 \le \ldots \theta_{m-1}, \theta_0 < \theta_{m-1} \\\vdots & \vdots \\\mathrm{H}_{1}: \theta_0 = \theta_1, & \mathrm{A}_{1} = \theta_0 < \theta_1\\\end{array}

LetR_{ij} be the rank ofX_{ij},whereX_{ij} is jointly rankedfrom\left\{1, 2, \ldots, N \right\}, ~~ N = \sum_{i=1}^k n_i,then the test statistic is

t_{i} = \frac{\max_{1 \le u \le i} \left(\sum_{j=u}^i n_j \bar{R}_j / \sum_{j=u}^i n_j \right) - \bar{R}_0}{\sigma_{R_i} \sqrt{1/n_i + 1/n_0}},

with expected variance of

\sigma_{R_i}^2 = N_i \left(N_i + 1 \right) / 12 - T_i,

whereN_i = n_0 + n_1 + n_2 + \ldots + n_i andT_i the ties for thei-th comparison is given by

T_i = \sum_{j=1}^i \frac{t_j^3 - t_j}{12 \left(N_i - 1\right)}.

The procedure starts from the highest dose level (m) to the the lowest dose level (1) andstops at the first non-significant test. The consequent lowest effect doseis the treatment level of the previous test number. This function hasincluded the modifications as recommended by Williams (1986), i.e.the data are re-ranked for each of thei-th comparison.

Ifmethod = "look-up" is selected, the function does not return p-values.Instead the criticalt'_{i,v,\alpha}-valuesas given in the tables of Williams (1972) for\alpha = 0.05 (one-sided)are looked up according to the degree of freedoms (v = \infty) and the order number of thedose level (i) and (potentially) modified according to the given extrapolationcoefficient\beta.

Non tabulated values are linearly interpolated with the functionapprox.

For the comparison of the first dose level (i = 1) with the control, the criticalz-value from the standard normal distribution is used (Normal).

Ifmethod = "boot", the p-values are estimated through an assymptoticboot-strap method. The p-values for H_1are calculated from the t distribution with infinite degree of freedom.

Value

Either a list with class"osrt" or a list with class"PMCMR".

method

a character string indicating what type of test was performed.

data.name

a character string giving the name(s) of the data.

statistic

the estimated statistic(s)

crit.value

critical values for\alpha = 0.05.

alternative

a character string describing the alternative hypothesis.

parameter

the parameter(s) of the test distribution.

dist

a string that denotes the test distribution.

There are print and summary methods available.

A list with class"PMCMR" containing the following components:

method

a character string indicating what type of test was performed.

data.name

a character string giving the name(s) of the data.

statistic

lower-triangle matrix of the estimatedquantiles of the pairwise test statistics.

p.value

lower-triangle matrix of the p-values for the pairwise tests.

alternative

a character string describing the alternative hypothesis.

p.adjust.method

a character string describing the method for p-valueadjustment.

model

a data frame of the input data.

dist

a string that denotes the test distribution.

Note

Formethod = "look-up", only tests on the level of\alpha = 0.05can be performed for alternative hypotheses less or greater.

Formethod = "boot" only the alternative"two.sided" can be calculated.One may increase the number of permutations to e.g.nperm = 10000in order to get more precise p-values. However, this will be on the expense ofcomputational time.

References

Shirley, E., (1977) Nonparametric Equivalent of Williams Test for Contrasting IncreasingDose Levels of a Treatment,Biometrics33, 386–389.

Williams, D. A. (1986) Note on Shirley's nonparametric test for comparingseveral dose levels with a zero-dose control,Biometrics42, 183–186.

See Also

williamsTest

Examples

## Example from Shirley (1977)## Reaction times of mice to stimuli to their tails.x <- c(2.4, 3, 3, 2.2, 2.2, 2.2, 2.2, 2.8, 2, 3, 2.8, 2.2, 3.8, 9.4, 8.4, 3, 3.2, 4.4, 3.2, 7.4, 9.8, 3.2, 5.8, 7.8, 2.6, 2.2, 6.2, 9.4, 7.8, 3.4, 7, 9.8, 9.4, 8.8, 8.8, 3.4, 9, 8.4, 2.4, 7.8)g <- gl(4, 10)## Shirley's test## one-sided test using look-up tableshirleyWilliamsTest(x ~ g, alternative = "greater")## Chacko's global hypothesis test for 'greater'chackoTest(x , g)## post-hoc test, default is standard normal distribution (NPT'-test)summary(chaAllPairsNashimotoTest(x, g, p.adjust.method = "none"))## same but h-distribution (NPY'-test)chaAllPairsNashimotoTest(x, g, dist = "h")## NPM-testNPMTest(x, g)## Hayter-Stone testhayterStoneTest(x, g)## all-pairs comparisonshsAllPairsTest(x, g)

Siegel-Tukey Rank Dispersion Test

Description

Performs Siegel-Tukey non-parametricrank dispersion test.

Usage

siegelTukeyTest(x, ...)## Default S3 method:siegelTukeyTest(  x,  y,  alternative = c("two.sided", "greater", "less"),  median.corr = FALSE,  ...)## S3 method for class 'formula'siegelTukeyTest(formula, data, subset, na.action, ...)

Arguments

x,y

numeric vectors of data values.

...

further arguments to be passed to or from methods.

alternative

a character string specifying thealternative hypothesis, must be one of"two.sided" (default),"greater" or"less".You can specify just the initial letter.

median.corr

logical indicator, whether median correctionshould be performed prior testing. Defaults toFALSE.

formula

a formula of the formresponse ~ group whereresponse gives the data values andgroup a vector orfactor of the corresponding groups.

data

an optional matrix or data frame (or similar: seemodel.frame) containing the variables in theformulaformula. By default the variables are taken fromenvironment(formula).

subset

an optional vector specifying asubset of observations to be used.

na.action

a function which indicates what should happen whenthe data containNAs. Defaults togetOption("na.action").

Details

Letx andy denote two identically and independentlydistributed variables of at least ordinal scale.Further, let\theta, and\lambda denotelocation and scale parameter of the common, but unknown distribution.Then for the two-tailed case, the null hypothesisH:\lambda_x / \lambda_y = 1 | \theta_x = \theta_y istested against the alternative,A:\lambda_x / \lambda_y \ne 1.

The data are combinedly ranked according to Siegel-Tukey.The ranking is done by alternate extremes (rank 1 is lowest,2 and 3 are the two highest, 4 and 5 are the two next lowest, etc.).If no ties are present, the p-values are computed fromthe Wilcoxon distribution (seeWilcoxon).In the case of ties, a tie correction is done accordingto Sachs (1997) and approximate p-values are computedfrom the standard normal distribution (seeNormal).

If both medians differ, one can correct for medians toincrease the specificity of the test.

Value

A list with class"htest" containing the following components:

method

a character string indicating what type of test was performed.

data.name

a character string giving the name(s) of the data.

statistic

the estimated quantile of the test statistic.

p.value

the p-value for the test.

parameter

the parameters of the test statistic, if any.

alternative

a character string describing the alternative hypothesis.

estimates

the estimates, if any.

null.value

the estimate under the null hypothesis, if any.

Source

The algorithm for the Siegel-Tukey ranks wastaken from the code of Daniel Malter. See also theblog from Tal Galili (02/2010,https://www.r-statistics.com/2010/02/siegel-tukey-a-non-parametric-test-for-equality-in-variability-r-code/,accessed 2018-08-05).

References

Sachs, L. (1997),Angewandte Statistik. Berlin: Springer.

Siegel, S., Tukey, J. W. (1960), A nonparametric sum of ranksprocedure for relative spread in unpaired samples,Journal of the American Statistical Association55, 429–455.

Examples

## Sachs, 1997, p. 376A <- c(10.1, 7.3, 12.6, 2.4, 6.1, 8.5, 8.8, 9.4, 10.1, 9.8)B <- c(15.3, 3.6, 16.5, 2.9, 3.3, 4.2, 4.9, 7.3, 11.7, 13.7)siegelTukeyTest(A, B)## from example var.testx <- rnorm(50, mean = 0, sd = 2)y <- rnorm(30, mean = 1, sd = 1)siegelTukeyTest(x, y, median.corr = TRUE)## directional hypothesisA <- c(33, 62, 84, 85, 88, 93, 97)B <- c(4, 16, 48, 51, 66, 98)siegelTukeyTest(A, B, alternative = "greater")

Skillings-Mack Test

Description

Performs Skillings-Mack rank sum test for partially balancedincomplete block designs or partially balanced random block designs.The null hypothesisH_0: \theta_i = \theta_j~~(i \ne j) is tested against thealternative H_{\mathrm{A}}: \theta_i \ne \theta_j, with at leastone inequality beeing strict.

Usage

skillingsMackTest(y, ...)## Default S3 method:skillingsMackTest(y, groups, blocks, ...)

Arguments

y

a numeric vector of data values, or a list of numeric datavectors.

groups

a vector or factor object giving the group for thecorresponding elements of"x". Ignored with a warning if"x" is a list.

blocks

a vector or factor object giving the block for thecorresponding elements of"x".Ignored with a warning if"x" is a list.

...

further arguments to be passed to or from methods.

Details

The function has implemented the test of Skillings and Mack (1981).The test statistic is assymptotically chi-squared distributed withdf = k - 1 degrees of freedom.

Value

A list with class"htest" containing the following components:

method

a character string indicating what type of test was performed.

data.name

a character string giving the name(s) of the data.

statistic

the estimated quantile of the test statistic.

p.value

the p-value for the test.

parameter

the parameters of the test statistic, if any.

alternative

a character string describing the alternative hypothesis.

estimates

the estimates, if any.

null.value

the estimate under the null hypothesis, if any.

Note

The input vector/matrix'y' must containNA.

References

Skillings, J. H., Mack, G.A. (1981) On the use of a Friedman-typestatistic in balanced and unbalanced block designs,Technometrics23, 171–177.

See Also

friedmanTest,durbinTest

Examples

## Example from Hollander and Wolfe 1999,## originally appeared in Brady 1969.x <- cbind(c(3,1,5,2,0,0,0,0),           c(5,3,4,NA,2,2,3,2),           c(15,18,21,6,17,10,8,13))colnames(x) <- c("R", "A", "B")rownames(x) <- 1:8skillingsMackTest(x)## Compare with Friedman Test for CRB## Sachs, 1997, p. 675## Six persons (block) received six different diuretics## (A to F, treatment).## The responses are the Na-concentration (mval)## in the urine measured 2 hours after each treatment. y <- matrix(c(3.88, 5.64, 5.76, 4.25, 5.91, 4.33, 30.58, 30.14, 16.92,23.19, 26.74, 10.91, 25.24, 33.52, 25.45, 18.85, 20.45,26.67, 4.44, 7.94, 4.04, 4.4, 4.23, 4.36, 29.41, 30.72,32.92, 28.23, 23.35, 12, 38.87, 33.12, 39.15, 28.06, 38.23,26.65),nrow=6, ncol=6,dimnames=list(1:6, LETTERS[1:6]))print(y)friedmanTest(y)skillingsMackTest(y)

Student-Newman-Keuls Test

Description

Performs Student-Newman-Keuls all-pairs comparisons test for normally distributeddata with equal group variances.

Usage

snkTest(x, ...)## Default S3 method:snkTest(x, g, ...)## S3 method for class 'formula'snkTest(formula, data, subset, na.action, ...)## S3 method for class 'aov'snkTest(x, ...)

Arguments

x

a numeric vector of data values, a list of numeric datavectors or a fitted model object, usually anaov fit.

...

further arguments to be passed to or from methods.

g

a vector or factor object giving the group for thecorresponding elements of"x".Ignored with a warning if"x" is a list.

formula

a formula of the formresponse ~ group whereresponse gives the data values andgroup a vector orfactor of the corresponding groups.

data

an optional matrix or data frame (or similar: seemodel.frame) containing the variables in theformulaformula. By default the variables are taken fromenvironment(formula).

subset

an optional vector specifying asubset of observations to be used.

na.action

a function which indicates what should happen whenthe data containNAs. Defaults togetOption("na.action").

Details

For all-pairs comparisons in an one-factorial layoutwith normally distributed residuals and equal variancesStudent-Newman-Keuls test can be performed. A total ofm = k(k-1)/2hypotheses can be tested. The null hypothesisH_{ij}: \mu_i(x) = \mu_j(x) is tested in the two-tailed testagainst the alternativeA_{ij}: \mu_i(x) \ne \mu_j(x), ~~ i \ne j.

The p-values are computed from the Tukey-distribution.

Value

A list with class"PMCMR" containing the following components:

method

a character string indicating what type of test was performed.

data.name

a character string giving the name(s) of the data.

statistic

lower-triangle matrix of the estimatedquantiles of the pairwise test statistics.

p.value

lower-triangle matrix of the p-values for the pairwise tests.

alternative

a character string describing the alternative hypothesis.

p.adjust.method

a character string describing the method for p-valueadjustment.

model

a data frame of the input data.

dist

a string that denotes the test distribution.

References

Keuls, M. (1952) The use of the "studentized range"in connection with an analysis of variance,Euphytica1, 112–122.

Newman, D. (1939) The distribution of range insamples from a normal population, expressed interms of an independent estimate of standarddeviation,Biometrika31, 20–30.

Student (1927) Errors of routine analysis,Biometrika19, 151–164.

See Also

Tukey,TukeyHSDtukeyTest

Examples

fit <- aov(weight ~ feed, chickwts)shapiro.test(residuals(fit))bartlett.test(weight ~ feed, chickwts)anova(fit)## also works with fitted objects of class aovres <- snkTest(fit)summary(res)summaryGroup(res)

Testing against Ordered Alternatives (Spearman Test)

Description

Performs a Spearman type test for testing against ordered alternatives.

Usage

spearmanTest(x, ...)## Default S3 method:spearmanTest(x, g, alternative = c("two.sided", "greater", "less"), ...)## S3 method for class 'formula'spearmanTest(  formula,  data,  subset,  na.action,  alternative = c("two.sided", "greater", "less"),  ...)

Arguments

x

a numeric vector of data values, or a list of numeric datavectors.

...

further arguments to be passed to or from methods.

g

a vector or factor object giving the group for thecorresponding elements of"x".Ignored with a warning if"x" is a list.

alternative

the alternative hypothesis. Defaults to"two.sided".

formula

a formula of the formresponse ~ group whereresponse gives the data values andgroup a vector orfactor of the corresponding groups.

data

an optional matrix or data frame (or similar: seemodel.frame) containing the variables in theformulaformula. By default the variables are taken fromenvironment(formula).

subset

an optional vector specifying asubset of observations to be used.

na.action

a function which indicates what should happen whenthe data containNAs. Defaults togetOption("na.action").

Details

A one factorial design for dose finding comprises an ordered factor,.e. treatment with increasing treatment levels.The basic idea is to correlate the ranksR_{ij} with the increasingorder number1 \le i \le k of the treatment levels (Kloke and McKean 2015).More precisely,R_{ij} is correlated with the expected mid-value ranksunder the assumption of strictly increasing median responses.Let the expected mid-value rank of the first group denoteE_1 = \left(n_1 + 1\right)/2.The following expected mid-value ranks areE_j = n_{j-1} + \left(n_j + 1 \right)/2 for2 \le j \le k.The corresponding number of tied values for theith group isn_i. #The sum of squared residuals isD^2 = \sum_{i=1}^k \sum_{j=1}^{n_i} \left(R_{ij} - E_i \right)^2.Consequently, Spearman's rank correlation coefficient can be calculated as:

r_\mathrm{S} = \frac{6 D^2} {\left(N^3 - N\right)- C},

with

C = 1/2 - \sum_{c=1}^r \left(t_c^3 - t_c\right) +1/2 - \sum_{i=1}^k \left(n_i^3 - n_i \right)

andt_c the number of ties of thecth group of ties.Spearman's rank correlation coefficient can be tested forsignificance with at-test.For a one-tailed test the null hypothesis ofr_\mathrm{S} \le 0is rejected and the alternativer_\mathrm{S} > 0 is accepted if

r_\mathrm{S} \sqrt{\frac{\left(n-2\right)}{\left(1 - r_\mathrm{S}\right)}} > t_{v,1-\alpha},

withv = n - 2 degree of freedom.

Value

A list with class"htest" containing the following components:

method

a character string indicating what type of test was performed.

data.name

a character string giving the name(s) of the data.

statistic

the estimated quantile of the test statistic.

p.value

the p-value for the test.

parameter

the parameters of the test statistic, if any.

alternative

a character string describing the alternative hypothesis.

estimates

the estimates, if any.

null.value

the estimate under the null hypothesis, if any.

Note

Factor labels forg must be assigned in such a way,that they can be increasingly ordered from zero-dosecontrol to the highest dose level, e.g. integers{0, 1, 2, ..., k} or letters {a, b, c, ...}.Otherwise the function may not select the correct valuesfor intended zero-dose control.

It is safer, to i) label the factor levels as given above,and to ii) sort the data according to increasing dose-levelsprior to call the function (seeorder,factor).

References

Kloke, J., McKean, J. W. (2015)Nonparametric statistical methods using R.Boca Raton, FL: Chapman & Hall/CRC.

See Also

kruskalTest andshirleyWilliamsTestof the packagePMCMRplus,kruskal.test of the librarystats.

Examples

## Example from Sachs (1997, p. 402)x <- c(106, 114, 116, 127, 145,       110, 125, 143, 148, 151,       136, 139, 149, 160, 174)g <- gl(3,5)levels(g) <- c("A", "B", "C")## Chacko's testchackoTest(x, g)## Cuzick's testcuzickTest(x, g)## Johnson-Mehrotra testjohnsonTest(x, g)## Jonckheere-Terpstra testjonckheereTest(x, g)## Le's testleTest(x, g)## Spearman type testspearmanTest(x, g)## Murakami's BWS trend testbwsTrendTest(x, g)## Fligner-Wolfe testflignerWolfeTest(x, g)## Shan-Young-Kang testshanTest(x, g)

Steel's Many-to-One Rank Test

Description

Performs Steel's non-parametric many-to-one comparisontest for Wilcox-type ranked data.

Usage

steelTest(x, ...)## Default S3 method:steelTest(x, g, alternative = c("greater", "less"), ...)## S3 method for class 'formula'steelTest(  formula,  data,  subset,  na.action,  alternative = c("greater", "less"),  ...)

Arguments

x

a numeric vector of data values, or a list of numeric datavectors.

...

further arguments to be passed to or from methods.

g

a vector or factor object giving the group for thecorresponding elements of"x".Ignored with a warning if"x" is a list.

alternative

the alternative hypothesis. Defaults togreater

formula

a formula of the formresponse ~ group whereresponse gives the data values andgroup a vector orfactor of the corresponding groups.

data

an optional matrix or data frame (or similar: seemodel.frame) containing the variables in theformulaformula. By default the variables are taken fromenvironment(formula).

subset

an optional vector specifying asubset of observations to be used.

na.action

a function which indicates what should happen whenthe data containNAs. Defaults togetOption("na.action").

Details

For many-to-one comparisons (pairwise comparisons with one control)in an one-factorial balanced layout with non-normally distributedresiduals Steels's non-parametric single-step test can be performed.Let there bek treatment levels (excluding the control),thenk pairwise comparisons can be performed betweenthei-th treatment level and the control.H_i: \theta_0 = \theta_i is tested in the one-tailed case (less) againstA_i: \theta_0 > \theta_i, ~~ (1 \le i \le k).

For each control - treatment level the data are ranked in increasing order.The ranksumR_i for thei-th treatment level is comparedto a criticalR value and is significantly(p = 0.05) less,ifR_i \le R. For thealternative = "greater" the sign is changed.

The function does not return p-values. Instead the criticalR-valuesas given in the tables of USEPA (2002) for\alpha = 0.05 (one-sided, less)are looked up according to the balanced sample sizes (n) and the order number of thedose level (i).

Value

A list with class"osrt" that contains the following components:

method

a character string indicating what type of test was performed.

data.name

a character string giving the name(s) of the data.

statistic

the estimated statistic(s)

crit.value

critical values for\alpha = 0.05.

alternative

a character string describing the alternative hypothesis.

parameter

the parameter(s) of the test distribution.

dist

a string that denotes the test distribution.

There are print and summary methods available.

Source

The critical rank sum values were taken from Table E.5 of USEPA (2002).

USEPA (2002)Short-term Methods for Estimating theChronic Toxicity of Effluents and ReceivingWaters to Freshwater Organisms, 4th edition, EPA-821-R-02-013.

Note

Steel's Many-to-One Rank test is only applicable for balanced designs anddirectional hypotheses. An error message will occur, if the design is unbalanced.In the current implementation, only one-sided tests onthe level of\alpha = 0.05 can be performed.

References

Steel, R. G. D. (1959) A multiple comparison rank sum test:treatments versus control,Biometrics15, 560–572.

See Also

wilcox.test,pairwise.wilcox.test,manyOneUTest,flignerWolfeTest,shirleyWilliamsTest,kwManyOneDunnTest,kwManyOneNdwTest,kwManyOneConoverTest,print.osrt,summary.osrt

Examples

## Example from Sachs (1997, p. 402)x <- c(106, 114, 116, 127, 145,110, 125, 143, 148, 151,136, 139, 149, 160, 174)g <- gl(3,5)levels(g) <- c("0", "I", "II")## Steel's TeststeelTest(x ~ g)## Example from USEPA (2002):## Reproduction data from a Ceriodaphnia dubia## 7-day chronic test to several concentrations## of effluent. Dose level 50% is excluded.x <- c(20, 26, 26, 23, 24, 27, 26, 23, 27, 24,13, 15, 14, 13, 23, 26, 0, 25, 26, 27,18, 22, 13, 13, 23, 22, 20, 22, 23, 22,14, 22, 20, 23, 20, 23, 25, 24, 25, 21,9, 0, 9, 7, 6, 10, 12, 14, 9, 13,rep(0,10))g <- gl(6, 10)levels(g) <- c("Control", "3%", "6%", "12%", "25%", "50%")## NOEC at 3%, LOEC at 6%steelTest(x ~ g, subset = g != "50%", alternative = "less")

Steel's k-Treatments vs. Control Test

Description

Performs the non-parametric Steel's testfor simultaneously testing k-treatments vs. one control.

Usage

steelsKSampleTest(x, ...)## Default S3 method:steelsKSampleTest(x, g, alternative = c("two.sided", "greater", "less"), ...)## S3 method for class 'formula'steelsKSampleTest(  formula,  data,  subset,  na.action,  alternative = c("two.sided", "greater", "less"),  ...)

Arguments

x

a numeric vector of data values, or a list of numeric datavectors.

...

further arguments to be passed to or from methods.

g

a vector or factor object giving the group for thecorresponding elements of"x".Ignored with a warning if"x" is a list.

alternative

the alternative hypothesis. Defaults totwo.sided.

formula

a formula of the formresponse ~ group whereresponse gives the data values andgroup a vector orfactor of the corresponding groups.

data

an optional matrix or data frame (or similar: seemodel.frame) containing the variables in theformulaformula. By default the variables are taken fromenvironment(formula).

subset

an optional vector specifying asubset of observations to be used.

na.action

a function which indicates what should happen whenthe data containNAs. Defaults togetOption("na.action").

Details

It testsH: F(i) = F(0), ~ i \le k, againstA: F(i) > F(0) (greater) with at least one inequality being strict.

The function is a wrapper function that callsSteel.test ofthe packagekSamples with argumentmethod = "asymptotic".

Value

A list with class"htest" containing the following components:

method

a character string indicating what type of test was performed.

data.name

a character string giving the name(s) of the data.

statistic

the estimated quantile of the test statistic.

p.value

the p-value for the test.

parameter

the parameters of the test statistic, if any.

alternative

a character string describing the alternative hypothesis.

estimates

the estimates, if any.

null.value

the estimate under the null hypothesis, if any.

References

Scholz, F. and Zhu, A. (2019). kSamples: K-Sample Rank Tests andtheir Combinations. R package version 1.2-9.https://CRAN.R-project.org/package=kSamples

Steel, R. G. D. (1959) A Multiple Comparison Rank Sum Test:Treatments Versus Control,Biometrics15, 560–572.

See Also

Steel.test,flignerWolfeTest

Examples

## Example from Sachs (1997, p. 402)x <- c(106, 114, 116, 127, 145,110, 125, 143, 148, 151,136, 139, 149, 160, 174)g <- gl(3,5)levels(g) <- c("0", "I", "II")## Steel's TeststeelsKSampleTest(x ~ g, alternative = "greater")## Example from USEPA (2002):## Reproduction data from a Ceriodaphnia dubia## 7-day chronic test to several concentrations## of effluent. Dose level 50% is excluded.x <- c(20, 26, 26, 23, 24, 27, 26, 23, 27, 24,13, 15, 14, 13, 23, 26, 0, 25, 26, 27,18, 22, 13, 13, 23, 22, 20, 22, 23, 22,14, 22, 20, 23, 20, 23, 25, 24, 25, 21,9, 0, 9, 7, 6, 10, 12, 14, 9, 13,rep(0,10))g <- gl(6, 10)levels(g) <- c("Control", "3%", "6%", "12%", "25%", "50%")## NOEC at 3%, LOEC at 6%steelsKSampleTest(x ~ g, subset = g != "50%", alternative = "less")

Step Down Trend Tests

Description

Performs step-down trend test procedures for monotone responsesto detect NOEC (LOEC) according to OECD (2006).

Usage

stepDownTrendTest(x, ...)## Default S3 method:stepDownTrendTest(  x,  g,  test = c("leTest", "spearmanTest", "jonckheereTest", "cuzickTest", "chackoTest",    "johnsonTest"),  alternative = c("two.sided", "greater", "less"),  continuity = FALSE,  ...)## S3 method for class 'formula'stepDownTrendTest(  formula,  data,  subset,  na.action,  test = c("leTest", "spearmanTest", "jonckheereTest", "cuzickTest", "chackoTest",    "johnsonTest"),  alternative = c("two.sided", "greater", "less"),  continuity = FALSE,  ...)

Arguments

x

a numeric vector of data values, or a list of numeric datavectors.

...

further arguments to be passed to or from methods.

g

a vector or factor object giving the group for thecorresponding elements of"x".Ignored with a warning if"x" is a list.

test

the trend test that shall be performed. Defaults to"leTest".

alternative

the alternative hypothesis. Defaults to"two.sided".

continuity

logical indicator whether a continuity correctionshall be performed. Only relevant for"jonckheereTest". Defaults toFALSE.

formula

a formula of the formresponse ~ group whereresponse gives the data values andgroup a vector orfactor of the corresponding groups.

data

an optional matrix or data frame (or similar: seemodel.frame) containing the variables in theformulaformula. By default the variables are taken fromenvironment(formula).

subset

an optional vector specifying asubset of observations to be used.

na.action

a function which indicates what should happen whenthe data containNAs. Defaults togetOption("na.action").

Details

According to OECD 2006 one can perform a test for trendon responses from all dose groups including the control.If the trend test is significant at the 0.05 level, thehigh dose group is omitted, and the trendstatistic with the remaining dose groups is re-computeThe procedure is continued until the trend test isfirst non-significant at the 0.05 level, then stop.

The NOEC is the highest doseremaining at this stage. If this test is significantwhen only the lowest dose and control remain,then a NOEC cannot be established from the data.

Value

A list with class"trendPMCMR" containing the following components:

method

a character string indicating what type of test was performed.

data.name

a character string giving the name(s) of the data.

statistic

lower-triangle matrix of the estimatedquantiles of the pairwise test statistics.

p.value

lower-triangle matrix of the p-values for the pairwise tests.

alternative

a character string describing the alternative hypothesis.

p.adjust.method

a character string describing the method for p-valueadjustment.

dist

a string that denotes the test distribution.

Note

Factor labels forg must be assigned in such a way,that they can be increasingly ordered from zero-dosecontrol to the highest dose level, e.g. integers {0, 1, 2, ..., k} orletters {a, b, c, ...}. Otherwise the function may notselect the correct values for intended zero-dose control.

It is safer, to i) label the factor levels as given above,and to ii) sort the data according to increasing dose-levelsprior to call the function (seeorder,factor).

References

OECD (2006)Current Approaches in the StatisticalAnalysis of Ecotoxicity Data: A Guidance to Application,OECD Series on Testing and Assessment52,Paris: Organisation for Econonomic Co-operation and Development.

See Also

leTest,jonckheereTest,spearmanTest,cuzickTest,chackoTest,johnsonTest

Examples

res <- stepDownTrendTest(Y ~ DOSE, data = trout,                         test = "jonckheereTest",                         alternative = "less")## print methodres## summary methodsummary(res)

Summarize an PMCMR Object

Description

Summarize an object of classPMCMR.

Usage

## S3 method for class 'PMCMR'summary(object, ...)

Arguments

object

an object of class"PMCMR".

...

further arguments. Currenly ignored.

Value

A detailed output of all pairwise hypotheses,the test statistics, the corresponding p-values andsymbols that indicates the level of significance.

See Also

print.PMCMR,summaryGroup.

Examples

ans <- vanWaerdenAllPairsTest(count ~ spray, InsectSprays)summary(ans)

Summarize an gesdTest Object

Description

Summarize an object of classgesdTest.

Usage

## S3 method for class 'gesdTest'summary(object, ...)

Arguments

object

an object of class"gesdTest".

...

further arguments. Currenly ignored.


Object Summary for class"mandel"

Description

summary.mandel is a functionused to produce result summaries of the results ofthe functionsmandelhTest ormandelkTest.

Usage

## S3 method for class 'mandel'summary(object, ...)

Arguments

object

an object of class"mandel" forwhich a summary is desired.

...

further arguments. Currently ignored.

See Also

mandelhTest,mandelkTest


Summarize an osrt Object

Description

Summarize an object of classosrt.

Usage

## S3 method for class 'osrt'summary(object, ...)

Arguments

object

an object of class"osrt".

...

further arguments. Currenly ignored.

See Also

print.osrt.


Summarize an trendPMCMR Object

Description

Summarize an object of classtrendPMCMR.

Usage

## S3 method for class 'trendPMCMR'summary(object, ...)

Arguments

object

an object of class"trendPMCMR".

...

further arguments. Currenly ignored.

Value

A detailed output of all pairwise hypotheses,the test statistics, the corresponding p-values andsymbols that indicates the level of significance.

See Also

print.trendPMCMR


Grouped Summary of an PMCMR Object

Description

Performes a grouped summary on an PMCMR object.

Usage

summaryGroup(x, alpha = 0.05, ...)

Arguments

x

an object of class"PMCMR".

alpha

the selected alpha-level. Defaults to 0.05.

...

further arguments. Currently ignored.

Value

Provides summary statistics for each factor leveland a letter symbol, whereas different letters indicatesignificant differences between factor levels based on theselected level of alpha.

See Also

summary.PMCMR


Tamhane-Dunnett Many-to-One Comparison Test

Description

Performs Tamhane-Dunnett's multiple comparisons test with one control.For many-to-one comparisons in an one-factorial layoutwith normally distributed residuals and unequal variancesTamhane-Dunnett's test can be used.LetX_{0j} denote a continuous random variablewith thej-the realization of the control group(1 \le j \le n_0) andX_{ij} thej-the realizationin thei-th treatment group (1 \le i \le k).Furthermore, the total sample size isN = n_0 + \sum_{i=1}^k n_i.A total ofm = k hypotheses can be tested: The null hypothesis isH_{i}: \mu_i = \mu_0 is tested against the alternativeA_{i}: \mu_i \ne \mu_0 (two-tailed). Tamhane-Dunnett's teststatistics are given by

t_{i} \frac{\bar{X}_i - \bar{X_0}} {\left( s^2_0 / n_0 + s^2_i / n_i \right)^{1/2} } ~~ (1 \le i \le k)

The null hypothesis is rejected if|t_{i}| > T_{kv_{i}\rho_{ij}\alpha} (two-tailed),with

v_i = n_0 + n_i - 2

degree of freedom and the correlation

\rho_{ii} = 1, ~ \rho_{ij} = 0 ~ (i \ne j).

The p-values are computed from the multivariate-tdistribution as implemented in the functionpmvt distribution.

Usage

tamhaneDunnettTest(x, ...)## Default S3 method:tamhaneDunnettTest(x, g, alternative = c("two.sided", "greater", "less"), ...)## S3 method for class 'formula'tamhaneDunnettTest(  formula,  data,  subset,  na.action,  alternative = c("two.sided", "greater", "less"),  ...)## S3 method for class 'aov'tamhaneDunnettTest(x, alternative = c("two.sided", "greater", "less"), ...)

Arguments

x

a numeric vector of data values, a list of numeric datavectors or a fitted model object, usually anaov fit.

...

further arguments to be passed to or from methods.

g

a vector or factor object giving the group for thecorresponding elements of"x".Ignored with a warning if"x" is a list.

alternative

the alternative hypothesis.Defaults to"two.sided".

formula

a formula of the formresponse ~ group whereresponse gives the data values andgroup a vector orfactor of the corresponding groups.

data

an optional matrix or data frame (or similar: seemodel.frame) containing the variables in theformulaformula. By default the variables are taken fromenvironment(formula).

subset

an optional vector specifying asubset of observations to be used.

na.action

a function which indicates what should happen whenthe data containNAs. Defaults togetOption("na.action").

Value

A list with class"PMCMR" containing the following components:

method

a character string indicating what type of test was performed.

data.name

a character string giving the name(s) of the data.

statistic

lower-triangle matrix of the estimatedquantiles of the pairwise test statistics.

p.value

lower-triangle matrix of the p-values for the pairwise tests.

alternative

a character string describing the alternative hypothesis.

p.adjust.method

a character string describing the method for p-valueadjustment.

model

a data frame of the input data.

dist

a string that denotes the test distribution.

References

OECD (ed. 2006)Current approaches in the statistical analysisof ecotoxicity data: A guidance to application - Annexes. OECD Serieson testing and assessment, No. 54.

See Also

pmvt,welchManyOneTTest

Examples

set.seed(245)mn <- c(1, 2, 2^2, 2^3, 2^4)x <- rep(mn, each=5) + rnorm(25)g <- factor(rep(1:5, each=5))fit <- aov(x ~ g - 1)shapiro.test(residuals(fit))bartlett.test(x ~ g - 1)anova(fit)## works with object of class aovsummary(tamhaneDunnettTest(fit, alternative = "greater"))

Tamhane's T2 Test

Description

Performs Tamhane's T2 (or T2') all-pairs comparison test for normally distributeddata with unequal variances.

Usage

tamhaneT2Test(x, ...)## Default S3 method:tamhaneT2Test(x, g, welch = TRUE, ...)## S3 method for class 'formula'tamhaneT2Test(formula, data, subset, na.action, welch = TRUE, ...)## S3 method for class 'aov'tamhaneT2Test(x, welch = TRUE, ...)

Arguments

x

a numeric vector of data values, a list of numeric datavectors or a fitted model object, usually anaov fit.

...

further arguments to be passed to or from methods.

g

a vector or factor object giving the group for thecorresponding elements of"x".Ignored with a warning if"x" is a list.

welch

indicates, whether Welch's approximate solution forcalculating the degree of freedom shall be used or, as usually,df = N - 2. Defaults toTRUE.

formula

a formula of the formresponse ~ group whereresponse gives the data values andgroup a vector orfactor of the corresponding groups.

data

an optional matrix or data frame (or similar: seemodel.frame) containing the variables in theformulaformula. By default the variables are taken fromenvironment(formula).

subset

an optional vector specifying asubset of observations to be used.

na.action

a function which indicates what should happen whenthe data containNAs. Defaults togetOption("na.action").

Details

For all-pairs comparisons in an one-factorial layoutwith normally distributed residuals but unequal groups variancesthe T2 test (or T2' test) of Tamhane can be performed.LetX_{ij} denote a continuous random variablewith thej-the realization (1 \le j \le n_i)in thei-th group (1 \le i \le k). Furthermore, the totalsample size isN = \sum_{i=1}^k n_i. A total ofm = k(k-1)/2hypotheses can be tested: The null hypothesis isH_{ij}: \mu_i = \mu_j ~~ (i \ne j) is tested against the alternativeA_{ij}: \mu_i \ne \mu_j (two-tailed). Tamhane T2 all-pairstest statistics are given by

t_{ij} \frac{\bar{X}_i - \bar{X_j}} {\left( s^2_j / n_j + s^2_i / n_i \right)^{1/2}}, ~~ (i \ne j)

withs^2_i the variance of thei-th group.The null hypothesis is rejected (two-tailed) if

\mathrm{Pr} \left\{ |t_{ij}| \ge t_{v_{ij}\alpha'/2} | \mathrm{H} \right\}_{ij} = \alpha.

T2 test uses Welch's approximate solution forcalculating the degree of freedom.

v_{ij} = \frac{\left( s^2_i / n_i + s^2_j / n_j \right)^2} {s^4_i / n^2_i \left(n_i - 1\right) + s^4_j / n^2_j \left(n_j - 1\right)}.

T2' test applies the following approximation for the degree of freedom

v_{ij} = n_i + n_j - 2

The p-values are computed from theTDist-distributionand adjusted according to Dunn-Sidak.

p'_{ij} = \min \left\{1, ~ (1 - (1 - p_{ij})^m)\right\}

Value

A list with class"PMCMR" containing the following components:

method

a character string indicating what type of test was performed.

data.name

a character string giving the name(s) of the data.

statistic

lower-triangle matrix of the estimatedquantiles of the pairwise test statistics.

p.value

lower-triangle matrix of the p-values for the pairwise tests.

alternative

a character string describing the alternative hypothesis.

p.adjust.method

a character string describing the method for p-valueadjustment.

model

a data frame of the input data.

dist

a string that denotes the test distribution.

Note

T2 test is basically an all-pairs pairwise-t-test. Similar resultscan be obtained withpairwise.t.test(..., var.equal=FALSE, p.adjust.mehod = FALSE).

A warning message appearsin the modified T2' test, if none of in Tamhane (1979) given conditionsfor nearly balancedsample sizes and nearly balanced standard errors is true.

Thanks to Sirio Bolaños for his kind suggestion for adding T2' testinto this function.

References

Tamhane, A. C. (1979) A Comparison of Procedures for Multiple Comparisonsof Means with Unequal Variances,Journal of the AmericanStatistical Association74, 471–480.

See Also

dunnettT3TesturyWigginsHochbergTest

Examples

fit <- aov(weight ~ feed, chickwts)shapiro.test(residuals(fit))bartlett.test(weight ~ feed, chickwts) # var1 = varNanova(fit)## also works with fitted objects of class aovres <- tamhaneT2Test(fit)summary(res)summaryGroup(res)res## compare with pairwise.t.testWT <- pairwise.t.test(chickwts$weight,                      chickwts$feed,                      pool.sd = FALSE,                      p.adjust.method = "none")p.adj.sidak <- function(p, m) sapply(p, function(p) min(1, 1 - (1 - p)^m))p.raw <- as.vector(WT$p.value)m <- length(p.raw[!is.na(p.raw)])PADJ <- matrix(ans <- p.adj.sidak(p.raw, m),               nrow = 5, ncol = 5)colnames(PADJ) <- colnames(WT$p.value)rownames(PADJ) <- rownames(WT$p.value)PADJ## same without Welch's approximate solutionsummary(T2b <- tamhaneT2Test(fit, welch = FALSE))

Convert a PMCMR or osrt Object to a Data.Frame

Description

The functions converts a list object of class"PMCMR"or"osrt" into a data.frame.

Usage

toTidy(mod, ...)

Arguments

mod

an object of class"PMCMR","trendPMCMR" or"osrt".

...

further arguments. Currently ignored.

Value

A data.frame.

Author(s)

Indrajeet Patil (via email, 2020-1022),modified by Thorsten Pohlert

Examples

res <- tukeyTest(weight ~ Diet, data = ChickWeight, subset = Time == 21)toTidy(res)

Data from a Dose-Response Experiment with Trouts

Description

This data set contains results from a dose-response experiment with trouts.The experiment was conducted with five doses of 10, 25, 60, 150 and1000 ppm, respectively, plus a zero-dose control. The response istrout weight in mg.

Format

A data frame with 65 observations on the following 5 variables.

CONC

a numeric vector of dose concentration in ppm

DOSE

a factor with levels123456

REPA

a factor with levels12

REPC

a factor with levels12

Y

a numeric vector of trout weight in mg

Source

ENV/JM/MONO(2006)18/ANN, page 113.

References

OECD (ed. 2006)Current approaches in the statistical analysisof ecotoxicity data: A guidance to application - Annexes. OECD Serieson testing and assessment, No. 54, (ENV/JM/MONO(2006)18/ANN).


Tukey's Multiple Comparison Test

Description

Performs Tukey's all-pairs comparisons test for normally distributeddata with equal group variances.

Usage

tukeyTest(x, ...)## Default S3 method:tukeyTest(x, g, ...)## S3 method for class 'formula'tukeyTest(formula, data, subset, na.action, ...)## S3 method for class 'aov'tukeyTest(x, ...)

Arguments

x

a numeric vector of data values, a list of numeric datavectors or a fitted model object, usually anaov fit.

...

further arguments to be passed to or from methods.

g

a vector or factor object giving the group for thecorresponding elements of"x".Ignored with a warning if"x" is a list.

formula

a formula of the formresponse ~ group whereresponse gives the data values andgroup a vector orfactor of the corresponding groups.

data

an optional matrix or data frame (or similar: seemodel.frame) containing the variables in theformulaformula. By default the variables are taken fromenvironment(formula).

subset

an optional vector specifying asubset of observations to be used.

na.action

a function which indicates what should happen whenthe data containNAs. Defaults togetOption("na.action").

Details

For all-pairs comparisons in an one-factorial layoutwith normally distributed residuals and equal variancesTukey's test can be performed.LetX_{ij} denote a continuous random variablewith thej-the realization (1 \le j \le n_i)in thei-th group (1 \le i \le k). Furthermore, the totalsample size isN = \sum_{i=1}^k n_i. A total ofm = k(k-1)/2hypotheses can be tested: The null hypothesis isH_{ij}: \mu_i = \mu_j ~~ (i \ne j) is tested against the alternativeA_{ij}: \mu_i \ne \mu_j (two-tailed). Tukey's all-pairs teststatistics are given by

t_{ij} \frac{\bar{X}_i - \bar{X_j}} {s_{\mathrm{in}} \left(1/n_j + 1/n_i\right)^{1/2}}, ~~ (i \ne j)

withs^2_{\mathrm{in}} the within-group ANOVA variance.The null hypothesis is rejected if|t_{ij}| > q_{vm\alpha} / \sqrt{2},withv = N - k degree of freedom. The p-values are computedfrom theTukey distribution.

Value

A list with class"PMCMR" containing the following components:

method

a character string indicating what type of test was performed.

data.name

a character string giving the name(s) of the data.

statistic

lower-triangle matrix of the estimatedquantiles of the pairwise test statistics.

p.value

lower-triangle matrix of the p-values for the pairwise tests.

alternative

a character string describing the alternative hypothesis.

p.adjust.method

a character string describing the method for p-valueadjustment.

model

a data frame of the input data.

dist

a string that denotes the test distribution.

References

Sachs, L. (1997)Angewandte Statistik, New York: Springer.

Tukey, J. (1949) Comparing Individual Means in the Analysis of Variance,Biometrics5, 99–114.

See Also

Tukey,TukeyHSD

Examples

fit <- aov(weight ~ feed, chickwts)shapiro.test(residuals(fit))bartlett.test(weight ~ feed, chickwts)anova(fit)## also works with fitted objects of class aovres <- tukeyTest(fit)summary(res)summaryGroup(res)

Ury, Wiggins, Hochberg Test

Description

Performs Ury-Wiggins and Hochberg's all-pairs comparison testfor normally distributed data with unequal variances.

Usage

uryWigginsHochbergTest(x, ...)## Default S3 method:uryWigginsHochbergTest(x, g, p.adjust.method = p.adjust.methods, ...)## S3 method for class 'formula'uryWigginsHochbergTest(  formula,  data,  subset,  na.action,  p.adjust.method = p.adjust.methods,  ...)## S3 method for class 'aov'uryWigginsHochbergTest(x, p.adjust.method = p.adjust.methods, ...)

Arguments

x

a numeric vector of data values, a list of numeric datavectors or a fitted model object, usually anaov fit.

...

further arguments to be passed to or from methods.

g

a vector or factor object giving the group for thecorresponding elements of"x".Ignored with a warning if"x" is a list.

p.adjust.method

method for adjusting p values(seep.adjust).

formula

a formula of the formresponse ~ group whereresponse gives the data values andgroup a vector orfactor of the corresponding groups.

data

an optional matrix or data frame (or similar: seemodel.frame) containing the variables in theformulaformula. By default the variables are taken fromenvironment(formula).

subset

an optional vector specifying asubset of observations to be used.

na.action

a function which indicates what should happen whenthe data containNAs. Defaults togetOption("na.action").

Details

For all-pairs comparisons in an one-factorial layoutwith normally distributed residuals but unequal groups variancesthe tests of Ury-Wiggins and Hochberg can be performed.LetX_{ij} denote a continuous random variablewith thej-the realization (1 \le j \le n_i)in thei-th group (1 \le i \le k). Furthermore, the totalsample size isN = \sum_{i=1}^k n_i. A total ofm = k(k-1)/2hypotheses can be tested: The null hypothesis isH_{ij}: \mu_i = \mu_j ~~ (i \ne j) is tested against the alternativeA_{ij}: \mu_i \ne \mu_j (two-tailed). Ury-Wiggins and Hochbergall-pairs test statistics are given by

t_{ij} \frac{\bar{X}_i - \bar{X_j}} {\left( s^2_j / n_j + s^2_i / n_i \right)^{1/2}}, ~~ (i \ne j)

withs^2_i the variance of thei-th group.The null hypothesis is rejected (two-tailed) if

\mathrm{Pr} \left\{ |t_{ij}| \ge t_{v_{ij}\alpha'/2} | \mathrm{H} \right\}_{ij} = \alpha,

with Welch's approximate equation for degree of freedom as

v_{ij} = \frac{\left( s^2_i / n_i + s^2_j / n_j \right)^2} {s^4_i / n^2_i \left(n_i - 1\right) + s^4_j / n^2_j \left(n_j - 1\right)}.

The p-values are computed from theTDist-distribution.The type of test dependson the selected p-value adjustment method (see alsop.adjust):

bonferroni

the Ury-Wiggins test is performed with Bonferroni adjustedp-values.

hochberg

the Hochberg test is performed with Hochberg's adjustedp-values

.

Value

A list with class"PMCMR" containing the following components:

method

a character string indicating what type of test was performed.

data.name

a character string giving the name(s) of the data.

statistic

lower-triangle matrix of the estimatedquantiles of the pairwise test statistics.

p.value

lower-triangle matrix of the p-values for the pairwise tests.

alternative

a character string describing the alternative hypothesis.

p.adjust.method

a character string describing the method for p-valueadjustment.

model

a data frame of the input data.

dist

a string that denotes the test distribution.

References

Hochberg, Y. (1976) A Modification of the T-Method of MultipleComparisons for a One-Way Layout With Unequal Variances,Journal of the American Statistical Association71, 200–203.

Ury, H. and Wiggins, A. D. (1971) Large Sample and OtherMultiple Comparisons Among Means,British Journal ofMathematical and Statistical Psychology24, 174–194.

See Also

dunnettT3TesttamhaneT2TestTDist

Examples

fit <- aov(weight ~ feed, chickwts)shapiro.test(residuals(fit))bartlett.test(weight ~ feed, chickwts) # var1 = varNanova(fit)## also works with fitted objects of class aovres <- uryWigginsHochbergTest(fit)summary(res)summaryGroup(res)

van-der-Waerden's All-Pairs Comparison Normal Scores Test

Description

Performs van-der-Waerden all-pairs comparisonnormal scores test.

Usage

vanWaerdenAllPairsTest(x, ...)## Default S3 method:vanWaerdenAllPairsTest(  x,  g,  p.adjust.method = c("single-step", p.adjust.methods),  ...)## S3 method for class 'formula'vanWaerdenAllPairsTest(  formula,  data,  subset,  na.action,  p.adjust.method = c("single-step", p.adjust.methods),  ...)

Arguments

x

a numeric vector of data values, or a list of numeric datavectors.

...

further arguments to be passed to or from methods.

g

a vector or factor object giving the group for thecorresponding elements of"x".Ignored with a warning if"x" is a list.

p.adjust.method

method for adjusting p values (seep.adjust).

formula

a formula of the formresponse ~ group whereresponse gives the data values andgroup a vector orfactor of the corresponding groups.

data

an optional matrix or data frame (or similar: seemodel.frame) containing the variables in theformulaformula. By default the variables are taken fromenvironment(formula).

subset

an optional vector specifying asubset of observations to be used.

na.action

a function which indicates what should happen whenthe data containNAs. Defaults togetOption("na.action").

Details

For all-pairs comparisons in an one-factorial layoutwith non-normally distributed residuals van-der-Waerden'snormal scores transformation can be used prior toan all-pairs comparison test. A total ofm = k(k-1)/2hypotheses can be tested. The null hypothesisH_{ij}: F_i(x) = F_j(x) is tested in the two-tailed testagainst the alternativeA_{ij}: F_i(x) \ne F_j(x), ~~ i \ne j.Forp.adjust.method = "single-step" theTukey's studentized range distribution is used to calculatep-values (seeTukey). Otherwise, thet-distribution is used for the calculation of p-valueswith a latter p-value adjustment asperformed byp.adjust.

Value

A list with class"PMCMR" containing the following components:

method

a character string indicating what type of test was performed.

data.name

a character string giving the name(s) of the data.

statistic

lower-triangle matrix of the estimatedquantiles of the pairwise test statistics.

p.value

lower-triangle matrix of the p-values for the pairwise tests.

alternative

a character string describing the alternative hypothesis.

p.adjust.method

a character string describing the method for p-valueadjustment.

model

a data frame of the input data.

dist

a string that denotes the test distribution.

References

Conover, W. J., Iman, R. L. (1979)On multiple-comparisons procedures,Tech. Rep. LA-7677-MS, Los Alamos Scientific Laboratory.

van der Waerden, B. L. (1952) Order tests for the two-sampleproblem and their power,Indagationes Mathematicae14, 453–458.

See Also

vanWaerdenTest,vanWaerdenManyOneTest,normOrder.


van-der-Waerden's Many-One Comparisons Normal Scores Test

Description

Performs van-der-Waerden's multiple comparisonnormal scores test with one control.

Usage

vanWaerdenManyOneTest(x, ...)## Default S3 method:vanWaerdenManyOneTest(  x,  g,  alternative = c("two.sided", "greater", "less"),  p.adjust.method = c("single-step", p.adjust.methods),  ...)## S3 method for class 'formula'vanWaerdenManyOneTest(  formula,  data,  subset,  na.action,  alternative = c("two.sided", "greater", "less"),  p.adjust.method = c("single-step", p.adjust.methods),  ...)

Arguments

x

a numeric vector of data values, or a list of numeric datavectors.

...

further arguments to be passed to or from methods.

g

a vector or factor object giving the group for thecorresponding elements of"x".Ignored with a warning if"x" is a list.

alternative

the alternative hypothesis. Defaults totwo.sided.

p.adjust.method

method for adjusting p values (seep.adjust).

formula

a formula of the formresponse ~ group whereresponse gives the data values andgroup a vector orfactor of the corresponding groups.

data

an optional matrix or data frame (or similar: seemodel.frame) containing the variables in theformulaformula. By default the variables are taken fromenvironment(formula).

subset

an optional vector specifying asubset of observations to be used.

na.action

a function which indicates what should happen whenthe data containNAs. Defaults togetOption("na.action").

Details

For many-to-one comparisons in an one-factorial layoutwith non-normally distributed residuals van-der-Waerden'snormal scores transformation can be used prior toa many-to-one comparison test. A total ofm = k-1hypotheses can be tested. The null hypothesisH_{i}: F_0(x) = F_i(x) is tested in the two-tailed testagainst the alternativeA_{i}: F_0(x) \ne F_i(x), ~~ 1 \le i \le k-1.Forp.adjust.method = "single-step" themultivariate t distribution is used to calculatep-values (seepmvt). Otherwise, thet-distribution is used for the calculation of p-valueswith a latter p-value adjustment asperformed byp.adjust.

Value

A list with class"PMCMR" containing the following components:

method

a character string indicating what type of test was performed.

data.name

a character string giving the name(s) of the data.

statistic

lower-triangle matrix of the estimatedquantiles of the pairwise test statistics.

p.value

lower-triangle matrix of the p-values for the pairwise tests.

alternative

a character string describing the alternative hypothesis.

p.adjust.method

a character string describing the method for p-valueadjustment.

model

a data frame of the input data.

dist

a string that denotes the test distribution.

References

Conover, W. J., Iman, R. L. (1979)On multiple-comparisons procedures,Tech. Rep. LA-7677-MS, Los Alamos Scientific Laboratory.

van der Waerden, B. L. (1952) Order tests for the two-sampleproblem and their power,Indagationes Mathematicae14, 453–458.

See Also

vanWaerdenTest,vanWaerdenAllPairsTest,pmvt.

Examples

## Data set PlantGrowth## Global testvanWaerdenTest(weight ~ group, data = PlantGrowth)## van-der-Waerden's many-one comparison testans <- vanWaerdenManyOneTest(weight ~ group,                             data = PlantGrowth,                             p.adjust.method = "holm")summary(ans)

van der Waerden's Normal Scores Test

Description

Performs van der Waerden's normal scores test.

Usage

vanWaerdenTest(x, ...)## Default S3 method:vanWaerdenTest(x, g, ...)## S3 method for class 'formula'vanWaerdenTest(formula, data, subset, na.action, ...)

Arguments

x

a numeric vector of data values, or a list of numeric datavectors.

...

further arguments to be passed to or from methods.

g

a vector or factor object giving the group for thecorresponding elements of"x".Ignored with a warning if"x" is a list.

formula

a formula of the formresponse ~ group whereresponse gives the data values andgroup a vector orfactor of the corresponding groups.

data

an optional matrix or data frame (or similar: seemodel.frame) containing the variables in theformulaformula. By default the variables are taken fromenvironment(formula).

subset

an optional vector specifying asubset of observations to be used.

na.action

a function which indicates what should happen whenthe data containNAs. Defaults togetOption("na.action").

Details

For one-factorial designs with non-normally distributedresiduals van der Waerden's normal scores test can be performed to testthe H_0: F_1(x) = F_2(x) = \ldots = F_k(x) againstthe H_\mathrm{A}: F_i (x) \ne F_j(x)~ (i \ne j) with at leastone strict inequality.

Note

A tie correction is not applied in this function.

References

Conover, W. J., Iman, R. L. (1979)On multiple-comparisons procedures,Tech. Rep. LA-7677-MS, Los Alamos Scientific Laboratory.

van der Waerden, B. L. (1952) Order tests for the two-sampleproblem and their power,Indagationes Mathematicae14, 453–458.

See Also

kruskalTest,normalScoresTest

Examples

vanWaerdenTest(count ~ spray, data = InsectSprays)

Welchs's Many-To-One Comparison Test

Description

Performs Welchs's t-test for multiple comparisons with one control.

Usage

welchManyOneTTest(x, ...)## Default S3 method:welchManyOneTTest(  x,  g,  alternative = c("two.sided", "greater", "less"),  p.adjust.method = p.adjust.methods,  ...)## S3 method for class 'formula'welchManyOneTTest(  formula,  data,  subset,  na.action,  alternative = c("two.sided", "greater", "less"),  p.adjust.method = p.adjust.methods,  ...)## S3 method for class 'aov'welchManyOneTTest(  x,  alternative = c("two.sided", "greater", "less"),  p.adjust.method = p.adjust.methods,  ...)

Arguments

x

a numeric vector of data values, a list of numeric datavectors or a fitted model object, usually anaov fit.

...

further arguments to be passed to or from methods.

g

a vector or factor object giving the group for thecorresponding elements of"x".Ignored with a warning if"x" is a list.

alternative

the alternative hypothesis.Defaults totwo.sided.

p.adjust.method

method for adjusting p values(seep.adjust).

formula

a formula of the formresponse ~ group whereresponse gives the data values andgroup a vector orfactor of the corresponding groups.

data

an optional matrix or data frame (or similar: seemodel.frame) containing the variables in theformulaformula. By default the variables are taken fromenvironment(formula).

subset

an optional vector specifying asubset of observations to be used.

na.action

a function which indicates what should happen whenthe data containNAs. Defaults togetOption("na.action").

Details

For many-to-one comparisons in an one-factorial layoutwith normally distributed residuals and unequal variancesWelch's t-test can be used. A total ofm = k-1hypotheses can be tested. The null hypothesisH_{i}: \mu_0(x) = \mu_i(x) is tested in the two-tailed testagainst the alternativeA_{i}: \mu_0(x) \ne \mu_i(x), ~~ 1 \le i \le k-1.

This function is basically a wrapper function fort.test(..., var.equal = FALSE). The p-values for the testare calculated from the t distributionand can be adusted with any method that is implemented inp.adjust.methods.

Value

A list with class"PMCMR" containing the following components:

method

a character string indicating what type of test was performed.

data.name

a character string giving the name(s) of the data.

statistic

lower-triangle matrix of the estimatedquantiles of the pairwise test statistics.

p.value

lower-triangle matrix of the p-values for the pairwise tests.

alternative

a character string describing the alternative hypothesis.

p.adjust.method

a character string describing the method for p-valueadjustment.

model

a data frame of the input data.

dist

a string that denotes the test distribution.

References

Welch, B. L. (1947) The generalization of "Student's" problemwhen several different population variances are involved,Biometrika34, 28–35.

Welch, B. L. (1951) On the comparison of several mean values:An alternative approach,Biometrika38, 330–336.

See Also

pairwise.t.test,t.test,p.adjust,tamhaneDunnettTest

Examples

set.seed(245)mn <- rep(c(1, 2^(1:4)), each=5)sd <- rep(1:5, each=5)x <- mn + rnorm(25, sd = sd)g <- factor(rep(1:5, each=5))fit <- aov(x ~ g)shapiro.test(residuals(fit))bartlett.test(x ~ g)anova(fit)summary(welchManyOneTTest(fit, alternative = "greater", p.adjust="holm"))

Williams Trend Test

Description

Performs Williams' test for contrasting increasing (decreasing) dose levels of a treatment.

Usage

williamsTest(x, ...)## Default S3 method:williamsTest(x, g, alternative = c("greater", "less"), ...)## S3 method for class 'formula'williamsTest(  formula,  data,  subset,  na.action,  alternative = c("greater", "less"),  ...)## S3 method for class 'aov'williamsTest(x, alternative = c("greater", "less"), ...)

Arguments

x

a numeric vector of data values, or a list of numeric datavectors.

...

further arguments to be passed to or from methods.

g

a vector or factor object giving the group for thecorresponding elements of"x".Ignored with a warning if"x" is a list.

alternative

the alternative hypothesis. Defaults togreater

formula

a formula of the formresponse ~ group whereresponse gives the data values andgroup a vector orfactor of the corresponding groups.

data

an optional matrix or data frame (or similar: seemodel.frame) containing the variables in theformulaformula. By default the variables are taken fromenvironment(formula).

subset

an optional vector specifying asubset of observations to be used.

na.action

a function which indicates what should happen whenthe data containNAs. Defaults togetOption("na.action").

Details

Williams' test is a step-down trend test for testing several treatment levelswith a zero control in a one-factorial design with normally distributederrors of homogeneous variance. Let there bek groups including the control and letthe zero dose level be indicated withi = 0 and the treatmentlevels indicated as1 \le i \le m, then the followingm = k - 1 hypotheses are tested:

\begin{array}{ll}\mathrm{H}_{m}: \bar{x}_0 = m_1 = \ldots = m_m, & \mathrm{A}_{m}: \bar{x}_0 \le m_1 \le \ldots m_m, \bar{x}_0 < m_m \\\mathrm{H}_{m-1}: \bar{x}_0 = m_1 = \ldots = m_{m-1}, & \mathrm{A}_{m-1}: \bar{x}_0 \le m_1 \le \ldots m_{m-1}, \bar{x}_0 < m_{m-1} \\\vdots & \vdots \\\mathrm{H}_{1}: \bar{x}_0 = m_1, & \mathrm{A}_{1}: \bar{x}_0 < m_1,\\\end{array}

wherem_i denotes the isotonic mean of theith dose level group.

William's test bases on a order restriction:

\mu_i^{*} = \max_{1\le u \le i}~\min_{i \le v \le m}~ \sum_{j=u}^v n_j \bar{x}_j^{*} ~/~ \sum_{j=u}^v n_j \qquad (1 \le i \le m),

where\bar{x}_j^* denotes thej-th isotonicmean estimated with isotonic regression using thepool adjacent violators algorithm (PAVA) with the vectorof means\left\{\bar{x}_1, \bar{x}_2, \ldots, \bar{x}_m\right\}^Tand the vector of weights\left\{n_1, n_2, \ldots, n_m\right\}^T.

For the alternative hypothesis of decreasing trend,max and min are interchanged in the above Equation.

Thei-the test statistic is calculated as follows:

\bar{t}_i = \frac{\mu_m^* - \bar{x}_0}{s_{\mathrm{E}} \sqrt{1/n_m - 1/n_0}}

The procedure starts from the highest dose level (m) to the the lowest dose level (1) andstops at the first non-significant test. The consequent lowest effect doseis the treatment level of the previous test number.

The function does not return p-values. Instead the critical t-valuesas given in the tables of Williams (1972) for\alpha = 0.05 (one-sided)are looked up according to the degree of freedoms (v) and the order number of thedose level (i) and (potentially) modified according to the given extrapolationcoefficient\beta.

Non tabulated values are linearly interpolated as recommended by Williams (1972).The functionapprox is used.

For the comparison of the first dose level (i = 1) with the control, the critical t-valuefrom the Student t distribution is used (TDist).

Value

A list with class"osrt" that contains the following components:

method

a character string indicating what type of test was performed.

data.name

a character string giving the name(s) of the data.

statistic

the estimated statistic(s)

crit.value

critical values for\alpha = 0.05.

alternative

a character string describing the alternative hypothesis.

parameter

the parameter(s) of the test distribution.

dist

a string that denotes the test distribution.

There are print and summary methods available.

Source

The source code for the application of the pool adjacent violatorstheorem to calculate the isotonic meanswas taken from the file"pava.f", which is included in thepackageIso:

Rolf Turner (2015). Iso: Functions to Perform Isotonic Regression. Rpackage version 0.0-17.https://CRAN.R-project.org/package=Iso.

The filepava.f is a Ratfor modification of Algorithm AS 206.1:

Bril, G., Dykstra, R., Pillers, C., Robertson, T. (1984)Statistical Algorithms: Algorithm AS 206: IsotonicRegression in Two Independent Variables,Appl. Statist.,34, 352–357.

The Algorith AS 206 is available from StatLibhttps://lib.stat.cmu.edu/apstat/. The Royal Statistical Societyholds the copyright to these routines,but has given its permission for their distribution provided thatno fee is charged.

Note

In the current implementation, only tests on the level of\alpha = 0.05can be performed. The included extrapolation function assumes eithera balanced design, or designs, where the number of replicates in the control excdeeds the number of replicatesin the treatment levels. A warning message appears, if the followingcondition is not met,1 \le n_0 / n_i \le 6 for1 \le i \le m.

References

Williams, D. A. (1971) A test for differences between treatment meanswhen several dose levels are compared with a zero dose control,Biometrics27, 103–117.

Williams, D. A. (1972) The comparison of several dose levels with a zerodose control,Biometrics28, 519–531.

See Also

TDist,approx,print.osrt,summary.osrt

Examples

## Example from Sachs (1997, p. 402)x <- c(106, 114, 116, 127, 145,110, 125, 143, 148, 151,136, 139, 149, 160, 174)g <- gl(3,5)levels(g) <- c("0", "I", "II")## Williams TestwilliamsTest(x ~ g)

[8]ページ先頭

©2009-2025 Movatter.jp