[R] Gaussian glm for grouped data with unequal variances

Thilo Kellermann tkellermann at ukaachen.de
Tue Jan 16 13:16:33 CET 2007


Hi,
I would suggest to use lme for doing that:
library(nlme)
vf1Ident <- varIdent( c(m = 0.5), form = ~ 1 | group )
fm.lme <- lme(data ~ group, weights = vf1Ident. data = DATA)
anova(fm.lme)

Hope this helps,
Thilo


On Tuesday 16 January 2007 10:30, Dawn Ashcourt wrote:
> Hello - I am fairly new to R, (i.e., ability to create functions/write
> programs insignificant) and was wondering if there might be a convenient
> way to model the following: I want to fit a gaussian glm to grouped data,
> while allowing for unequal variances in each of the groups.
> More specifically, my data set looks something like this:
> ----------------
>    data group
> 1    76     1
> 2    82     1
> 3    83     1
> 4    54     1
> 5    35     1
> 6    46     1
> 7    87     1
> 8    68     1
> 9    87     2
> 10   95     2
> 11   98     2
> 12  100     2
> 13  109     2
> 14  109     2
> 15  100     2
> 16   81     2
> 17   75     2
> 18   68     2
> 19   67     2
> 20  105     3
> .... et cetera.
> ---------------
> There are seven groups in all, each with a different number of
> observations. The idea is to compare a model in which all the data points
> can be modeled with a single mean (i.e., if all the group means are equal),
> or if the  data suggests that each of the groups has a different mean. In
> other words, I want to do a Likelihood ratio test on whether or not the
> group means are significantly different from each other: the full model
> would be glm(data ~ as.factor(group)-1, family = gaussian), to be compared
> against a restricted model that only includes an intercept. However, I also
> need to allow for the fact that each group has a different variance. And
> this I have no idea how to do. I would really appreciate some help in this
> matter.
> Thank you in advance,
> Dawn.
>
> 	[[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at stat.math.ethz.ch 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.

-- 
________________________
Thilo Kellermann
Department of Psychiatry und Psychotherapy
RWTH Aachen University
Pauwelstr. 30
52074 Aachen
Tel.: +49 (0)241 / 8089977
Fax.: +49 (0)241 / 8082401
E-Mail: tkellermann at ukaachen.de



More information about the R-help mailing list