Hi all, I would like to test the homoegeneity of variances between several linear model for some analysis of covariance. It seems that the Bartlett's test is a good test to use but I am having problem using with linear model and I cannot find any examples on the internet. There are some examples for comparisons of variances but not linear models. If I take the hellung data set, which is the example in Dalgaard's book. I know var.test works fine but I want to learn how to use the Bartlett's test. > hellung$glucose <- factor(hellung$glucose, labels=c("Yes","No")) > attach(hellung) > tethym.gluc <- hellung[glucose=="Yes",] > tethym.nogluc <- hellung[glucose=="No",] > lm.nogluc <- lm(log10(diameter)~log10(conc), data=tethym.nogluc) > lm.gluc <- lm(log10(diameter)~log10(conc), data=tethym.gluc) I guess I have two questions. 1) How to use bartlett.test with linear model (using the model above) and 2) how to test for homogeneity of variances of linear models when there are more than two groups. Thanks, Stephanie
Stephanie Bernard wrote:> > Hi all, > I would like to test the homoegeneity of variances between several > linear model for some analysis of covariance. It seems that the > Bartlett's test is a good test to use but I am having problem using with > linear model and I cannot find any examples on the internet. There are > some examples for comparisons of variances but not linear models. > If I take the hellung data set, which is the example in Dalgaard's book. > I know var.test works fine but I want to learn how to use the Bartlett's > test. > > hellung$glucose <- factor(hellung$glucose, labels=c("Yes","No")) > > attach(hellung) > > tethym.gluc <- hellung[glucose=="Yes",] > > tethym.nogluc <- hellung[glucose=="No",] > > lm.nogluc <- lm(log10(diameter)~log10(conc), data=tethym.nogluc) > > lm.gluc <- lm(log10(diameter)~log10(conc), data=tethym.gluc) > I guess I have two questions. 1) How to use bartlett.test with linear > model (using the model above) and 2) how to test for homogeneity of > variances of linear models when there are more than two groups. >1. bartlett.test(list(lm.gluc,lm.nogluc)) 2. x = rnorm(40,sd=1) y = rnorm(40,sd=2) z = rnorm(40,sd=3) bartlett.test(list(x,y,z)) -- View this message in context: http://www.nabble.com/Help-with-Bartlett%27s-test-on-linear-model-tf4807461.html#a13756626 Sent from the R help mailing list archive at Nabble.com.
Stephanie Bernard a ?crit :> Hi all, > I would like to test the homoegeneity of variances between several > linear model for some analysis of covariance. It seems that the > Bartlett's test is a good test to use but I am having problem using with > linear model and I cannot find any examples on the internet. There are > some examples for comparisons of variances but not linear models. > If I take the hellung data set, which is the example in Dalgaard's book. > I know var.test works fine but I want to learn how to use the Bartlett's > test. >> hellung$glucose <- factor(hellung$glucose, labels=c("Yes","No")) >> attach(hellung) >> tethym.gluc <- hellung[glucose=="Yes",] >> tethym.nogluc <- hellung[glucose=="No",] >> lm.nogluc <- lm(log10(diameter)~log10(conc), data=tethym.nogluc) >> lm.gluc <- lm(log10(diameter)~log10(conc), data=tethym.gluc) > I guess I have two questions. 1) How to use bartlett.test with linear > model (using the model above)Please look at ?bartlett.test. This generic has methods both for formulae (formulas ?) and for objects inheriting from the class "lm". Therefore you might call : bartlett.test(nogluc) and bartlett.test(gluc) or (equivalently, I think) bartlett.test(log10(diameter)~log10(conc), data=tethym.nogluc) etc ... ad nauseam. and 2) how to test for homogeneity of> variances of linear models when there are more than two groups.As the "?bartlett.test" will tell you, this function "[p]erforms Bartlett's test of the null that the variances in each of the groups (samples) are the same", which is exactly what you aim at... HTH Emmanuel Charpentier