Tell me more ×
Cross Validated is a question and answer site for statisticians, data analysts, data miners and data visualization experts. It's 100% free, no registration required.

can anybody tell me why the oneway.test() results in a p-value of NA when var.equal is set to FALSE but in a p-value of 0.7173 when it is set to TRUE

Here is my example:

x <- c(3.921973, 5.703782, 3.921973, 3.921973, 3.921973, 6.075346, 3.921973, 3.921973, 3.921973, 3.921973)
y <- c(4.424847, 4.424847, 4.424847, 4.424847, 4.424847, 4.424847, 4.424847, 4.424847)

d <- c(x,y)
f <- c(rep("a", 10), rep("b", 8))

oneway.test(d ~ f, var.equal = FALSE)

oneway.test(d ~ f, var.equal = TRUE)

Thanks for you help!

share|improve this question
5  
The reason is that the sample variance of y is $0$ since all its elements are 4.424847. When var.equal = FALSE you get division by 0 (or some similar problem) at some point. – MånsT Aug 7 '12 at 12:42

1 Answer

When in doubt, look at the source code (it's one of the interest of R). In that case you can just issue the name of the function at the R prompt. As pointed out by @MÃ¥nsT, variance for the b group is zero, which makes one of the intermediate computation result in NaN when var.equal = FALSE.(a)

Note that if you only work with two groups, it is probably better to stay with a $t$-test with Welch correction, which in this case does not show any problem.

> t.test(d ~ f, var.equal = FALSE)

    Welch Two Sample t-test

data:  d by f 
t = -0.4145, df = 9, p-value = 0.6882
alternative hypothesis: true difference in means is not equal to 0 
95 percent confidence interval:
 -0.7061202  0.4874086 
sample estimates:
mean in group a mean in group b 
       4.315491        4.424847 

(a) The reference paper cited in the online help is given below:
B. L. Welch (1951), On the comparison of several mean values: an alternative approach. Biometrika, 38, 330-336

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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