I want to fit a regression model to see whether these is changes in the proportion of First-year students over years. I have count data for the total count of First-year students (FirstTimeStudents) and total count of all students (TotalStudents). I want to fit a GEE model with this data and wrote the following code. My output for coefficients are all NA
combFirstYear = geeglm(cbind(data$FirstTimeStudents, data$TotalStudents - data$FirstTimeStudents) ~ Year, family=binomial(logit), data=data, id=DeptID, corstr="independence") summary(combFirstYear)
The reason I fit the model this way is because I read on this website about doing similar thing using glm and it works. But for some reasons, it does not work with geeglm. If anyone can think of different way of answering this question in terms of proportion, I'd really appreciate it too.
It says: "R can handle this using glm with the binomial(link="logit") family, with a dependent variable that is actually a two-vector object, the first being the number of 'successes' and the second the number of 'failures'."
Here's an example by modeling hemlock cover with respect to total cover. The example is a bit forced (as these are not actual samples of individuals) but you get the idea. We start by generating the summed cover of all species for each plot:
sumcover = tapply(dat$
coverdat = data.frame(names(sumcover),sumcover)
Now we merge these data with our dat5 hemlock object, based on plotID:
dat6 = merge(dat5,coverdat,all.x=T,by.x=1,by.y=1)
And create our response variables of hemlock cover (successes) and total cover minus hemlock cover (failures):
cover.y = cbind(dat6$cover,dat6$sumcover-dat6$cover)
We can now model these data as a binomial process of varying number of trials per observation:
glm6 = glm(cover.y~disturb*elev,data=dat6,family=binomial)