% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/compare.2.vectors.R
\encoding{UTF-8}
\name{compare.2.vectors}
\alias{compare.2.vectors}
\title{Compare two vectors using various tests.}
\usage{
compare.2.vectors(x, y, paired = FALSE, na.rm = FALSE, 
     tests = c("parametric", "nonparametric"), coin = TRUE, 
     alternative = "two.sided", 
     perm.distribution, 
     wilcox.exact = NULL, wilcox.correct = TRUE)
}
\arguments{
\item{x}{a (non-empty) numeric vector of data values.}

\item{y}{a (non-empty) numeric vector of data values.}

\item{paired}{a logical whether the data is paired. Default is \code{FALSE}.}

\item{na.rm}{logical. Should \code{NA} be removed?  Default is \code{FALSE}.}

\item{tests}{Which tests to report, parametric or nonparamteric? The default \code{c("parametric", "nonparametric")} reports both. See details. (Arguments may be abbreviated).}

\item{coin}{logical or character. Should (permutation) tests from the \pkg{coin} package be reported? Default is \code{TRUE} corresponding to all implemented tests. \code{FALSE} calculates no tests from \pkg{coin}. A character vector may include any of the following (potentially abbreviated) implemented tests (see also Details): \code{c("permutation", "Wilcoxon", "median")}}

\item{alternative}{a character, the alternative hypothesis must be one of \code{"two.sided"} (default), \code{"greater"} or \code{"less"}. You can specify just the initial letter, will be passed to all functions.}

\item{perm.distribution}{\code{distribution} argument to \pkg{coin}, see \code{\link[coin]{NullDistribution}} or , \code{\link[coin]{IndependenceTest}}. If missing, defaults to \code{coin::approximate(100000)} indicating an approximation of the excat conditional distribution with 100.000 Monte Carlo samples. One can use \code{"exact"} for small samples and if \code{paired = FALSE}.}

\item{wilcox.exact}{\code{exact} argument to \code{\link{wilcox.test}}.}

\item{wilcox.correct}{\code{correct} argument to \code{\link{wilcox.test}}.}
}
\value{
a list with up to two elements (i.e., \code{paramteric} and/or \code{nonparamteric}) each containing  a \code{data.frame} with the following columns: \code{test}, \code{test.statistic}, \code{test.value}, \code{test.df}, \code{p}.
}
\description{
Compares two vectors \code{x} and \code{y} using t-test, Welch-test (also known as Satterthwaite), Wilcoxon-test, and a permutation test implemented in \pkg{coin}.
}
\details{
The \code{parametric} tests (currently) only contain the \emph{t}-test and Welch/Statterwaithe/Smith/unequal variance \emph{t}-test implemented in \code{\link{t.test}}. The latter one is only displayed if \code{paired = FALSE}. 

The \code{nonparametric} tests (currently) contain the Wilcoxon test implemented in \code{\link{wilcox.test}} (\code{stats::Wilcoxon}) and (if \code{coin = TRUE}) the following tests implemented in \pkg{coin}: 

\itemize{
\item a \code{permutation} test \code{\link[coin]{oneway_test}} (the only test in this selction not using a rank transformation),
\item the \code{Wilcoxon} test \code{\link[coin]{wilcox_test}} (\code{coin::Wilcoxon}), and 
\item the \code{median} test \code{\link[coin]{median_test}}. 
}
Note that the two implementations of the Wilcoxon test probably differ. This is due to differences in the calculation of the Null distributions.
}
\examples{

with(sleep, compare.2.vectors(extra[group == 1], extra[group == 2]))

# gives:
## $parametric
##    test test.statistic test.value test.df       p
## 1     t              t     -1.861   18.00 0.07919
## 2 Welch              t     -1.861   17.78 0.07939
## 
## $nonparametric
##              test test.statistic test.value test.df       p
## 1 stats::Wilcoxon              W     25.500      NA 0.06933
## 2     permutation              Z     -1.751      NA 0.08154
## 3  coin::Wilcoxon              Z     -1.854      NA 0.06487
## 4          median              Z     -1.744      NA 0.17867

# compare with:
with(sleep, compare.2.vectors(extra[group == 1], extra[group == 2], 
                              alternative = "less"))

with(sleep, compare.2.vectors(extra[group == 1], extra[group == 2], 
                              alternative = "greater"))

# doesn't make much sense as the data is not paired, but whatever:
with(sleep, compare.2.vectors(extra[group == 1], extra[group == 2], 
                              paired = TRUE))

# from ?t.test:
compare.2.vectors(1:10,y=c(7:20, 200))

}
