I'm doing a project involving outcomes measured for people clustered within departments. The departments had previously been randomized to a treatment or control condition.
One of the main outcomes is the proportion of women within each department (technically the proportion of new hires that are women). So, I'm interested in the relative proportion of women in treatment and control departments.
My initial impression as to how to analyze these data was to simply calculate the proportion of women within each department, then fit a plain old linear model with condition as a predictor variable. However, on further thought it seems like this might be an appropriate situation in which to use a GLMEM (Generalized Linear Mixed Effects Model) in which condition predicts gender, with random intercepts for department.
What are the implications of fitting a linear model on proportions calculated within departments vs fitting a full GLMEM?
Here is some very simple R code showing these two approaches:
set.seed(1343) d <- data.frame(id = 1:2000, dept_id = rep(1:100, 20)) d$condition <- ifelse(d$dept_id %in% 1:50, "control", "experimental") d$gender <- sample(rep(c(1, 0), 1000)) mod1 <- glmer(gender ~ condition + (1|dept_id), family = binomial, data = d) summary(mod1) dept_stats <- ddply(d, "dept_id", summarize, condition = unique(condition), prop_m = sum(gender == 1)/length(gender)) mod2 <- lm(prop_m ~ condition, data = dept_stats) summary(mod2)