Learn R Programming

asympTest (version 0.1.4)

asymp.test: Asymptotic tests

Description

Performs one and two sample asymptotic (no gaussian assumption on distribution) parametric tests on vectors of data.

Usage

asymp.test(x,…)
# S3 method for default
asymp.test(x, y = NULL,
parameter = c("mean", "var", "dMean", "dVar", "rMean", "rVar"),
alternative = c("two.sided", "less", "greater"),
reference = 0, conf.level = 0.95, rho = 1, ...)
# S3 method for formula
asymp.test(formula, data, subset, na.action, ...)

Arguments

x

a (non-empty) numeric vector of data values.

y

an optional (non-empty) numeric vector of data values.

parameter

a character string specifying the parameter under testing, must be one of "mean", "var", "dMean" (default), "dVar", "rMean", "rVar"

alternative

a character string specifying the alternative hypothesis, must be one of "two.sided" (default), "greater" or "less". You can specify just the initial letter.

reference

a number indicating the reference value of the parameter (difference or ratio true value for two sample test)

conf.level

confidence level of the interval.

rho

optional parameter (only used for parameters "dMean" and "dVar") for penalization (or enhancement) of the contribution of the second parameter.

formula

a formula of the form lhs ~ rhs where lhs is a numeric variable giving the data values and rhs a factor with two levels giving the corresponding groups.

data

an optional matrix or data frame (or similar: see model.frame) containing the variables in the formula formula. By default the variables are taken from environment(formula).

subset

an optional vector specifying a subset of observations to be used.

na.action

a function which indicates what should happen when the data contain NAs. Defaults to getOption("na.action").

further arguments to be passed to or from methods.

Value

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

statistic

the value of the unified \(\theta\) statistic.

p.value

the p-value for the test.

conf.int

a confidence interval for the parameter appropriate to the specified alternative hypothesis.

estimate

the estimated parameter depending on whether it wasa one-sample test or a two-sample test (in which case the estimated parameter can be a difference/ratio in means/variances).

null.value

the specified hypothesized value of parameter depending on whether it was a one-sample test or a two-sample test.

alternative

a character string describing the alternative hypothesis.

method

a character string indicating what type of asymptotictest was performed.

data.name

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

Details

Asymptotic parametric test and confidence intervals are based on the following unified statistic : $$\frac{\hat{\theta}(Y)-\theta}{\hat{\sigma_{\hat{\theta}}(Y)}}$$ which asymptotically follows a \(N(0,1)\).

\(\theta\) stands for the parameter under testing (mean/variance, difference/ratio of means or variances).

The term \(\hat{\sigma_{\hat{\theta}}(Y)}\) is calculated by the ad-hoc seTheta function (see seMean).

References

C oeurjolly, J.F. Drouilhet, R. Lafaye de Micheaux, P. Robineau, J.F. (2009) asympTest: a simple R package for performing classical parametric statistical tests and confidence intervals in large samples, The R Journal

See Also

t.test, var.test for normal distributed data.

Examples

Run this code
# NOT RUN {
## one sample
x <- rnorm(70, mean = 1, sd = 2)
asymp.test(x)
asymp.test(x,par="mean",alt="g")
asymp.test(x,par="mean",alt="l",ref=2)
asymp.test(x,par="var",alt="g")
asymp.test(x,par="var",alt="l",ref=2)
## two samples
y <- rnorm(50, mean = 2, sd = 1)
asymp.test(x,y)
asymp.test(x,y,"rMean","l",.75)
asymp.test(x,y,"dMean","l",0,rho=.75)
asymp.test(x,y,"dVar")
## Formula interface
asymp.test(uptake~Type,data=CO2)
# }

Run the code above in your browser using DataLab