# Demonstrate effect of number of observation on credibility interval and on amount of shrinkage library(lme4) library(reshape) rm(list=ls()) load("MaskedPriming.rda") d <- subset(d, e=="1") # Keep only data from Exp 1 # LM - w/ all data (feID.1 <- coef(lmList(rt ~ 1 | subjects, data=d))[1]) # LMM - w/ full data (m1 <- lmer(rt ~ 1 + (1|subjects), data=d)) (reID.1 <- ranef(m1, postVar=TRUE)) dotplot(reID.1, scales = list(x = list(relation = 'free', rot=0, cex=1), y = list(cex=0.5) ) ) # Remove random quarter of trials for 2 extreme and 1 medium subjects ix <- which(as.numeric(d$subjects) %in% c(5, 7, 9)) b <- d[-sample(ix, length(ix)*3/4), ] # LM - w/ missing data (feID.2 <- coef(lmList(rt ~ 1 | subjects, data=b))[1]) # LMM - w/ missing data (m2 <- lmer(rt ~ (1|subjects), data=b)) (reID.2 <- ranef(m2, postVar=TRUE)) dotplot(reID.2, scales = list(x = list(relation = 'free', rot=0, cex=1), y = list(cex=0.5) ) ) # Combine means in wide format df <- data.frame(cbind(unlist(feID.1), unlist(reID.1)+fixef(m1), unlist(feID.2), unlist(reID.2)+fixef(m2))) rownames(df) <- substr(rownames(df), 12,13) names(df) <- c("feID.1", "reID.1", "feID.2", "reID.2") df$id <- as.numeric(rownames(df)) # Convert to long format df.rs <- melt(df, id.var="id", measure.var=c("feID.1", "reID.1", "feID.2", "reID.2")) # Plot the four means dotplot(id ~ value, data=df.rs, group=variable, ref=TRUE, auto.key = list(columns=2), #auto.key=TRUE, scales = list(x = list(relation = 'free', rot=0, cex=1), y = list(cex=.5) ), pch=16 )