asymp.test: Asymptotic tests

Description Usage Arguments Details Value Author(s) References See Also Examples

Description

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

Usage

1
2
3
4
5
6
7
8
asymp.test(x,...)
## Default S3 method:
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 class '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.

Details

Asymptotic parametric test and confidence intervals are based on the following unified statistic :

est(theta)(Y)-theta / est(var(est(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 est(var(est(theta))) is calculated by the ad-hoc seTheta function (see seMean).

Value

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

statistic

the value of the unified θ 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.

Author(s)

J.-F. Coeurjolly, R. Drouilhet, P. Lafaye de Micheaux, J.-F. Robineau

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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
## 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)

Example output

	One-sample asymptotic mean test

data:  x
statistic = 3.1968, p-value = 0.00139
alternative hypothesis: true mean is not equal to 0
95 percent confidence interval:
 0.3210356 1.3385236
sample estimates:
     mean 
0.8297796 


	One-sample asymptotic mean test

data:  x
statistic = 3.1968, p-value = 0.0006949
alternative hypothesis: true mean is greater than 0
95 percent confidence interval:
 0.4028282       Inf
sample estimates:
     mean 
0.8297796 


	One-sample asymptotic mean test

data:  x
statistic = -4.5083, p-value = 3.267e-06
alternative hypothesis: true mean is less than 2
95 percent confidence interval:
     -Inf 1.256731
sample estimates:
     mean 
0.8297796 


	One-sample asymptotic variance test

data:  x
statistic = 5.8971, p-value = 1.85e-09
alternative hypothesis: true variance is greater than 0
95 percent confidence interval:
 3.400785      Inf
sample estimates:
variance 
 4.71629 


	One-sample asymptotic variance test

data:  x
statistic = 3.3963, p-value = 0.9997
alternative hypothesis: true variance is less than 2
95 percent confidence interval:
     -Inf 6.031794
sample estimates:
variance 
 4.71629 


	Two-sample asymptotic difference of means test

data:  x and y
statistic = -4.1333, p-value = 3.576e-05
alternative hypothesis: true difference of means is not equal to 0
95 percent confidence interval:
 -1.7608216 -0.6280426
sample estimates:
difference of means 
          -1.194432 


	Two-sample asymptotic ratio of means test

data:  x and y
statistic = -2.6002, p-value = 0.004658
alternative hypothesis: true ratio of means is less than 0.75
95 percent confidence interval:
      -Inf 0.6250514
sample estimates:
ratio of means 
     0.4099273 


	Two-sample asymptotic difference of (weighted) means test

data:  x and y
statistic = -2.4896, p-value = 0.006394
alternative hypothesis: true difference of (weighted) means is less than 0
95 percent confidence interval:
       -Inf -0.2335817
sample estimates:
difference of (weighted) means 
                    -0.6883792 


	Two-sample asymptotic difference of variances test

data:  x and y
statistic = 4.771, p-value = 1.833e-06
alternative hypothesis: true difference of variances is not equal to 0
95 percent confidence interval:
 2.303520 5.515698
sample estimates:
difference of variances 
               3.909609 


	Two-sample asymptotic difference of means test

data:  uptake by Type
statistic = 6.5969, p-value = 4.198e-11
alternative hypothesis: true difference of means is not equal to 0
95 percent confidence interval:
  8.898332 16.420716
sample estimates:
difference of means 
           12.65952 

asympTest documentation built on May 2, 2019, 11:16 a.m.