Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Yuen test #47

Open
krzysiektr opened this issue Jun 20, 2020 · 1 comment
Open

Yuen test #47

krzysiektr opened this issue Jun 20, 2020 · 1 comment

Comments

@krzysiektr
Copy link

Different results:

  • DescTools version 0.99.36:
> library("DescTools")
> YuenTTest(extra ~ group, data = sleep)

	Yuen Two Sample t-test

data:  extra by group
t = -1.5314, df = 8.7502, trim = 0.2000, p-value = 0.161
alternative hypothesis: true difference in trimmed means is not equal to 0
95 percent confidence interval:
 -4.1394366  0.8061033
sample estimates:
trimmed mean in group 1 trimmed mean in group 2 
              0.5333333               2.2000000 
  • PairedData, WRS2 and WRS package:
> PairedData::yuen.t.test(extra ~ group, data = sleep)

	Two-sample Yuen test, trim=0.2

data:  extra by group
t = -1.6168, df = 8.2647, p-value = 0.1434
alternative hypothesis: true difference in trimmed means is not equal to 0
95 percent confidence interval:
 -4.0306400  0.6973066
sample estimates:
trimmed mean in group 1 trimmed mean in group 2 
              0.5333333               2.2000000 
> library("WRS2")
> yuen(extra ~ group, data = sleep)

Call:
yuen(formula = extra ~ group, data = sleep)

Test statistic: 1.6168 (df = 8.26), p-value = 0.14338

Trimmed mean difference:  -1.66667 
95 percent confidence interval:
-4.0306     0.6973 

Explanatory measure of effect size: 0.52 
with(unstack(sleep[,1:2]), WRS::yuen(X1, X2))[c("teststat","df","p.value","ci")]

$teststat
[1] 1.616777

$df
[1] 8.264709

$p.value
[1] 0.1433783

$ci
[1] -4.0306400  0.6973066
@AndriSignorell
Copy link
Owner

Thanks for spotting this, I analysed the cause and come to the conclusion, that my solution is the better approximation.
In PairedData Stephane Champely's version is a copy of the code of Wilcox (WRS).
Rand Wilcox again uses a rather coarse version for quantifying the quantiles of a vector, when calculating the variance of the winsorized vectors. In my function I use the base R's approach to get the quantiles, which in my point of view leads to better results.
In the present case my function also comes nearer to the results of the yuen-t-test bootstrap version of Rand Wilcox.
Note that this differences will in general be of minor relevance, as they rarely will change our interpretation. The changes will be most noticeable when we are dealing with very small data sets. In such cases, the estimation of quantiles becomes increasingly difficult, apart from the fact that the choice of the trim factor of 20% left and right is already quite arbitrary.
Conclusion: I stick to my proposal. ;-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants