# Problem on conducting a hypothesis test with sample data

I'm trying to perform a statistical tests for the sample data(n=63) which is the effect of smoking for time(measured in minute) to fall asleep.

First, I set a null hypothesis, there's no effect of smoking on sleep patterns. So alternative hypothesis will be there's an effect.

Here's the summary of data.

And here are two histograms for smokers and non-smokers.

I was going to conduct a test for comparing two sample means. And the test statistic will be "t-test" since the population variance is unknown.

From my knowledge, to conduct the test, I think the distribution of samples should be normal. However, in the histogram above, "smokers" samples are not normally distributed.

Is it still possible to conduct a test? I think i'm missing something..

 smokers(n=47) non-smokers(m=63)

• Why do your histograms indicate there are 110 subjects rather than 63?? – whuber Apr 4 '19 at 21:56
• @whuber where do you see 110 subjects? – hood Apr 4 '19 at 21:58
• I counted them in the histograms: each depicts 55 times. – whuber Apr 4 '19 at 22:05
• @whuber oh, sorry for the confusion. Actually, smokers(n=47) and non-smokers(m=63). – hood Apr 4 '19 at 22:25
• There are nonparametric tests for testing the equality of medians that you can choose from. – Michael R. Chernick Apr 5 '19 at 0:35

It seems clear from the histograms that the distributions for smokers and non-smokers are different. The former is distinctly bimodal and the latter may be consistent with normal (Shapiro-Wilk P-value 20%). However, the means and medians seem similar.

Digitized data from histograms. I digitized the histograms to give 63 integer values for non-smokers and 42 for smokers

v.n = 14:25;  f.n = c(3,4,3,10,4,9,11,8,4,3,2,2)
non = rep(v.n, f.n); non
[1] 14 14 14 15 15 15 15 16 16 16 17 17 17 17 17 17 17 17 17 17
[21] 18 18 18 18 19 19 19 19 19 19 19 19 19 20 20 20 20 20 20 20
[41] 20 20 20 20 21 21 21 21 21 21 21 21 22 22 22 22 23 23 23 24
[61] 24 25 25
v.s = c(13,15:23,25,26,29); f.s = c(1,4,7,2,5,1,3,2,3,4,7,2,1)
smo = rep(v.s, f.s); smo
[1] 13 15 15 15 15 16 16 16 16 16 16 16 17 17 18 18 18 18 18 19
[21] 20 20 20 21 21 22 22 22 23 23 23 23 25 25 25 25 25 25 25 26
[41] 26 29


Maybe my work is imperfect, but summaries are similar to the ones you provide:

summary(non)
Min. 1st Qu.  Median    Mean 3rd Qu.    Max.
14.00   17.00   19.00   19.14   21.00   25.00
summary(smo)
Min. 1st Qu.  Median    Mean 3rd Qu.    Max.
13.0    16.0    20.0    20.1    23.0    29.0


As anticipated, a two-sample Wilcoxon test shows no difference (P-value 0.32).

Kolmogorov-Smirnov Test. The first thing to try might be a Kolmogorov-Smirnov test to see if the two empirical CDFs differ. This test detects no significant difference.

ks.test(non, smo)

Two-sample Kolmogorov-Smirnov test

data:  non and smo
D = 0.23016, p-value = 0.1385
alternative hypothesis: two-sided

Warning message:
In ks.test(non, smo) : cannot compute exact p-value with ties


This result is not surprising because sample sizes are small, so the power to detect a difference may be small, and we can't get an exact P-value because there are many tied values among and between samples.

Significant permutation test. However, the interquartile ranges (IQRs) of the two samples seem remarkably different.

 IQR(non); IQR(smo)
[1] 4
[1] 7


A permutation test using differences in IQR's as metric, does show that the times to fall asleep are more diverse for smokers than for non-smokers. The 105 subjects were randomly assigned to non-smoking and smoking groups 100,000 times. At each iteration $$d$$ = IQR(non) - IQR(smo) was computed.

Overall, these differences averaged very nearly 0, compared to the observed difference of $$-3.$$ Among 100,00 iterations, there were 36 uniquely different values of $$d.$$ The P-value of the permutation test is below 1%. So it seems that smokers require significantly more-variable lengths of time (as measured by IQR) to go to sleep than do non-smokers.

set.seed(403)  # for reproducibility
all = c(non, smo)
m = 10^5;  d = numeric(m); d.obs=IQR(non)-IQR(smo)
for(i in 1:m) {
prm = sample(all)
d[i] = IQR(prm[1:42]) - IQR(prm[43:105])
}

mean(d <= d.obs)
[1] 0.0072


• I found that a probability plot did a good job of comparing the datasets and a Wilcoxon rank sum test will drive the point home. – whuber Apr 6 '19 at 14:16