My question is similar to this one GLM with grouped/aggregated data in R, but I have a specific question regarding my data set. I have included below an aggregated data set of frequency of death by gender and age group from 2005 to 2015.
structure(list(age_9 = structure(c(1L, 1L, 2L, 2L, 3L, 3L,
4L,4L, 5L, 5L, 6L, 6L, 7L, 7L, 8L, 8L, 9L, 9L),
.Label = c("0 - 14 years", "15 - 24 years","25 - 34 years", "35 - 44
years","45 - 54 years", 55 - 64 years", "65 - 74 years
"75 - 84 years", "85+"),class = "factor"), = structure(c(1L, 2L, 1L,
2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L),
.Label = c("Male", "Female" ), class = "factor"),
count = c(6, 4, 7, 5, 15, 15, 18, 35, 39, 62, 71, 79, 71,89, 83, 120,
66, 123),
pop = c(336085, 316508, 266001, 256539, 220505, 233310,
219358, 239771, 220639, 197750, 236558, 155796, 188762,
77920, 104571, 26234, 44487)),
.Names = c("age_9", "sex", "count", "pop"),
row.names = c(NA, -18L), vars = "age_9",
drop = TRUE,class = c("grouped_df", "tbl_df","tbl", "data.frame"))
Let's say I want to use this data to test if females had higher risk of dying than males accounting for age groups.
Based on the document (pdf) linked in the referenced original question I think I should use a generalized linear model on my aggregated data for my specific question, but I'm not sure:
glm(count ~ sex + age, family=poisson(link=log), offset=log(?), data=A2)
My questions are:
- Is adequate to formulate the above GLM with the included aggregated data set?
- if no, why?
- If yes to question 1, What would be an appropriate offset vector?