1
$\begingroup$

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
$\endgroup$

1 Answer 1

1
$\begingroup$

You need to analyse this as a repeated measures model. Use lmer from the lme4 package and include a random effect for the subject -- the entity you have 1000 of, and which you observe at 5 points.

With a binomial response, the variance of the values will be a function of the probability, but the link function takes care of that.

Yes ... there are conditions to take into account, but the model will be fairly robust against them. At least, if you just want to test for a change in time.

If the fit fails to converge, that probably means that the random effect is not significant. In that case, you can drop it and return to the GLM model you have already tried.

$\endgroup$
5
  • $\begingroup$ Thanks, I added the output from the (g)lmer() model above. Looks like it works (for this model). $\endgroup$ Dec 26, 2017 at 15:23
  • $\begingroup$ So it looks as if "student" is a very small effect, and you get much the same values for your fixed effects coefficients either way. $\endgroup$
    – Placidia
    Dec 26, 2017 at 15:34
  • $\begingroup$ Do you have any thoughts on the large variance of the student random effects? That seems to suggest (to me) there is systematic variation at the student level. But the fixed effects seem to not be impacted much by it. $\endgroup$ Dec 26, 2017 at 15:37
  • $\begingroup$ The variance is large, but so is its standard deviation -- 1.697 to an estimate of 2.881. That's why I don't think that the student effect is significant. You might also want to check the observation with scaled residual 4.4. Did you get any warning messages about convergence? $\endgroup$
    – Placidia
    Dec 26, 2017 at 15:45
  • $\begingroup$ Thanks, I did not get any warning messages. What is scaled residual 4.4? $\endgroup$ Dec 26, 2017 at 15:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.