Reputation: 13
I want to use Generalized Estimating Equations (GEE) to model longitudinal survey data. Participants' responses were recorded at three timepoints, and I have multiple independent variables (which are constant across time) that I would like to incorporate into the model as well.
My data looks something like this:
id | timepoint | education | income | response |
---|---|---|---|---|
1 | 1 | elementary school | full time | 6.8 |
1 | 2 | NA | NA | 5.3 |
1 | 3 | NA | NA | 4.7 |
2 | 1 | high school | full time | 6.1 |
2 | 2 | NA | NA | 5.9 |
2 | 3 | NA | NA | 6.0 |
3 | 1 | high school | part time | 7.0 |
3 | 2 | NA | NA | 6.2 |
3 | 3 | NA | NA | 5.9 |
Based on my understanding so far, I want to use a autoregressive correlation structure, and my response data follows a gamma family description.
I have written:
gee.arl <- geeglm(teqfactor3_mean ~ timepoint + education_hier + income_assist,
id = studyid, waves = timepoint, data = T1_T3_dataset,
family = Gamma(), corstr = "ar1")
and have gotten the message "Error in contrasts<-
(*tmp*
, value = contr.funs[1 + isOF[nn]]) : contrasts can be applied only to factors with 2 or more levels"
However, I know that all the variables are categorized as factors and they do have at least 2 levels. I am wondering if the issue is because I have missing values in the time-fixed covariate columns (education and income) due to the fact that they were only recorded at the first timepoint and was not recorded again because they are constant. Could this be a explanation for the error? and if so, is there a way to rewrite the equation to fix this issue?
Upvotes: 0
Views: 98