[R] GLM Help

Kathy Haapala kathy at haapi.mn.org
Wed Sep 3 17:17:53 CEST 2014


Hi all,

I have a large set of data that looks something like this, although
this data frame is much smaller and includes made up numbers to make
my question easier.

> x.df <- data.frame(Region = c("A", "A", "A", "A", "A", "B", "B", "B", "B", "B", "B", "C", "C", "C", "C"), Group_ID = c(1:15), No_Offspring = c(3, 0, 4, 2, 1, 0, 3, 4, 3, 2, 2, 5, 4, 1, 3), M_Offspring = c(2, 0, 2, 1, 0, 0, 1, 1, 2, 0, 1, 3, 2, 1, 1), F_Offspring = c(1, 0, 2, 1, 1, 0, 2, 3, 1, 2, 1, 2, 2, 0, 2), No_Helpers = c(5, 0, 2, 1, 0, 1, 3, 4, 2, 3, 2, 3, 4, 0, 0))

> x.df
   Region Group_ID No_Offspring M_Offspring F_Offspring No_Helpers
1       A        1            3           2           1          5
2       A        2            0           0           0          0
3       A        3            4           2           2          2
4       A        4            2           1           1          1
5       A        5            1           0           1          0
6       B        6            0           0           0          1
7       B        7            3           1           2          3
8       B        8            4           1           3          4
9       B        9            3           2           1          2
10      B       10            2           0           2          3
11      B       11            2           1           1          2
12      C       12            5           3           2          3
13      C       13            4           2           2          4
14      C       14            1           1           0          0
15      C       15            3           1           2          0

I have been using GLMs to determine if the number of helpers
(No_Helpers) has an effect on the sex ratio of the offspring. Here's
the GLM I have been using:

> prop.male <- x.df$M_Offspring/x.df$No_Offspring
> glm = glm(prop.male~No_Helpers,binomial,data=x.df)

However, now I'd like to fit a model with region-specific regressions
and see if this has more support than the model without
region-specificity. So, I'd like one model that generates a regression
for each region (A, B, & C).

I've tried treating No_Helpers and Region as covariates:
> glm2 = glm(prop.male~No_Helpers+Region-1,binomial,data=x.df)
which includes region-specificity in the intercepts, but not the
entire regression,
and as interaction terms:
> glm3 = glm(prop.male~No_Helpers*Region-1,binomial,data=x.df)
which also does not give me an intercept and slope for each region.

I'm not sure how else to adjust the formula, or if the adjustment
should be somewhere else in the GLM call.

Thanks in advance for your help.



More information about the R-help mailing list