Frank Harrell's R package rms is an amazing tool for implementing multiple logistic regression. However, I wish to know how/ if it is possible to incorporate random effects into a model run through rms. I know that rms can run through nlme, but only the generalized least squares function (Gls) and not the lme function, which allows for the incorporation of random effects. Mixed effects models can be problematic for analysis/ interpretation but are occasionally necessary in order to account for nested effects in models.
I'm not sure if it's helpful in this case but I have copied some code from the rms help files that runs a simple logistic regression model and added a line demonstrating a mixed effects logistic regression model run through glmmPQL of the MASS package.
n <- 1000 # define sample size
require(rms)
set.seed(17) # so can reproduce the results
age <- rnorm(n, 50, 10)
blood.pressure <- rnorm(n, 120, 15)
cholesterol <- rnorm(n, 200, 25)
sex <- factor(sample(c('female','male'), n,TRUE))
label(age) <- 'Age' # label is in Hmisc
label(cholesterol) <- 'Total Cholesterol'
label(blood.pressure) <- 'Systolic Blood Pressure'
label(sex) <- 'Sex'
units(cholesterol) <- 'mg/dl' # uses units.default in Hmisc
units(blood.pressure) <- 'mmHg'
ch <- cut2(cholesterol, g=40, levels.mean=TRUE) # use mean values in intervals
table(ch)
f <- lrm(ch ~ age)
require(MASS)
f1<-glmmPQL(ch~age, random=~1|sex, family=binomial)
summary(f1)
I would be interested in any insight as to whether random effects can be incorporated in rms both for logistic regression (lrm) or run through nlme for linear regression.
Thanks to all