Performs one and two sample Yuen t-tests for trimmed means on vectors of data.

YuenTTest(x, ...)

# Default S3 method
YuenTTest(x, y = NULL, alternative = c("two.sided", "less", "greater"), 
          mu = 0, paired = FALSE, conf.level = 0.95, trim = 0.2, ... )

# S3 method for class 'formula'
YuenTTest(formula, data, subset, na.action, ...)

Arguments

x

numeric vector of data values. Non-finite (e.g. infinite or missing) values will be omitted.

y

an optional numeric vector of data values: as with x non-finite values will be omitted.

alternative

is a character string, one of "greater", "less", or "two.sided", or the initial letter of each, indicating the specification of the alternative hypothesis. For one-sample tests, alternative refers to the true median of the parent population in relation to the hypothesized value of the mean.

paired

a logical indicating whether you want a paired z-test.

mu

a number specifying the hypothesized mean of the population.

conf.level

confidence level for the interval computation.

trim

the fraction (0 to 0.5) of observations to be trimmed from each end of x before the mean is computed. Values of trim outside that range are taken as the nearest endpoint.

formula

a formula of the form lhs ~ rhs where lhs gives the data values and rhs 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

An object of class htest containing the following components:

statistic

the value of the t-statistic.

parameter

the degrees of freedom for the t-statistic and the trim percentage used.

p.value

the p-value for the test.

conf.int

a confidence interval for the trimmed mean appropriate to the specified alternative hypothesis.

estimate

the estimated trimmed mean or difference in trimmed means depending on whether it was a one-sample test or a two-sample test.

null.value

the specified hypothesized value of the trimmed mean or trimmed mean difference 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 test was performed.

data.name

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

References

Wilcox, R. R. (2005) Introduction to robust estimation and hypothesis testing. Academic Press.
Yuen, K. K. (1974) The two-sample trimmed t for unequal population variances. Biometrika, 61, 165-170.

Author

Andri Signorell <andri@signorell.net>, based on R-Core code of t.test

See also

Examples

x <- rnorm(25, 100, 5)
YuenTTest(x, mu=99)
#> 
#> 	Yuen One Sample t-test
#> 
#> data:  x
#> t = 1, df = 14.0, trim = 0.2, p-value = 0.3
#> alternative hypothesis: true trimmed mean is not equal to 99
#> 95 percent confidence interval:
#>   98 102
#> sample estimates:
#> trimmed mean of x 
#>               100 
#> 

# the classic interface
with(sleep, YuenTTest(extra[group == 1], extra[group == 2]))
#> 
#> 	Yuen Two Sample t-test
#> 
#> data:  extra[group == 1] and extra[group == 2]
#> t = -2, df = 8.8, trim = 0.2, p-value = 0.2
#> alternative hypothesis: true difference in trimmed means is not equal to 0
#> 95 percent confidence interval:
#>  -4.139  0.806
#> sample estimates:
#> trimmed mean of x trimmed mean of y 
#>             0.533             2.200 
#> 

# the formula interface
YuenTTest(extra ~ group, data = sleep)
#> 
#> 	Yuen Two Sample t-test
#> 
#> data:  extra by group
#> t = -2, df = 8.8, trim = 0.2, p-value = 0.2
#> alternative hypothesis: true difference in trimmed means is not equal to 0
#> 95 percent confidence interval:
#>  -4.139  0.806
#> sample estimates:
#> trimmed mean in group 1 trimmed mean in group 2 
#>                   0.533                   2.200 
#> 


# Stahel (2002), pp. 186, 196  
d.tyres <- data.frame(A=c(44.5,55,52.5,50.2,45.3,46.1,52.1,50.5,50.6,49.2),
                      B=c(44.9,54.8,55.6,55.2,55.6,47.7,53,49.1,52.3,50.7))
with(d.tyres, YuenTTest(A, B, paired=TRUE))
#> 
#> 	Yuen Paired t-test
#> 
#> data:  A and B
#> t = -2, df = 5.0, trim = 0.2, p-value = 0.1
#> alternative hypothesis: true difference in trimmed means is not equal to 0
#> 95 percent confidence interval:
#>  -6.71  1.25
#> sample estimates:
#> difference of trimmed means 
#>                       -2.73 
#> 


d.oxen <- data.frame(ext=c(2.7,2.7,1.1,3.0,1.9,3.0,3.8,3.8,0.3,1.9,1.9),
                     int=c(6.5,5.4,8.1,3.5,0.5,3.8,6.8,4.9,9.5,6.2,4.1))
with(d.oxen, YuenTTest(int, ext, paired=FALSE))
#> 
#> 	Yuen Two Sample t-test
#> 
#> data:  int and ext
#> t = 4, df = 7.9, trim = 0.2, p-value = 0.003
#> alternative hypothesis: true difference in trimmed means is not equal to 0
#> 95 percent confidence interval:
#>  1.34 4.54
#> sample estimates:
#> trimmed mean of x trimmed mean of y 
#>              5.39              2.44 
#>