# Package 'coin' - The R Project for Statistical Computing

←

**Page content transcription**

If your browser does not render page correctly, please read the page content below

Package ‘coin’ March 8, 2019 Version 1.3-0 Date 2019-03-04 Title Conditional Inference Procedures in a Permutation Test Framework Description Conditional inference procedures for the general independence problem including two-sample, K-sample (non-parametric ANOVA), correlation, censored, ordered and multivariate problems. Depends R (>= 3.4.0), survival Imports methods, parallel, stats, stats4, utils, libcoin (>= 1.0-0), matrixStats (>= 0.54.0), modeltools (>= 0.2-9), mvtnorm (>= 1.0-5), multcomp Suggests xtable, e1071, vcd, TH.data (>= 1.0-7) LinkingTo libcoin (>= 1.0-0) LazyData yes NeedsCompilation yes ByteCompile yes License GPL-2 URL http://coin.r-forge.r-project.org Author Torsten Hothorn [aut, cre] (), Henric Winell [aut] (), Kurt Hornik [aut] (), Mark A. van de Wiel [aut] (), Achim Zeileis [aut] () Maintainer Torsten Hothorn Repository CRAN Date/Publication 2019-03-08 10:12:52 UTC R topics documented: coin-package . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 alpha . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 1

2 R topics documented: alzheimer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 asat . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 ContingencyTests . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 CorrelationTests . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12 CWD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14 expectation-methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16 glioma . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17 GTSG . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19 hohnloser . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20 IndependenceLinearStatistic-class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21 IndependenceProblem-class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22 IndependenceTest . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23 IndependenceTest-class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27 IndependenceTestProblem-class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30 IndependenceTestStatistic-class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31 jobsatisfaction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33 LocationTests . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34 malformations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39 MarginalHomogeneityTests . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41 MaximallySelectedStatisticsTests . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45 mercuryfish . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48 neuropathy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50 NullDistribution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51 NullDistribution-class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53 NullDistribution-methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55 ocarcinoma . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57 PermutationDistribution-methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58 photocar . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60 PValue-class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61 pvalue-methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62 rotarod . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66 ScaleTests . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67 statistic-methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70 SurvivalTests . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72 SymmetryProblem-class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78 SymmetryTest . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78 SymmetryTests . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82 Transformations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87 treepipit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91 VarCovar-class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92 vision . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93 Index 95

coin-package 3 coin-package General Information on the coin Package Description The coin package provides an implementation of a general framework for conditional inference procedures commonly known as permutation tests. The framework was developed by Strasser and Weber (1999) and is based on a multivariate linear statistic and its conditional expectation, covariance and limiting distribution. These results are utilized to construct tests of independence between two sets of variables. The package does not only provide a flexible implementation of the abstract framework, but also provides a large set of convenience functions implementing well-known as well as lesser-known classical and non-classical test procedures within the framework. Many of the tests presented in prominent text books, such as Hollander and Wolfe (1999) or Agresti (2002), are immediately available or can be implemented without much effort. Examples include linear rank statistics for the two- and K-sample location and scale problem against ordered and unordered alternatives including post-hoc tests for arbitrary contrasts, tests of independence for contingency tables, two- and K- sample tests for censored data, tests of independence between two continuous variables as well as tests of marginal homogeneity and symmetry. Approximations of the exact null distribution via the limiting distribution or conditional Monte Carlo resampling are available for every test procedure, while the exact null distribution is currently available for univariate two-sample problems only. The salient parts of the Strasser-Weber framework are elucidated by Hothorn et al. (2006) and a thorough description of the software implementation is given by Hothorn et al. (2008). Author(s) This package is authored by Torsten Hothorn , Kurt Hornik , Mark A. van de Wiel , Henric Winell and Achim Zeileis . References Agresti, A. (2002). Categorical Data Analysis, Second Edition. Hoboken, New Jersey: John Wiley & Sons. Hollander, M. and Wolfe, D. A. (1999). Nonparametric Statistical Methods, Second Edition. New York: John Wiley & Sons. Hothorn, T., Hornik, K., van de Wiel, M. A. and Zeileis, A. (2006). A Lego system for conditional inference. The American Statistician 60(3), 257–263. doi: 10.1198/000313006X118430 Hothorn, T., Hornik, K., van de Wiel, M. A. and Zeileis, A. (2008). Implementing a class of permutation tests: The coin package. Journal of Statistical Software 28(8), 1–23. doi: 10.18637/ jss.v028.i08 Strasser, H. and Weber, C. (1999). On the asymptotic theory of permutation statistics. Mathematical Methods of Statistics 8(2), 220–250.

4 alpha Examples ## Not run: ## Generate doxygen documentation if you are interested in the internals: ## Download source package into a temporary directory tmpdir

alzheimer 5 References Hothorn, T., Hornik, K., van de Wiel, M. A. and Zeileis, A. (2006). A Lego system for conditional inference. The American Statistician 60(3), 257–263. doi: 10.1198/000313006X118430 Examples ## Boxplots boxplot(elevel ~ alength, data = alpha) ## Asymptotic Kruskal-Wallis test kruskal_test(elevel ~ alength, data = alpha) alzheimer Smoking and Alzheimer’s Disease Description A case-control study of smoking and Alzheimer’s disease. Usage alzheimer Format A data frame with 538 observations on 3 variables. smoking a factor with levels "None", "20" (cigarettes per day). disease a factor with levels "Alzheimer", "Other dementias" and "Other diagnoses". gender a factor with levels "Female" and "Male". Details Subjects with Alzheimer’s disease are compared to two different control groups with respect to smoking history. The data are given in Salib and Hillier (1997, Tab. 4). Source Salib, E. and Hillier, V. (1997). A case-control study of smoking and Alzheimer’s disease. Interna- tional Journal of Geriatric Psychiatry 12(3), 295–300. doi: 10.1002/(SICI)10991166(199703)12:33.0.CO;23 References Hothorn, T., Hornik, K., van de Wiel, M. A. and Zeileis, A. (2006). A Lego system for conditional inference. The American Statistician 60(3), 257–263. doi: 10.1198/000313006X118430

6 asat Examples ## Spineplots op

ContingencyTests 7 Examples ## Proof-of-safety based on ratio of medians (Pflueger and Hothorn, 2002) ## One-sided exact Wilcoxon-Mann-Whitney test wt

8 ContingencyTests subset an optional vector specifying a subset of observations to be used. Defaults to NULL. weights an optional formula of the form ~ w defining integer valued case weights for each observation. Defaults to NULL, implying equal weight for all observations. object an object inheriting from classes "table" or "IndependenceProblem". ... further arguments to be passed to independence_test. Details chisq_test, cmh_test and lbl_test provide the Pearson chi-squared test, the generalized Cochran- Mantel-Haenszel test and the linear-by-linear association test. A general description of these meth- ods is given by Agresti (2002). The null hypothesis of independence, or conditional independence given block, between y and x is tested. If y and/or x are ordered factors, the default scores, 1:nlevels(y) and 1:nlevels(x) respectively, can be altered using the scores argument (see independence_test); this argument can also be used to coerce nominal factors to class "ordered". (lbl_test coerces to class "ordered" un- der any circumstances.) If both y and x are ordered factors, a linear-by-linear association test is computed and the direction of the alternative hypothesis can be specified using the alternative argument. For the Pearson chi-squared test, this extension was given by Yates (1948) who also dis- cussed the situation when either the response or the covariate is an ordered factor; see also Cochran (1954) and Armitage (1955) for the particular case when y is a binary factor and x is ordered. The Mantel-Haenszel statistic (Mantel and Haenszel, 1959) was similarly extended by Mantel (1963) and Landis, Heyman and Koch (1978). The conditional null distribution of the test statistic is used to obtain p-values and an asymptotic approximation of the exact distribution is used by default (distribution = "asymptotic"). Al- ternatively, the distribution can be approximated via Monte Carlo resampling or computed exactly for univariate two-sample problems by setting distribution to "approximate" or "exact" re- spectively. See asymptotic, approximate and exact for details. Value An object inheriting from class "IndependenceTest". Note The exact versions of the Pearson chi-squared test and the generalized Cochran-Mantel-Haenszel test do not necessarily result in the same p-value as Fisher’s exact test (Davis, 1986). References Agresti, A. (2002). Categorical Data Analysis, Second Edition. Hoboken, New Jersey: John Wiley & Sons. Armitage, P. (1955). Tests for linear trends in proportions and frequencies. Biometrics 11(3), 375– 386. doi: 10.2307/3001775 Cochran, W.G. (1954). Some methods for strengthening the common χ2 tests. Biometrics 10(4), 417–451. doi: 10.2307/3001616

ContingencyTests 9 Davis, L. J. (1986). Exact tests for 2 × 2 contingency tables. The American Statistician 40(2), 139–141. doi: 10.1080/00031305.1986.10475377 Landis, J. R., Heyman, E. R. and Koch, G. G. (1978). Average partial association in three-way contingency tables: a review and discussion of alternative tests. International Statistical Review 46(3), 237–254. doi: 10.2307/1402373 Mantel, N. and Haenszel, W. (1959). Statistical aspects of the analysis of data from retrospective studies of disease. Journal of the National Cancer Institute 22(4), 719–748. doi: 10.1093/jnci/ 22.4.719 Mantel, N. (1963). Chi-square tests with one degree of freedom: extensions of the Mantel-Haenszel procedure. Journal of the American Statistical Association 58(303), 690–700. doi: 10.1080/01621459.1963.10500879 Yates, F. (1948). The analysis of contingency tables with groupings based on quantitative characters. Biometrika 35(1/2), 176–181. doi: 10.1093/biomet/35.12.176 Examples ## Example data ## Davis (1986, p. 140) davis

10 ContingencyTests c(21, 2, 15, 3), nrow = 2, byrow = TRUE, dimnames = list( "Treatment" = c("Surgery", "Radiation"), "Cancer" = c("Controlled", "Not Controlled") ) ) cancer

ContingencyTests 11 cochran

12 CorrelationTests ## Asymptotic generalized Cochran-Mantel-Haenszel test (Agresti, p. 297) cmh_test(jobsatisfaction) # CMH = 10.2001 ## Asymptotic generalized Cochran-Mantel-Haenszel test (Agresti, p. 297) ## Note: 'Job.Satisfaction' as ordinal cmh_test(jobsatisfaction, scores = list("Job.Satisfaction" = c(1, 3, 4, 5))) # L^2 = 9.0342 ## Asymptotic linear-by-linear association test (Agresti, p. 297) ## Note: 'Job.Satisfaction' and 'Income' as ordinal (lt

CorrelationTests 13 Arguments formula a formula of the form y ~ x | block where y and x are numeric variables and block is an optional factor for stratification. data an optional data frame containing the variables in the model formula. subset an optional vector specifying a subset of observations to be used. Defaults to NULL. weights an optional formula of the form ~ w defining integer valued case weights for each observation. Defaults to NULL, implying equal weight for all observations. object an object inheriting from class "IndependenceProblem". distribution a character, the conditional null distribution of the test statistic can be approx- imated by its asymptotic distribution ("asymptotic", default) or via Monte Carlo resampling ("approximate"). Alternatively, the functions asymptotic or approximate can be used. Computation of the null distribution can be sup- pressed by specifying "none". ties.method a character, the method used to handle ties: the score generating function ei- ther uses mid-ranks ("mid-ranks", default) or averages the scores of randomly broken ties ("average-scores"). mid.score a character, the score assigned to observations exactly equal to the median: ei- ther 0 ("0", default), 0.5 ("0.5") or 1 ("1"); see median_test. ... further arguments to be passed to independence_test. Details spearman_test, fisyat_test, quadrant_test and koziol_test provide the Spearman correla- tion test, the Fisher-Yates correlation test using van der Waerden scores, the quadrant test and the Koziol-Nemec test. A general description of these methods is given by Hájek, Šidák and Sen (1999, Sec. 4.6). The Koziol-Nemec test was suggested by Koziol and Nemec (1979). For the adjustment of scores for tied values see Hájek, Šidák and Sen (1999, pp. 133–135). The null hypothesis of independence, or conditional independence given block, between y and x is tested. The conditional null distribution of the test statistic is used to obtain p-values and an asymptotic ap- proximation of the exact distribution is used by default (distribution = "asymptotic"). Alterna- tively, the distribution can be approximated via Monte Carlo resampling by setting distribution to "approximate". See asymptotic and approximate for details. Value An object inheriting from class "IndependenceTest". References Hájek, J., Šidák, Z. and Sen, P. K. (1999). Theory of Rank Tests, Second Edition. San Diego: Academic Press. Koziol, J. A. and Nemec, A. F. (1979). On a Cramér-von Mises type statistic for testing bivariate independence. The Canadian Journal of Statistics 7(1), 43–52. doi: 10.2307/3315014

14 CWD Examples ## Asymptotic Spearman test spearman_test(CONT ~ INTG, data = USJudgeRatings) ## Asymptotic Fisher-Yates test fisyat_test(CONT ~ INTG, data = USJudgeRatings) ## Asymptotic quadrant test quadrant_test(CONT ~ INTG, data = USJudgeRatings) ## Asymptotic Koziol-Nemec test koziol_test(CONT ~ INTG, data = USJudgeRatings) CWD Coarse Woody Debris Description Carbon flux on six pieces of wood. Usage CWD Format A data frame with 13 observations on 8 variables. sample2 carbon flux measurement for 2nd piece of wood. sample3 carbon flux measurement for 3rd piece of wood. sample4 carbon flux measurement for 4th piece of wood. sample6 carbon flux measurement for 6th piece of wood. sample7 carbon flux measurement for 7th piece of wood. sample8 carbon flux measurement for 8th piece of wood. trend measurement day (in days from beginning). time date of measurement. Details Coarse woody debris (CWD, dead wood greater than 10 cm in diameter) is a large stock of carbon in tropical forests, yet the flux of carbon out of this pool, via respiration, is poorly resolved (Chambers, Schimel and Nobre, 2001). The heterotrophic process involved in CWD respiration should respond to reductions in moisture availability, which occurs during dry season (Chambers, Schimel and Nobre, 2001). CWD respiration measurements were taken in a tropical forest in west French Guiana, which ex- periences extreme contrasts in wet and dry season (Bonal et al., 2008). An infrared gas analyzer

CWD 15 and a clear chamber sealed to the wood surface were used to measure the flux of carbon out of the wood (Stahl et al., 2011). Measurements were repeated 13 times, from July to November 2011, on six pieces of wood during the transition into and out of the dry season. The aim is to assess if there were shifts in the CWD respiration of any of the pieces in response to the transition into (early August) and out of (late October) the dry season. Zeileis and Hothorn (2013) investigated the six-variate series of CO2 reflux, aiming to find out whether the reflux had changed over the sampling period in at least one of the six wood pieces. Source The coarse woody debris respiration data were kindly provided by Lucy Rowland (School of Geo- Sciences, University of Edinburgh). References Bonal, D., Bosc, A., Ponton, S., Goret, J.-Y., Burban, B., Gross, P., Bonnefond, J.-M., Elbers, J., Longdoz, B., Epron, D., Guehl, J.-M. and Granier, A. (2008). Impact of severe dry season on net ecosystem exchange in the Neotropical rainforest of French Guiana. Global Change Biology 14(8), 1917–1933. doi: 10.1111/j.13652486.2008.01610.x Chambers, J. Q., Schimel, J. P. and Nobre, A. D. (2001). Respiration from coarse wood litter in central Amazon forests. Biogeochemistry 52(2), 115–131. doi: 10.1023/A:1006473530673 Stahl, C., Burban, B., Goret, J.-Y. and Bonal, D. (2011). Seasonal variations in stem CO2 ef- flux in the Neotropical rainforest of French Guiana. Annals of Forest Science 68(4), 771–782. doi: 10.1007/s1359501100742 Zeileis, A. and Hothorn, T. (2013). A toolbox of permutation tests for structural change. Statistical Papers 54(4), 931–954. doi: 10.1007/s0036201305034 Examples ## Zeileis and Hothorn (2013, pp. 942-944) ## Approximative (Monte Carlo) maximally selected statistics CWD[1:6]

16 expectation-methods expectation-methods Extraction of the Expectation, Variance and Covariance of the Linear Statistic Description Methods for extraction of the expectation, variance and covariance of the linear statistic. Usage ## S4 method for signature 'IndependenceLinearStatistic' expectation(object, ...) ## S4 method for signature 'IndependenceTest' expectation(object, ...) ## S4 method for signature 'Variance' variance(object, ...) ## S4 method for signature 'CovarianceMatrix' variance(object, ...) ## S4 method for signature 'IndependenceLinearStatistic' variance(object, ...) ## S4 method for signature 'IndependenceTest' variance(object, ...) ## S4 method for signature 'CovarianceMatrix' covariance(object, ...) ## S4 method for signature 'IndependenceLinearStatistic' covariance(object, ...) ## S4 method for signature 'IndependenceTest' covariance(object, ...) Arguments object an object from which the expectation, variance or covariance of the linear statis- tic can be extracted. ... further arguments (currently ignored). Details The methods expectation, variance and covariance extract the expectation, variance and co- variance, respectively, of the linear statistic. Value The expectation, variance or covariance of the linear statistic extracted from object. A numeric vector or matrix.

glioma 17 Examples ## Example data dta

18 glioma Details The primary endpoint of this small pilot study is survival. Since the survival times are tied, the classical asymptotic logrank test may be inadequate in this setup. Therefore, a permutation test using Monte Carlo resampling was computed in the original paper. The data are taken from Tables 1 and 2 of Grana et al. (2002). Source Grana, C., Chinol, M., Robertson, C., Mazzetta, C., Bartolomei, M., De Cicco, C., Fiorenza, M., Gatti, M., Caliceti, P. and Paganelli, G. (2002). Pretargeted adjuvant radioimmunotherapy with Yttrium-90-biotin in malignant glioma patients: A pilot study. British Journal of Cancer 86(2), 207–212. doi: 10.1038/sj.bjc.6600047 Examples ## Grade III glioma g3

GTSG 19 GTSG Gastrointestinal Tumor Study Group Description A randomized clinical trial in gastric cancer. Usage GTSG Format A data frame with 90 observations on 3 variables. time survival time (days). event status indicator for time: 0 for right-censored observations and 1 otherwise. group a factor with levels "Chemotherapy+Radiation" and "Chemotherapy". Details A clinical trial comparing chemotherapy alone versus a combination of chemotherapy and radiation therapy in the treatment of locally advanced, nonresectable gastric carcinoma. Note There is substantial separation between the estimated survival distributions at 8 to 10 months, but by month 26 the distributions intersect. Source Stablein, D. M., Carter, W. H., Jr. and Novak, J. W. (1981). Analysis of survival data with nonproportional hazard functions. Controlled Clinical Trials 2(2), 149–159. doi: 10.1016/0197- 2456(81)900052 References Moreau, T., Maccario, J., Lellouch, J. and Huber, C. (1992). Weighted log rank statistics for com- paring two distributions. Biometrika 79(1), 195–198. doi: 10.1093/biomet/79.1.195 Shen, W. and Le, C. T. (2000). Linear rank tests for censored survival data. Communications in Statistics – Simulation and Computation 29(1), 21–36. doi: 10.1080/03610910008813599 Tubert-Bitter, P., Kramar, A., Chalé, J. J. and Moureau, T. (1994). Linear rank tests for comparing survival in two groups with crossing hazards. Computational Statistics & Data Analysis 18(5), 547–559. doi: 10.1016/01679473(94)900841

20 hohnloser Examples ## Plot Kaplan-Meier estimates plot(survfit(Surv(time / (365.25 / 12), event) ~ group, data = GTSG), lty = 1:2, ylab = "% Survival", xlab = "Survival Time in Months") legend("topright", lty = 1:2, c("Chemotherapy+Radiation", "Chemotherapy"), bty = "n") ## Asymptotic logrank test logrank_test(Surv(time, event) ~ group, data = GTSG) ## Asymptotic Prentice test logrank_test(Surv(time, event) ~ group, data = GTSG, type = "Prentice") ## Asymptotic test against Weibull-type alternatives (Moreau et al., 1992) moreau_weight

IndependenceLinearStatistic-class 21 Details The data was used by Lausen and Schumacher (1992) to illustrate the use of maximally selected statistics. Source Hohnloser, S. H., Raeder, E. A., Podrid, P. J., Graboys, T. B. and Lown, B. (1987). Predictors of antiarrhythmic drug efficacy in patients with malignant ventricular tachyarrhythmias. American Heart Journal 114(1 Pt 1), 1–7. doi: 10.1016/00028703(87)902997 References Lausen, B. and Schumacher, M. (1992). Maximally selected rank statistics. Biometrics 48(1), 73–85. doi: 10.2307/2532740 Examples ## Asymptotic maximally selected logrank statistics maxstat_test(Surv(time, event) ~ EF, data = hohnloser) IndependenceLinearStatistic-class Class "IndependenceLinearStatistic" Description Objects of class "IndependenceLinearStatistic" represent the linear statistic and the trans- formed and original data structures corresponding to an independence problem. Objects from the Class Objects can be created by calls of the form new("IndependenceLinearStatistic", object, varonly = FALSE, ...) where object is an object of class "IndependenceTestProblem", varonly is a logical indicating that slot covariance (see ‘Slots’) should only contain the diagonal elements of the covariance matrix. Slots linearstatistic: Object of class "numeric". The linear statistic. expectation: Object of class "numeric". The expectation of the linear statistic. covariance: Object of class "VarCovar". The covariance or variance of the linear statistic. xtrans: Object of class "matrix". The transformed x. ytrans: Object of class "matrix". The transformed y.

22 IndependenceProblem-class xtrafo: Object of class "function". The regression function for x. ytrafo: Object of class "function". The influence function for y. x: Object of class "data.frame". The variables x. y: Object of class "data.frame". The variables y. block: Object of class "factor". The block structure. weights: Object of class "numeric". The case weights. Extends Class "IndependenceTestProblem", directly. Class "IndependenceProblem", by class "IndependenceTestProblem", distance 2. Known Subclasses Class "IndependenceTestStatistic", directly. Class "MaxTypeIndependenceTestStatistic", by class "IndependenceTestStatistic", dis- tance 2. Class "QuadTypeIndependenceTestStatistic", by class "IndependenceTestStatistic", dis- tance 2. Class "ScalarIndependenceTestStatistic", by class "IndependenceTestStatistic", distance 2. Methods covariance signature(object = "IndependenceLinearStatistic"): See the documentation for covariance for details. expectation signature(object = "IndependenceLinearStatistic"): See the documentation for expectation for details. initialize signature(.Object = "IndependenceLinearStatistic"): See the documentation for initialize (in package methods) for details. statistic signature(object = "IndependenceLinearStatistic"): See the documentation for statistic for details. variance signature(object = "IndependenceLinearStatistic"): See the documentation for variance for details. IndependenceProblem-class Class "IndependenceProblem" Description Objects of class "IndependenceProblem" represent the data structure corresponding to an inde- pendence problem.

IndependenceTest 23 Objects from the Class Objects can be created by calls of the form new("IndependenceProblem", x, y, block = NULL, weights = NULL, ...) where x and y are data frames containing the variables X and Y respectively, block is an optional factor representing the block structure b and weights is an optional integer vector corresponding to the case weights w. Slots x: Object of class "data.frame". The variables x. y: Object of class "data.frame". The variables y. block: Object of class "factor". The block structure. weights: Object of class "numeric". The case weights. Known Subclasses Class "IndependenceTestProblem", directly. Class "SymmetryProblem", directly. Class "IndependenceLinearStatistic", by class "IndependenceTestProblem", distance 2. Class "IndependenceTestStatistic", by class "IndependenceTestProblem", distance 3. Class "MaxTypeIndependenceTestStatistic", by class "IndependenceTestProblem", distance 4. Class "QuadTypeIndependenceTestStatistic", by class "IndependenceTestProblem", distance 4. Class "ScalarIndependenceTestStatistic", by class "IndependenceTestProblem", distance 4. Methods initialize signature(.Object = "IndependenceProblem"): See the documentation for initialize (in package methods) for details. IndependenceTest General Independence Test Description Testing the independence of two sets of variables measured on arbitrary scales.

24 IndependenceTest Usage ## S3 method for class 'formula' independence_test(formula, data, subset = NULL, weights = NULL, ...) ## S3 method for class 'table' independence_test(object, ...) ## S3 method for class 'IndependenceProblem' independence_test(object, teststat = c("maximum", "quadratic", "scalar"), distribution = c("asymptotic", "approximate", "exact", "none"), alternative = c("two.sided", "less", "greater"), xtrafo = trafo, ytrafo = trafo, scores = NULL, check = NULL, ...) Arguments formula a formula of the form y1 + ... + yq ~ x1 + ... + xp | block where y1, . . . , yq and x1, . . . , xp are measured on arbitrary scales (nominal, ordinal or continuous with or without censoring) and block is an optional factor for stratification. data an optional data frame containing the variables in the model formula. subset an optional vector specifying a subset of observations to be used. Defaults to NULL. weights an optional formula of the form ~ w defining integer valued case weights for each observation. Defaults to NULL, implying equal weight for all observations. object an object inheriting from classes "table" or "IndependenceProblem". teststat a character, the type of test statistic to be applied: either a maximum statistic ("maximum", default), a quadratic form ("quadratic") or a standardized scalar test statistic ("scalar"). distribution a character, the conditional null distribution of the test statistic can be approx- imated by its asymptotic distribution ("asymptotic", default) or via Monte Carlo resampling ("approximate"). Alternatively, the functions asymptotic or approximate can be used. For univariate two-sample problems, "exact" or use of the function exact computes the exact distribution. Computation of the null distribution can be suppressed by specifying "none". It is also possible to specify a function with one argument (an object inheriting from "IndependenceTestStatistic") that returns an object of class "NullDistribution". alternative a character, the alternative hypothesis: either "two.sided" (default), "greater" or "less". xtrafo a function of transformations to be applied to the variables x1, . . . , xp supplied in formula; see ‘Details’. Defaults to trafo. ytrafo a function of transformations to be applied to the variables y1, . . . , yq supplied in formula; see ‘Details’. Defaults to trafo. scores a named list of scores to be attached to ordered factors; see ‘Details’. Defaults to NULL, implying equally spaced scores.

IndependenceTest 25 check a function to be applied to objects of class "IndependenceTest" in order to check for specific properties of the data. Defaults to NULL. ... further arguments to be passed to or from other methods (currently ignored). Details independence_test provides a general independence test for two sets of variables measured on arbitrary scales. This function is based on the general framework for conditional inference proce- dures proposed by Strasser and Weber (1999). The salient parts of the Strasser-Weber framework are elucidated by Hothorn et al. (2006) and a thorough description of the software implementation is given by Hothorn et al. (2008). The null hypothesis of independence, or conditional independence given block, between y1, . . . , yq and x1, . . . , xp is tested. A vector of case weights, e.g., observation counts, can be supplied through the weights argument and the type of test statistic is specified by the teststat argument. Influence and regression func- tions, i.e., transformations of y1, . . . , yq and x1, . . . , xp, are specified by the ytrafo and xtrafo arguments respectively; see trafo for the collection of transformation functions currently avail- able. This allows for implementation of both novel and familiar test statistics, e.g., the Pearson χ2 test, the generalized Cochran-Mantel-Haenszel test, the Spearman correlation test, the Fisher- Pitman permutation test, the Wilcoxon-Mann-Whitney test, the Kruskal-Wallis test and the family of weighted logrank tests for censored data. Furthermore, multivariate extensions such as the mul- tivariate Kruskal-Wallis test (Puri and Sen, 1966, 1971) can be implemented without much effort (see ‘Examples’). If, say, y1 and/or x1 are ordered factors, the default scores, 1:nlevels(y1) and 1:nlevels(x1) respectively, can be altered using the scores argument; this argument can also be used to coerce nominal factors to class "ordered". For example, when y1 is an ordered factor with four levels and x1 is a nominal factor with three levels, scores = list(y1 = c(1, 3:5), x1 = c(1:2, 4)) supplies the scores to be used. For ordered alternatives the scores must be monotonic, but non- montonic scores are also allowed for testing against, e.g., umbrella alternatives. The length of the score vector must be equal to the number of factor levels. The conditional null distribution of the test statistic is used to obtain p-values and an asymptotic approximation of the exact distribution is used by default (distribution = "asymptotic"). Al- ternatively, the distribution can be approximated via Monte Carlo resampling or computed exactly for univariate two-sample problems by setting distribution to "approximate" or "exact" re- spectively. See asymptotic, approximate and exact for details. Value An object inheriting from class "IndependenceTest". Note Starting with coin version 1.1-0, maximum statistics and quadratic forms can no longer be specified using teststat = "maxtype" and teststat = "quadtype" respectively (as was used in versions prior to 0.4-5).

26 IndependenceTest References Hothorn, T., Hornik, K., van de Wiel, M. A. and Zeileis, A. (2006). A Lego system for conditional inference. The American Statistician 60(3), 257–263. doi: 10.1198/000313006X118430 Hothorn, T., Hornik, K., van de Wiel, M. A. and Zeileis, A. (2008). Implementing a class of permutation tests: The coin package. Journal of Statistical Software 28(8), 1–23. doi: 10.18637/ jss.v028.i08 Johnson, W. D., Mercante, D. E. and May, W. L. (1993). A computer package for the multivariate nonparametric rank test in completely randomized experimental designs. Computer Methods and Programs in Biomedicine 40(3), 217–225. doi: 10.1016/01692607(93)90059T Puri, M. L. and Sen, P. K. (1966). On a class of multivariate multisample rank order tests. Sankhya A 28(4), 353–376. Puri, M. L. and Sen, P. K. (1971). Nonparametric Methods in Multivariate Analysis. New York: John Wiley & Sons. Strasser, H. and Weber, C. (1999). On the asymptotic theory of permutation statistics. Mathematical Methods of Statistics 8(2), 220–250. Examples ## One-sided exact van der Waerden (normal scores) test... independence_test(asat ~ group, data = asat, ## exact null distribution distribution = "exact", ## one-sided test alternative = "greater", ## apply normal scores to asat$asat ytrafo = function(data) trafo(data, numeric_trafo = normal_trafo), ## indicator matrix of 1st level of asat$group xtrafo = function(data) trafo(data, factor_trafo = function(x) matrix(x == levels(x)[1], ncol = 1))) ## ...or more conveniently normal_test(asat ~ group, data = asat, ## exact null distribution distribution = "exact", ## one-sided test alternative = "greater") ## Receptor binding assay of benzodiazepines ## Johnson, Mercante and May (1993, Tab. 1) benzos

IndependenceTest-class 27 cortex = c(10.52, 7.52, 4.57, 5.48, 7.16, 12.00, 9.36, 9.35, 11.54, 11.05, 9.92, 13.59, 13.21), hypothalamus = c(19.51, 10.00, 8.27, 10.26, 11.43, 19.13, 14.03, 15.59, 24.87, 14.16, 22.68, 19.93, 29.32), striatum = c( 6.98, 5.07, 3.57, 5.34, 4.57, 8.82, 5.76, 11.72, 6.98, 7.54, 7.66, 9.69, 8.09), hippocampus = c(20.31, 13.20, 8.58, 11.42, 13.79, 23.71, 18.35, 38.52, 21.56, 18.66, 19.24, 27.39, 26.55), treatment = factor(rep(c("Lorazepam", "Alprazolam", "Saline"), c(4, 4, 5))) ) ## Approximative (Monte Carlo) multivariate Kruskal-Wallis test ## Johnson, Mercante and May (1993, Tab. 2) independence_test(cerebellum + brainstem + cortex + hypothalamus + striatum + hippocampus ~ treatment, data = benzos, teststat = "quadratic", distribution = approximate(nresample = 10000), ytrafo = function(data) trafo(data, numeric_trafo = rank_trafo)) # Q = 16.129 IndependenceTest-class Class "IndependenceTest" and its subclasses Description Objects of class "IndependenceTest" and its subclasses "MaxTypeIndependenceTest", "QuadTypeIndependenceTest", "ScalarIndependenceTest" and "ScalarIndependenceTestConfint" represent an independence test including its original and transformed data structure, linear statistic, test statistic and reference distribution. Objects from the Class Objects can be created by calls of the form new("IndependenceTest", ...), new("MaxTypeIndependenceTest", ...), new("QuadTypeIndependenceTest", ...), new("ScalarIndependenceTest", ...)

28 IndependenceTest-class and new("ScalarIndependenceTestConfint", ...). Slots For objects of classes "IndependenceTest", "MaxTypeIndependenceTest", "QuadTypeIndependenceTest", "ScalarIndependenceTest" or "ScalarIndependenceTestConfint": distribution: Object of class "PValue". The reference distribution. statistic: Object of class "IndependenceTestStatistic". The test statistic, the linear statistic, and the transformed and original data structures. estimates: Object of class "list". The estimated parameters. method: Object of class "character". The test method. call: Object of class "call". The matched call. Additionally, for objects of classes "ScalarIndependenceTest" or "ScalarIndependenceTestConfint": parameter: Object of class "character". The tested parameter. nullvalue: Object of class "numeric". The hypothesized value of the null hypothesis. Additionally, for objects of class "ScalarIndependenceTestConfint": confint: Object of class "function". The confidence interval function. conf.level: Object of class "numeric". The confidence level. Extends For objects of classes "MaxTypeIndependenceTest", "QuadTypeIndependenceTest" or "ScalarIndependenceTest": Class "IndependenceTest", directly. For objects of class "ScalarIndependenceTestConfint": Class "ScalarIndependenceTest", directly. Class "IndependenceTest", by class "ScalarIndependenceTest", distance 2. Known Subclasses For objects of class "IndependenceTest": Class "MaxTypeIndependenceTest", directly. Class "QuadTypeIndependenceTest", directly. Class "ScalarIndependenceTest", directly. Class "ScalarIndependenceTestConfint", by class "ScalarIndependenceTest", distance 2. For objects of class "ScalarIndependenceTest": Class "ScalarIndependenceTestConfint", directly.

IndependenceTest-class 29 Methods confint signature(object = "IndependenceTest"): See the documentation for confint-methods (in package stats4) for details. confint signature(object = "ScalarIndependenceTestConfint"): See the documentation for confint-methods (in package stats4) for details. covariance signature(object = "IndependenceTest"): See the documentation for covariance for details. dperm signature(object = "IndependenceTest"): See the documentation for dperm for de- tails. expectation signature(object = "IndependenceTest"): See the documentation for expectation for details. midpvalue signature(object = "IndependenceTest"): See the documentation for midpvalue for details. pperm signature(object = "IndependenceTest"): See the documentation for pperm for de- tails. pvalue signature(object = "IndependenceTest"): See the documentation for pvalue for details. pvalue_interval signature(object = "IndependenceTest"): See the documentation for pvalue_interval for details. qperm signature(object = "IndependenceTest"): See the documentation for qperm for de- tails. rperm signature(object = "IndependenceTest"): See the documentation for rperm for de- tails. show signature(object = "IndependenceTest"): See the documentation for show (in package methods) for details. show signature(object = "MaxTypeIndependenceTest"): See the documentation for show (in package methods) for details. show signature(object = "QuadTypeIndependenceTest"): See the documentation for show (in package methods) for details. show signature(object = "ScalarIndependenceTest"): See the documentation for show (in package methods) for details. show signature(object = "ScalarIndependenceTestConfint"): See the documentation for show (in package methods) for details. size signature(object = "IndependenceTest"): See the documentation for size for details. statistic signature(object = "IndependenceTest"): See the documentation for statistic for details. support signature(object = "IndependenceTest"): See the documentation for support for details. variance signature(object = "IndependenceTest"): See the documentation for variance for details.

30 IndependenceTestProblem-class IndependenceTestProblem-class Class "IndependenceTestProblem" Description Objects of class "IndependenceTestProblem" represent the transformed and original data struc- tures corresponding to an independence problem. Objects from the Class Objects can be created by calls of the form new("IndependenceTestProblem", object, xtrafo = trafo, ytrafo = trafo, ...) where object is an object of class "IndependenceProblem", xtrafo is the regression function g(X) and ytrafo is the influence function h(Y). Slots xtrans: Object of class "matrix". The transformed x. ytrans: Object of class "matrix". The transformed y. xtrafo: Object of class "function". The regression function for x. ytrafo: Object of class "function". The influence function for y. x: Object of class "data.frame". The variables x. y: Object of class "data.frame". The variables y. block: Object of class "factor". The block structure. weights: Object of class "numeric". The case weights. Extends Class "IndependenceProblem", directly. Known Subclasses Class "IndependenceLinearStatistic", directly. Class "IndependenceTestStatistic", by class "IndependenceLinearStatistic", distance 2. Class "MaxTypeIndependenceTestStatistic", by class "IndependenceTestStatistic", dis- tance 3. Class "QuadTypeIndependenceTestStatistic", by class "IndependenceTestStatistic", dis- tance 3. Class "ScalarIndependenceTestStatistic", by class "IndependenceTestStatistic", distance 3.

IndependenceTestStatistic-class 31 Methods initialize signature(.Object = "IndependenceTestProblem"): See the documentation for initialize (in package methods) for details. IndependenceTestStatistic-class Class "IndependenceTestStatistic" and its subclasses Description Objects of class "IndependenceTestStatistic" and its subclasses "MaxTypeIndependenceTestStatistic", "QuadTypeIndependenceTestStatistic" and "ScalarIndependenceTestStatistic" represent the test statistic, the linear statistic, and the transformed and original data structures corresponding to an independence problem. Objects from the Class Class "IndependenceTestStatistic" is a virtual class, so objects cannot be created from it di- rectly. Objects can be created by calls of the form new("MaxTypeIndependenceTestStatistic", object, alternative = c("two.sided", "less", "greater"), ...), new("QuadTypeIndependenceTestStatistic", object, paired = FALSE, ...) and new("ScalarIndependenceTestStatistic", object, alternative = c("two.sided", "less", "greater"), paired = FALSE, ...) where object is an object of class "IndependenceLinearStatistic", alternative is a character specifying the direction of the alternative hypothesis and paired is a logical indicating that paired data have been transformed in such a way that the (unstandardized) linear statistic is the sum of the absolute values of the positive differences between the paired observations. Slots For objects of classes "IndependenceTestStatistic", "MaxTypeIndependenceTestStatistic", "QuadTypeIndependenceTestStatistic" or "ScalarIndependenceTestStatistic": teststatistic: Object of class "numeric". The test statistic. standardizedlinearstatistic: Object of class "numeric". The standardized linear statistic. linearstatistic: Object of class "numeric". The linear statistic. expectation: Object of class "numeric". The expectation of the linear statistic. covariance: Object of class "VarCovar". The covariance or variance of the linear statistic.

32 IndependenceTestStatistic-class xtrans: Object of class "matrix". The transformed x. ytrans: Object of class "matrix". The transformed y. xtrafo: Object of class "function". The regression function for x. ytrafo: Object of class "function". The influence function for y. x: Object of class "data.frame". The variables x. y: Object of class "data.frame". The variables y. block: Object of class "factor". The block structure. weights: Object of class "numeric". The case weights. Additionally, for objects of classes "MaxTypeIndependenceTest" or "ScalarIndependenceTest": alternative: Object of class "character". The direction of the alternative hypothesis. Additionally, for objects of class "QuadTypeIndependenceTest": covarianceplus: Object of class "matrix". The Moore-Penrose inverse of the covariance matrix. df: Object of class "numeric". The rank of the covariance matrix. Additionally, for objects of classes "QuadTypeIndependenceTest" or "ScalarIndependenceTest": paired: Object of class "logical". The indicator for paired test statistics. Extends For objects of class "IndependenceTestStatistic": Class "IndependenceLinearStatistic", directly. Class "IndependenceTestProblem", by class "IndependenceLinearStatistic", distance 2. Class "IndependenceProblem", by class "IndependenceLinearStatistic", distance 3. For objects of classes "MaxTypeIndependenceTestStatistic", "QuadTypeIndependenceTestStatistic" or "ScalarIndependenceTestStatistic": Class "IndependenceTestStatistic", directly. Class "IndependenceLinearStatistic", by class "IndependenceTestStatistic", distance 2. Class "IndependenceTestProblem", by class "IndependenceTestStatistic", distance 3. Class "IndependenceProblem", by class "IndependenceTestStatistic", distance 4. Known Subclasses For objects of class "IndependenceTestStatistic": Class "MaxTypeIndependenceTestStatistic", directly. Class "QuadTypeIndependenceTestStatistic", directly. Class "ScalarIndependenceTestStatistic", directly. Methods ApproxNullDistribution signature(object = "MaxTypeIndependenceTestStatistic"): See the documentation for ApproxNullDistribution for details. ApproxNullDistribution signature(object = "QuadTypeIndependenceTestStatistic"): See the documentation for ApproxNullDistribution for details.

jobsatisfaction 33 ApproxNullDistribution signature(object = "ScalarIndependenceTestStatistic"): See the documentation for ApproxNullDistribution for details. AsymptNullDistribution signature(object = "MaxTypeIndependenceTestStatistic"): See the documentation for AsymptNullDistribution for details. AsymptNullDistribution signature(object = "QuadTypeIndependenceTestStatistic"): See the documentation for AsymptNullDistribution for details. AsymptNullDistribution signature(object = "ScalarIndependenceTestStatistic"): See the documentation for AsymptNullDistribution for details. ExactNullDistribution signature(object = "QuadTypeIndependenceTestStatistic"): See the documentation for ExactNullDistribution for details. ExactNullDistribution signature(object = "ScalarIndependenceTestStatistic"): See the documentation for ExactNullDistribution for details. initialize signature(.Object = "MaxTypeIndependenceTestStatistic"): See the documen- tation for initialize (in package methods) for details. initialize signature(.Object = "QuadTypeIndependenceTestStatistic"): See the docu- mentation for initialize (in package methods) for details. initialize signature(.Object = "ScalarIndependenceTestStatistic"): See the documenta- tion for initialize (in package methods) for details. statistic signature(object = "IndependenceTestStatistic"): See the documentation for statistic for details. jobsatisfaction Income and Job Satisfaction Description Income and job satisfaction by gender. Usage jobsatisfaction Format A contingency table with 104 observations on 3 variables. Income a factor with levels "25000". Job.Satisfaction a factor with levels "Very Dissatisfied", "A Little Satisfied", "Moderately Satisfied" and "Very Satisfied". Gender a factor with levels "Female" and "Male". Details This data set was given in Agresti (2002, p. 288, Tab. 7.8). Winell and Lindbäck (2018) used the data to demonstrate a score-independent test for ordered categorical data.

34 LocationTests Source Agresti, A. (2002). Categorical Data Analysis, Second Edition. Hoboken, New Jersey: John Wiley & Sons. References Winell, H. and Lindbäck, J. (2018). A general score-independent test for order-restricted inference. Statistics in Medicine 37(21), 3078–3090. doi: 10.1002/sim.7690 Examples ## Approximative (Monte Carlo) linear-by-linear association test lbl_test(jobsatisfaction, distribution = approximate(nresample = 10000)) ## Not run: ## Approximative (Monte Carlo) score-independent test ## Winell and Lindbaeck (2018) (it

LocationTests 35 wilcox_test(formula, data, subset = NULL, weights = NULL, ...) ## S3 method for class 'IndependenceProblem' wilcox_test(object, conf.int = FALSE, conf.level = 0.95, ...) ## S3 method for class 'formula' kruskal_test(formula, data, subset = NULL, weights = NULL, ...) ## S3 method for class 'IndependenceProblem' kruskal_test(object, ...) ## S3 method for class 'formula' normal_test(formula, data, subset = NULL, weights = NULL, ...) ## S3 method for class 'IndependenceProblem' normal_test(object, ties.method = c("mid-ranks", "average-scores"), conf.int = FALSE, conf.level = 0.95, ...) ## S3 method for class 'formula' median_test(formula, data, subset = NULL, weights = NULL, ...) ## S3 method for class 'IndependenceProblem' median_test(object, mid.score = c("0", "0.5", "1"), conf.int = FALSE, conf.level = 0.95, ...) ## S3 method for class 'formula' savage_test(formula, data, subset = NULL, weights = NULL, ...) ## S3 method for class 'IndependenceProblem' savage_test(object, ties.method = c("mid-ranks", "average-scores"), conf.int = FALSE, conf.level = 0.95, ...) Arguments formula a formula of the form y ~ x | block where y is a numeric variable, x is a factor and block is an optional factor for stratification. data an optional data frame containing the variables in the model formula. subset an optional vector specifying a subset of observations to be used. Defaults to NULL. weights an optional formula of the form ~ w defining integer valued case weights for each observation. Defaults to NULL, implying equal weight for all observations. object an object inheriting from class "IndependenceProblem". conf.int a logical indicating whether a confidence interval for the difference in location should be computed. Defaults to FALSE. conf.level a numeric, confidence level of the interval. Defaults to 0.95. ties.method a character, the method used to handle ties: the score generating function ei- ther uses mid-ranks ("mid-ranks", default) or averages the scores of randomly broken ties ("average-scores"). mid.score a character, the score assigned to observations exactly equal to the median: ei- ther 0 ("0", default), 0.5 ("0.5") or 1 ("1"); see ‘Details’. ... further arguments to be passed to independence_test.

36 LocationTests Details oneway_test, wilcox_test, kruskal_test, normal_test, median_test and savage_test pro- vide the Fisher-Pitman permutation test, the Wilcoxon-Mann-Whitney test, the Kruskal-Wallis test, the van der Waerden test, the Brown-Mood median test and the Savage test. A general description of these methods is given by Hollander and Wolfe (1999). For the adjustment of scores for tied values see Hájek, Šidák and Sen (1999, pp. 133–135). The null hypothesis of equality, or conditional equality given block, of the distribution of y in the groups defined by x is tested against shift alternatives. In the two-sample case, the two-sided null hypothesis is H0 : µ = 0, where µ = Y1 − Y2 and Ys is the median of the responses in the sth sample. In case alternative = "less", the null hypothesis is H0 : µ ≥ 0. When alternative = "greater", the null hypothesis is H0 : µ ≤ 0. Confidence intervals for the difference in location are available (except for oneway_test) and computed according to Bauer (1972). If x is an ordered factor, the default scores, 1:nlevels(x), can be altered using the scores argu- ment (see independence_test); this argument can also be used to coerce nominal factors to class "ordered". In this case, a linear-by-linear association test is computed and the direction of the alternative hypothesis can be specified using the alternative argument. The Brown-Mood median test offers a choice of mid-score, i.e., the score assigned to observa- tions exactly equal to the median. In the two-sample case, mid-score = "0" implies that the linear test statistic is simply the number of subjects in the second sample with observations greater than the median of the pooled sample. Similarly, the linear test statistic for the last alternative, mid-score = "1", is the number of subjects in the second sample with observations greater than or equal to the median of the pooled sample. If mid-score = "0.5" is selected, the linear test statistic is the mean of the test statistics corresponding to the first and last alternatives and has a symmetric distribution, or at least approximately so, under the null hypothesis (see Hájek, Šidák and Sen, 1999, pp. 97–98). The conditional null distribution of the test statistic is used to obtain p-values and an asymptotic approximation of the exact distribution is used by default (distribution = "asymptotic"). Al- ternatively, the distribution can be approximated via Monte Carlo resampling or computed exactly for univariate two-sample problems by setting distribution to "approximate" or "exact" re- spectively. See asymptotic, approximate and exact for details. Value An object inheriting from class "IndependenceTest". Confidence intervals can be extracted by confint. Note Starting with version 1.1-0, oneway_test no longer allows the test statistic to be specified; a quadratic form is now used in the K-sample case. Please use independence_test if more con- trol is desired. References Bauer, D. F. (1972). Constructing confidence sets using rank statistics. Journal of the American Statistical Association 67(339), 687–690. doi: 10.1080/01621459.1972.10481279

You can also read