2
$\begingroup$

I have two samples that I want to verify that variances are equals in order to apply Wilcoxon rank sum test that assume that the variance are equals.

Here a boxplot enter image description here

As you can see the variance look similar.

Using wilcox.test I can verify the non normality of these samples:

>shapiro.test(table$tempeture_stationA)

    Shapiro-Wilk normality test

data:  table$tempeture_stationA
W = 0.94385, p-value = 8.624e-06

> shapiro.test(table$tempeture_stationB)

    Shapiro-Wilk normality test

data:  table$tempeture_stationB
W = 0.95691, p-value = 0.0001091

As you can see these samples aren't normal distributed. So I can't use var.test, F test to compare two variances, because assume the normality of the samples. For this reason I decided to use Fligner-Killeen test. The result for these two samples is:

>fligner.test(table$tempeture_stationA, table$tempeture_stationB)

    Fligner-Killeen test of homogeneity of variances

data:  table$tempeture_stationA and table$tempeture_stationB
Fligner-Killeen:med chi-squared = 82.85, df = 52, p-value = 0.004177

The p-value from the Fligner-Killeen test is  0.004177

And indicates that variances are different. (Correct me if I'm wrong please).

In the boxplot you can see that the variances are pretty similar, what could be the reason for why the test indicates that variances are different?

This is a similar question Fligner-Killeen homogeneity of variances test - is it accurate for unequal sample sizes?, but in my case the sample size is the same for both samples.

Before I test with var.test, I know that this test assumes normality, but I expected less difference in the results of these tests

> var.test(table$tempeture_stationA, table$tempeture_stationB)

    F test to compare two variances

data:  table$tempeture_stationA and table$tempeture_stationB
F = 0.99679, num df = 152, denom df = 152, p-value = 0.9842
alternative hypothesis: true ratio of variances is not equal to 1
95 percent confidence interval:
 0.7244371 1.3715303
sample estimates:
ratio of variances 
         0.9967885 

Edit 1

In response comment of @BruceET here the Stripcharts: enter image description here

Edit 2

The data is measured every hour between 9:00 am and 4:00pm during a month of two sensors of temperature located in the same place, the purpose is analyse if there are significant difference between the measures of sensors.

Thanks in advance.

$\endgroup$
3
  • $\begingroup$ A boxplot uses only five numbers from the sample: min, Q1, median, Q3, and max. From these you can get range = max - min and IQR = Q3 - Q1, both measures of dispersion, but neither containing perfect info on sample disp. // Wilcoxon rank-sum test requires 2 pop's of similar shape (including disp). // If Flinger and F tests for disp are based on different measures of disp, it is unsurprising that they don't agree as to to equal disp. But I find the discrep in P-values surprising. // Stripcharts show more than boxplots; would like to see them. // Also, P-val .98 always invites a 2nd look. $\endgroup$
    – BruceET
    Jul 20, 2018 at 3:53
  • $\begingroup$ @BruceET I add the Stripcharts to my question, but I don't know how interpret that, I need to research about it. $\endgroup$ Jul 20, 2018 at 15:18
  • $\begingroup$ I am not familiar with the syntax or rationale of the flinger.test, so I will not comment on it. However my (graphical) comment below raises some issues you may want to consider. $\endgroup$
    – BruceET
    Jul 20, 2018 at 17:06

1 Answer 1

2
$\begingroup$

Comments:

(a) When making stripcharts, variations from the default are sometimes useful for visualizing data. Here are stripcharts for data somewhat similar to yours.

a = 24 + 10*rbeta(150, 1.1, 1.1)  # generate fake data
b = 24 + 10*rbeta(150, 1.1, 1.1)

par(mfrow=c(2,1))                 # enable two panels per plot
  stripchart(x ~ gp, pch="|", ylim=c(.5, 2.5))   # narrow plotting symbol
  stripchart(x ~ gp, meth="j", ylim=c(.5, 2.5))  # jittered to mitigate overplotting
par(mfrow=c(1,1))                 # return to single-panel plotting

enter image description here

(b) I am beginning to wonder whether you have two independent samples or whether you have paired data. The very high P-value from your var.test is suspicious. (In my view, very high P-values are always worth a second look. "If the P-value is very small, reject the null hypothesis; it it is very large, suspect the model or the computation.") Here is what I got for my fake independent data:

var.test(a, b)

        F test to compare two variances

data:  a and b
F = 0.95059, num df = 149, denom df = 149, p-value = 0.7575
alternative hypothesis: true ratio of variances is not equal to 1
95 percent confidence interval:
 0.6886359 1.3121767
sample estimates:
ratio of variances 
         0.9505851 

var.test(x ~ gp)
  [essentially identical output]

Here are fake paired data (effect of pairing perhaps somewhat exaggerated):

err = rnorm(150, 0, .1);  aa = a + err
cor(a, aa)
[1] 0.9992711

You can check for pairing by looking at the correlation and by plotting.

par(mfrow=c(1,2))
 plot(a, b, pch=20, main="Independent");  plot(a, aa, pch=20, main="Paired")
par(mfrow=c(1,1))

enter image description here

For paired data var.test shows P-value near 1 [some output abridged], as in your Question.

var.test(a, aa)

        F test to compare two variances

data:  a and aa
F = 0.99757, num df = 149, denom df = 149, p-value = 0.9882
...

If your data are paired, you should consider the Wilcoxon signed-rank test, instead of the Wilcoxon rank-sum test. If you have further questions, please provide more detail about your data: how collected, purpose of study, and so on. Then perhaps one of us can offer further comments or advice.

$\endgroup$
6
  • $\begingroup$ yes your are right my data is paired, in fact first I ran wilcox.test using the parameter paired = TRUE and I got P-value < 0.00001 and on the contrary with paired = False near to 1, what you mean is that I should use paired = TRUE. On other hand is pretty useful the explanation about var.test, but remember that is non normal so I can't use var.test to verify that variances are equals, what do you recommend me in this case? $\endgroup$ Jul 23, 2018 at 5:01
  • $\begingroup$ Glad the main issue is settled. There are various tests of homoscedasticity. Mostly for two-sample data or ANOVA designs. Levene's is the one I'm familiar with. Nothing against Flinger-Killeen, just not familiar with it. $\endgroup$
    – BruceET
    Jul 23, 2018 at 5:06
  • $\begingroup$ I did a new edit of my data and explained the origin of my data. $\endgroup$ Jul 23, 2018 at 5:09
  • $\begingroup$ So levene's test don't assume the normality of samples?? $\endgroup$ Jul 23, 2018 at 5:16
  • 1
    $\begingroup$ Read 2nd paragraph of this NIST page. Also a few paragraphs down about the Brown-Forsythe version. This page speaks favorably of Flinger-Killeen, but I don't know if it authoritative. (As a plus, F-K has been programmed into R. Still no personal opinion, no personal experience with F-K.) $\endgroup$
    – BruceET
    Jul 23, 2018 at 5:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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