# Modelling repeated counts with three or more levels of a repeated measures factor or a combination of factors

For small number of counts (including 0/1 data) in a repeated measures design the technique of generalized estimating equations (GEEs) can be used. GEEs are examples of generalized linear models which allow for different patterns of correlations between observations form group factor combinations coming from the same subject. The same results given by GEEs can be obtained using the Cox regression procedure for two within subject 2x2 interactions (see this example).

As an example suppose we wish to compare the relationship between staying awake and on which side over two sessions by fitting the three-way interaction awake by side by session. the data is read in in long format (ie with frequency and awake, side and session as four columns). The model can then be fitted using the syntax below in SPSS.

WEIGHT OFF. EXE. GENLIN freq BY awake side session (ORDER=ASCENDING) /MODEL awake side session awake*side awake*session side*session awake*side*session INTERCEPT=YES DISTRIBUTION=POISSON LINK=LOG /CRITERIA METHOD=FISHER(1) SCALE=1 MAXITERATIONS=100 MAXSTEPHALVING=5 PCONVERGE=1E-006(ABSOLUTE) SINGULAR=1E-012 ANALYSISTYPE=3(WALD) CILEVEL=95 LIKELIHOOD=FULL /REPEATED SUBJECT=sub WITHINSUBJECT=awake*side*session SORT=YES CORRTYPE=EXCHANGEABLE ADJUSTCORR=YES COVB=ROBUST MAXITERATIONS=100 PCONVERGE=1e-006(ABSOLUTE) UPDATECORR=1 /MISSING CLASSMISSING=EXCLUDE /PRINT CPS DESCRIPTIVES MODELINFO FIT SUMMARY SOLUTION.

The test for model effects presents a Wald chi-square test and p-value for the interaction. Two quasi-likelihood criteria (corrected, QIC, and uncorrected, QICC) are also presented. Like the more prevalent Akaike and Bayesian information criteria whese are comparative statistics whose values can be compared. The uncorrected tests different correlation structures within subject whilst the corrected can be used to test models both with and without the term of interest (the awake by side by session interaction in our case) with the model giving the lower value in each case being preferred. In the data used in the above example we found agreement between the Wald chi-square (chi-square(1)=4.83, p=0.028) and the corrected criterion value of 172.9 (with three-way interaction) and 174.2 (dropping the interaction) which both suggest the presence of the awake by side by session interaction.

Examining the parameter estimate for the three-way interaction comparing left sided propotion awake in session 1 with the other proportions we find it is negative (-0.72) suggesting proportionately fewer responses were reported as being awake on the left side in session 1 (compared to session 2).

You can also output the 'working correlation matrix' which presents the correlations between the eight within subjects scores estimated by the model within subject (assumed equal across subjects). This indicates the pattern of correlations fitted by the model for each subject.

You can get the same result using SAS GENMOD in SAS. Geepack in R may also be used.

The analogous code in SAS (V9.2 and above) is given here reading the data in from a text file. V9.2 will automatically output the quasi-likelihood criteria mentioned above. Earlier versions require a macro to do this.

DATA ONE; INFILE "C:\Documents and Settings\peterw\Desktop\My Documents\My Do cuments2\GEES_SAS\corinne.txt"; input freq sub awake side session; proc genmod data=one; class sub; /* scwgt weight; */ model freq = awake side session awake*side awake*session side*session awake*side*session/dist=poisson; repeated subject=sub /type=un corrw type=exch; make 'geercov' out=rcov; make 'GEEEmpPest' out=wt; run;

Further details with illustrations introducing and comparing GEEs with repeated measures and random effect models see this powerpoint talk (from Annette) given here. Annette concludes that these different techniques, at least on the illustrated data example, lead to the same conclusions.

The pdf attachment here illustrates how to fit GEEs in SAS and also (in the right hand column of page 3) recommends using the robust standard errors over the model-based ones since the latter are influenced by mis-specified within subject patterns of correlations.

Reference

Lipsitz SR, Kim K and Zhao L (1994) Analysis of repeated categorical data using generalized estimating equations. *Statistics in Medicine* **13(11)** 1149-1163. Model fitted using SAS GENMOD (in SAS).