% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/statTally.R
\name{statTally}
\alias{statTally}
\title{Tally test statistics}
\usage{
statTally(
  sample,
  rdata,
  FUN,
  direction = NULL,
  alternative = c("default", "two.sided", "less", "greater"),
  sig.level = 0.1,
  system = c("gg", "lattice"),
  shade = "navy",
  alpha = 0.1,
  binwidth = NULL,
  bins = NULL,
  fill = "gray80",
  color = "black",
  center = NULL,
  stemplot = dim(rdata)[direction] < 201,
  q = c(0.5, 0.9, 0.95, 0.99),
  fun = function(x) x,
  xlim,
  quiet = FALSE,
  ...
)
}
\arguments{
\item{sample}{sample data}

\item{rdata}{a matrix of randomly generated data under
null hypothesis.}

\item{FUN}{a function that computes the test statistic from
a data set.  The default value does nothing, making it easy to
use this to tabulate precomputed statistics into a null distribution.
See the examples.}

\item{direction}{1 or 2 indicating whether samples in \code{rdata}
are in rows (1) or columns (2).}

\item{alternative}{one of \code{default}, \code{two.sided}, \code{less}, or \code{greater}}

\item{sig.level}{significance threshold for \code{wilcox.test} used to detect lack of symmetry}

\item{system}{graphics system to use for the plot}

\item{shade}{a color to use for shading.}

\item{alpha}{opacity of shading.}

\item{binwidth}{bin width for histogram.}

\item{bins}{number of bins for histogram.}

\item{fill}{fill color for histogram.}

\item{color}{border color for histogram.}

\item{center}{center of null distribution}

\item{stemplot}{indicates whether a stem plot should be displayed}

\item{q}{quantiles of sampling distribution to display}

\item{fun}{same as \code{FUN} so you don't have to remember if it
should be capitalized}

\item{xlim}{limits for the horizontal axis of the plot.}

\item{quiet}{a logicial indicating whether the text output should be suppressed}

\item{\dots}{additional arguments passed to \code{\link[lattice:histogram]{lattice::histogram()}} or \code{\link[ggplot2:geom_histogram]{ggplot2::geom_histogram()}}}
}
\value{
A lattice or ggplot showing the sampling distribution.

As side effects, information
about the empirical sampling distribution and (optionally) a stem plot are
printed to the screen.
}
\description{
Tally test statistics from data and from multiple draws
from a simulated null distribution
}
\examples{
# is my spinner fair?
x <- c(10, 18, 9, 15)   # counts in four cells
rdata <- rmultinom(999, sum(x), prob = rep(.25, 4))
statTally(x, rdata, fun = max, binwidth = 1)  # unusual test statistic
statTally(x, rdata, fun = var, shade = "red", binwidth = 2)  # equivalent to chi-squared test
# Can also be used with test stats that are precomputed.
if (require(mosaicData)) {
D <- diffmean( age ~ sex, data = HELPrct); D
nullDist <- do(999) * diffmean( age ~ shuffle(sex), data = HELPrct)
statTally(D, nullDist)
statTally(D, nullDist, system = "lattice")
}

}
\keyword{inference}
