# loading lme4
library(lme4)
# Fitting a random effects model based on c2_dat1
fit <- lmer(y_ijk~(1|a)+(1|b)+(1|a:b), c2_dat1)
summary(fit)
#----------------------------------------------------------------------------
### Using c2_dat2 as newdat
c2_dat2
lmer_bs(model=fit, newdat=c2_dat2, nboot=100)
#----------------------------------------------------------------------------
### Using futmat_list
# c2_dat4 has no replication for b. Hence the list of design matrices can not be
# generated by lme4::lFormula() and have to be provided by hand via futmat_list.
c2_dat4
# Build a list containing the design matrices
fml <- vector(length=4, "list")
names(fml) <- c("a:b", "b", "a", "Residual")
fml[["a:b"]] <- matrix(nrow=6, ncol=2, data=c(1,1,0,0,0,0, 0,0,1,1,1,1))
fml[["b"]] <- matrix(nrow=6, ncol=1, data=c(1,1,1,1,1,1))
fml[["a"]] <- matrix(nrow=6, ncol=2, data=c(1,1,0,0,0,0, 0,0,1,1,1,1))
fml[["Residual"]] <- diag(6)
fml
lmer_bs(model=fit, futmat_list=fml, nboot=100)
Run the code above in your browser using DataLab