mosaic (version 1.1.0)

statTally: Tally test statistics

Description

Tally test statistics from data and from multiple draws from a simulated null distribution

Usage

statTally(sample, rdata, FUN, direction = NULL, alternative = c("default",
  "two.sided", "less", "greater"), sig.level = 0.1, center = NULL,
  stemplot = dim(rdata)[direction] < 201, q = c(0.5, 0.9, 0.95, 0.99),
  fun = function(x) x, xlim, ...)

Arguments

sample

sample data

rdata

a matrix of randomly generated data under null hypothesis.

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.

direction

1 or 2 indicating whether samples in rdata are in rows (1) or columns (2).

alternative

one of default, two.sided, less, or greater

sig.level

significance threshold for wilcox.test used to detect lack of symmetry

center

center of null distribution

stemplot

indicates whether a stem plot should be displayed

q

quantiles of sampling distribution to display

fun

same as FUN so you don't have to remember if it should be capitalized

xlim

limits for the horizontal axis of the plot.

additional arguments passed to histogram()

Value

A lattice plot showing the sampling distribution.

As side effects, information about the empirical sampling distribution and (optionally) a stem plot are printed to the screen.

Examples

Run this code
# NOT RUN {
# 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)  # unusual test statistic
statTally(x, rdata, fun=var)  # 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)
}

# }

Run the code above in your browser using DataCamp Workspace