Generalized Estimating Equations (GEE) models using R

I’ve been having the feeling lately that using SPSS for running multilevel analysis may not be the greatest idea. I had to switch to something that is more robust and better documented. Enter R: free, open source, greatly documented, tons of well maintained packages, great for both simple and complex analyses, mathematics in general, plotting capabilities, as well as pretty much anything you would have used MATLAB to do.

Here’s a quick explanation on how to perform the same analysis in here which was done using SPSS, this time using R. The package I’m using here is geepack, and It’s documented here.

require(xlsx) #to read excel sheets
require(geepack) #the gee package

#reading my data file in excel, with a first row of column headers
J1 <- read.xlsx("J1\ multimodel.xlsx", 1)

#making sure I read my predictors as factors
#default would treat them as covariates.
J1\$N <- as.factor(J1\$N)
J1\$A <- as.factor(J1\$A)
J1\$Cr <- as.factor(J1\$Cr)
J1\$Cd <- as.factor(J1\$Cd)

#constructing the model:
#slider as response,
#N, A, Cr, and CD as fixed effects
#and pp as random effect
#with slider's distribution as gaussian
# and an unstructured covariance matrix
gee01 <- geeglm (slider ~ N*A*Cr*Cd,
id =pp, data = J1,
family=gaussian,
corstr="unstructured")

#and finally, to see the results:
summary(gee01)