Have you read the documentation to either of the functions you are using?

?bartlett.test

"Performs Bartlett's test of the null that the variances in each of the
groups (samples) are the same."

This explicitly tells you what is being tested, i.e. the null tested is that
var1 = var2.

?rnorm

Generates random deviates, so the answer [i.e. p-value] will (almost
certainly) differ each time. Only by setting a seed for the random number
generator to use will rnorm() generate the same number-set/distribution and
therefore the same p-value.

?set.seed

##
set.seed(7)
bartlett.test(rep(rnorm(5),times=4), rep(1:5, each=4))
set.seed(7)
bartlett.test(rep(rnorm(5),times=4), rep(1:5, each=4))
set(23)
bartlett.test(rep(rnorm(5),times=4), rep(1:5, each=4))
bartlett.test(rep(rnorm(5),times=4), rep(1:5, each=4))

HTH, Mark.


Daren Tan wrote:
> 
> 
> I am testing whether the sample variances are equal. When p-value < 0.05
> (alpha), should accept null hypothesis (sample variances are equal) or
> reject it ?
> 
> 
> The two new examples with each having same sample variances also puzzle
> me. Why are the p-values different ?
> 
> bartlett.test(rep(rnorm(5),times=4), rep(1:5, each=4))
> 
> 
>         Bartlett test of homogeneity of variances
> 
> 
> data:  rep(rnorm(5), times = 4) and rep(1:5, each = 4)
> Bartlett's K-squared = 0.8681, df = 4, p-value = 0.929
> 
> 
> bartlett.test(rep(rnorm(5),times=4), rep(1:5, each=4))
> 
> 
>         Bartlett test of homogeneity of variances
> 
> 
> data:  rep(rnorm(5), times = 4) and rep(1:5, each = 4)
> Bartlett's K-squared = 3.5599, df = 4, p-value = 0.4688
> 
> 
>> From: [EMAIL PROTECTED]
>> To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
>> Date: Fri, 22 Aug 2008 11:25:36 -0400
>> Subject: RE: [R] Test of Homogeneity of Variances
>>
>> What are your hypotheses? Once you state what they are, interpretation
>> should be straightforward.
>>
>>
>>
>> -----Original Message-----
>> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
>> On Behalf Of Daren Tan
>> Sent: Friday, August 22, 2008 11:18 AM
>> To: [EMAIL PROTECTED]
>> Subject: [R] Test of Homogeneity of Variances
>>
>>
>> I am testing the homogeneity of variances via bartlett.test and
>> fligner.test. Using the following example, how should I interpret the
>> p-value in order to accept or reject the null hypothesis ?
>>
>> set.seed(5)
>> x <- rnorm(20)
>> bartlett.test(x, rep(1:5, each=4))
>>
>>
>> Bartlett test of homogeneity of variances
>>
>>
>> data: x and rep(1:5, each = 4)
>> Bartlett's K-squared = 1.7709, df = 4, p-value = 0.7778
>>
>> fligner.test(x, rep(1:5, each=4))
>>
>> Fligner-Killeen test of homogeneity of variances
>>
>>
>> data: x and rep(1:5, each = 4)
>> Fligner-Killeen:med chi-squared = 1.0819, df = 4, p-value = 0.8971
>>
>> ______________________________________________
>> R-help@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide
>> http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>> This email message, including any attachments, is for ...{{dropped:6}}
> 
> ______________________________________________
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Test-of-Homogeneity-of-Variances-tp19109383p19112613.html
Sent from the R help mailing list archive at Nabble.com.

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to