1
$\begingroup$

I got two distribution which are not pairs. It's difficult to say that they are also from a normal distribution because they have different length.

The distributions of the vectors are, for gas: 65 65 65 65 74 74 74 74 74 77 78 81 81 83 83 83 85 85 85 85 85 87 87 89 89 90 91 91 91 91 91 91 94 94 94 95 95 95 95 98 101 101 101 102 102 102 102 102 103 103 103 103 103 104 104 104 104 104 104 106 106 106 106 107 108 108 110 110 113 113 115 115 115 118 118 118 118 119 119 121 122 122 122 125 125 125 128 128 128 128 128 129 129 134 134 134 134 134 134 137 137 137 142 145 145 148 148 148 148 150 150 150 150 150 150 150 153 153 154 154 154 158 158 161 161 161 161 161 161 161 161 164 164 168 168 168 168 168 186 188 188 192 192 194 194 197 197 231 256

while for the diesel vector distribution is:

65  91  91  93  93  93  93  94  94  95 122 128 161 161 161

I made the t.test and the wilcox.test and I got these results:

Welch Two Sample t-test

data:  diesel_type and gas_type
t = -1.7104, df = 18.149, p-value = 0.1042
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
-31.873874   3.256425
sample estimates:
mean of x mean of y 
109.0000  123.3087 

and Wilcoxon test is:

data:  diesel_type and gas_type
W = 843, p-value = 0.1179
alternative hypothesis: true location shift is not equal to 0

I could accept the null hypothesis in the t.test, saying that the means are equals because the p-value is over the 5%. Should I accept the null hypothesis in the Wilcoxon test too? Are the medians equals? What could I say about these results?

$\endgroup$
  • $\begingroup$ Please have a look around this site as this type of question is quite common. In general, there is no reason to run two tests. You make assumptions, you can then check if those assumptions are reasonable (preferably not by significance testing), and then you perform a suitable test. If you run two tests, you had two (somewhat correlated) chances of a false positive, so you should technically already correct for multiple testing. Moreover you have no evidence for the null-hypothesis. You never do with NHST, so you cannot conclude that the null is true. $\endgroup$ – Frans Rodenburg Aug 23 '18 at 11:45
  • $\begingroup$ That's almost clear now. In fact the two tests are somewhat correlated, You're right! Anyway, I would say also that my that is unuseful because the second distribution contains only 15 data, and It's futher from a normal distribution....I guess! I'm not a statistician, for this reason I am not sure 100% about what I conclude with these results. $\endgroup$ – La_haine Aug 23 '18 at 13:03
1
$\begingroup$

The gasoline data are pretty cleanly positively skewed. The distribution of the diesel data is difficult to guess, although the data suggest it is also positively skewed.

Given this fact, and the relatively small sample size, I would probably avoid the t-test.

The Wilcoxon-Mann-Whitney is a likely candidate to compare the two groups. But note that this test is not usually a test of medians †. It sees if an observation from one group is likely to be greater than an observation from the other group. This is called stochastic dominance. It is usually a more interesting hypothesis than that from a test of medians. Although there are tests to test the medians directly, which is sometimes what you want.

To answer the question posed, using an alpha of 0.05, since the p-value from the Wilcoxon-Mann-Whitney test is > 0.05, you don't have good evidence to reject the null hypothesis. That is, you have no good evidence to think that the groups aren't stochastically equal.

It is also useful to look at an effect size statistic. Here, Cliff's delta is used. It ranges from -1 to 1, with 0 being no effect, and -1 or 1 corresponding to one group having complete stochastic domination. (Somewhat analogous to r as effect size for correlation). The result here is "small" by generalized interpretation.


† In some cases, this test will be a test of medians, but it seems to me, that if you are interested in comparing medians, it makes more sense to use a test that compares medians, rather than make distributional assumptions about the data.

‡ Disclosure: medians and confidence intervals calculated with my own R package.

if(!require(lattice)){install.packages("lattice")}
if(!require(effsize)){install.packages("effsize")}

A = read.table(text="65  65  65  65  74  74  74  74  74  77  78  81  81  83  83  83  85  85  85  85  85  87  87 89  89  90  91  91  91  91  91  91  94  94  94  95  95  95  95  98 101 101 101 102 102 102 102 102 103 103 103 103 103 104 104 104 104 104 104 106 106 106 106 107 108 108 110 110 113 113 115 115 115 118 118 118 118 119 119 121 122 122 122 125 125 125 128 128 128 128 128 129 129 134 134 134 134 134 134 137 137 137 142 145 145 148 148 148 148 150 150 150 150 150 150 150 153 153 154 154 154 158 158 161 161 161 161 161 161 161 161 164 164 168 168 168 168 168 186 188 188 192 192 194 194 197 197 231 256")

Gas = as.numeric(A[1,])

B = read.table(text="65  91  91  93  93  93  93  94  94  95 122 128 161 161 161")

Diesel = as.numeric(B[1,])

#    #    #

wilcox.test(Gas, Diesel)

   ### Wilcoxon rank sum test with continuity correction

   ### W = 1392, p-value = 0.1179

#    #    #

Y = c(Gas, Diesel)
Group = c(rep("Gas", length(Gas)), rep("Diesel", length(Diesel)))
Data = data.frame(Group, Y)

library(lattice)

histogram(~ Y | Group,
          data=Data, col="darkgray",
          layout=c(1,2))

#    #    #

library(effsize)

cliff.delta(Y ~ Group, data=Data)

   ### Cliff's Delta

   ### delta estimate: -0.2456376 (small)

Edit: Additional code based on the comments: Mood-brown median test and medians with confidence intervals ‡.

if(!require(coin)){install.packages("coin")}

library(coin)

median_test(Y~Group, data=Data)

   ### Asymptotic Two-Sample Brown-Mood Median Test

   ### Z = -1.301, p-value = 0.1933


if(!require(rcompanion)){install.packages("rcompanion")}

library(rcompanion)

groupwiseMedian(Y~Group, data=Data, R=1000)


  ###    Group   n Median Conf.level Bca.lower Bca.upper
  ### 1 Diesel  15     94       0.95        93       122
  ### 2    Gas 149    118       0.95       104       122

      ### Results by bootstrap. Results may vary.

enter image description here

$\endgroup$
  • $\begingroup$ Very intersting. I am not a statistician, so I've never heard about the Cliff's Delta. How could I interpret that? It seems that is a measure of how often the values in one distribution are larger than the values in a second distribution, and I doesn't need any assumption about distribution (this is good in my case). What could I say, exactly, about the two medians? $\endgroup$ – La_haine Aug 24 '18 at 13:24
  • $\begingroup$ If you want to compare medians, use a test of the medians. For example, Mood's median test. See RVAideMemoire::mood.medtest or coin::median_test. Report the test results with the difference in medians as the effect size. $\endgroup$ – Sal Mangiafico Aug 24 '18 at 13:35
  • $\begingroup$ Your understanding of Cliff's delta is essentially correct. It is linearly related to the probability of an observation in one group being greater than an observation in the other group. If this is expressed as a probability, it often called Vargha and Delaney's A. .... I think effect size statistics are important, but are not common in all fields. They are pretty standard in behavioral sciences. $\endgroup$ – Sal Mangiafico Aug 24 '18 at 13:40
  • $\begingroup$ Another thought on the medians: if the median is the statistic of interest, you might want to look at the 95% confidence intervals of the medians. Be sure to use a method appropriate for medians. (Disclosure: link to my own website). $\endgroup$ – Sal Mangiafico Aug 24 '18 at 13:45
  • $\begingroup$ I am not used to refer my statistics to medians, I take care of means. I'm just appoaching to quantile regressions! So these kind of measures are very useful to me in this moment. I'm just understanding the power of the quantiles!! $\endgroup$ – La_haine Aug 24 '18 at 13:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.