[R] Gaussian glm for grouped data with unequal variances
Chuck Cleland
ccleland at optonline.net
Tue Jan 16 12:51:25 CET 2007
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.
Have you considered oneway.test()? For example:
## Not assuming equal variances
oneway.test(breaks ~ tension, data = warpbreaks)
One-way analysis of means (not assuming equal variances)
data: breaks and tension
F = 5.8018, num df = 2.00, denom df = 32.32, p-value = 0.007032
> 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.
--
Chuck Cleland, Ph.D.
NDRI, Inc.
71 West 23rd Street, 8th floor
New York, NY 10010
tel: (212) 845-4495 (Tu, Th)
tel: (732) 512-0171 (M, W, F)
fax: (917) 438-0894
More information about the R-help
mailing list