I have (for example) 2,000 observations from around 600 individuals measured at 5 time points. At each time point, the observation is associated with a value of 1
or 0
.
I'm trying to model the change in the probability of an observation being a 1
over time.
The way I've tried to do this is to use a GLM with a binomial response distribution and a logit link function; the results are an intercept and slope, both in log-odds units.
Is this a viable way to model binomial data over time (longitudinally)? In particular, I have in mind are:
- Some of the issues related to the use of repeated measures ANOVA for modeling longitudinal data with normally distributed response data - that the variance of the values must be nearly equal at different time points.
- GLM-specific issues, like over-dispersion.
EDIT:
Here's an example of some output for a possible model fit using glm()
in R:
Call:
glm(formula = code_0 ~ key_num, family = "binomial", data = dd)
Deviance Residuals:
Min 1Q Median 3Q Max
-0.7052 -0.5697 -0.4567 -0.3643 2.5269
Coefficients:
Estimate Std. Error z value Pr(>|z|)
(Intercept) -0.79330 0.16177 -4.904 9.40e-07 ***
key_num -0.47150 0.06455 -7.305 2.78e-13 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
(Dispersion parameter for binomial family taken to be 1)
Null deviance: 1401.5 on 1881 degrees of freedom
Residual deviance: 1342.2 on 1880 degrees of freedom
AIC: 1346.2
Number of Fisher Scoring iterations: 5
Here is the output from using glmer()
(also in R):
Generalized linear mixed model fit by maximum likelihood (Laplace Approximation) ['glmerMod']
Family: binomial ( logit )
Formula: code_0 ~ key_num + (1 | student_ID)
Data: dd
AIC BIC logLik deviance df.resid
1325.1 1341.7 -659.6 1319.1 1879
Scaled residuals:
Min 1Q Median 3Q Max
-0.9391 -0.2742 -0.2074 -0.1368 4.4166
Random effects:
Groups Name Variance Std.Dev.
student_ID (Intercept) 2.881 1.697
Number of obs: 1882, groups: student_ID, 845
Fixed effects:
Estimate Std. Error z value Pr(>|z|)
(Intercept) -1.24170 0.27151 -4.573 4.8e-06 ***
key_num -0.57235 0.08629 -6.633 3.3e-11 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Correlation of Fixed Effects:
(Intr)
key_num -0.390