5  Experiments, Stepped Wedge Cluster Design

library(lme4)
lmerfit <- lmer(Y ~ period + rx + (1| cluster), data = dx)
vars <-as.data.frame(VarCorr(lmerfit))$vcov
iccest <- round(vars[1]/(sum(vars)), 3)

library(lme4)
lmerfit <- lmer(Y ~ period + rx + (1| cluster/period) , data = dcs)

The cluster-level period-specific effects are specified in the model as “cluster/period”, which indicates that the period effects are nested within the cluster.

- vs <- as.data.table(VarCorr(lmerfit))$vcov
- rho <- vs[2]/sum(vs[1:2])
iccw <- sum(vs[1:2])/sum(vs
iccb <- vs[2]/sum(vs)