Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

shrinkage

Data set illustrating shrinkage


Description

Simulated data set for illustrating shrinkage.

Usage

data(shrinkage)

Format

A data frame with 200 observations on the following 6 variables.

intercept

a numeric vector for the intercept.

frequency

a numeric vector for word frequency.

subject

a factor for subjects with levels S1, S2, ... , S10.

error

a numeric vector for residuals.

ranef

a numeric vector for random effect.

RT

a numeric vector for simulated RTs.

Examples

## Not run: 
data(shrinkage)

require(lme4)
require(lmerTest)
require(optimx)

shrinkage.lmer = lmer(RT ~ frequency + (1|subject), 
  data = shrinkage,
  control=lmerControl(optimizer="optimx",optCtrl=list(method="nlminb"))
shrinkage.lmList = lmList(RT ~ frequency | subject, data = shrinkage)

# and visualize the difference between random regression 
# and mixed-effects regression

mixed = coef(shrinkage.lmer)[[1]]
random = coef(shrinkage.lmList)
subj = unique(shrinkage[,c("subject", "ranef")])
subj = subj[order(subj$subject),]
subj$random = random[,1]
subj$mixed = mixed[,1]
subj = subj[order(subj$random),]
subj$rank = 1:nrow(subj)

par(mfrow=c(1,2))
plot(subj$rank, subj$random, xlab="rank", ylab="RT", ylim=c(200,550), type="n")
text(subj$rank, subj$random, as.character(subj$subject), cex=0.8, col="red")
mtext("random regression", 3, 1)
points(subj$rank, 400+subj$ranef, col="blue")
abline(h=400)
plot(subj$rank, subj$mixed, xlab="rank", ylab="RT", ylim=c(200,550), type="n")
text(subj$rank, subj$mixed, as.character(subj$subject), cex=0.8, col = "red")
mtext("mixed-effects regression", 3, 1)
points(subj$rank, 400+subj$ranef, col="blue")
abline(h=400)
par(mfrow=c(1,1))

## End(Not run)

languageR

Analyzing Linguistic Data: A Practical Introduction to Statistics

v1.5.0
GPL (>= 2)
Authors
R. H. Baayen <harald.baayen@uni-tuebingen.de>, Elnaz Shafaei-Bajestan <elnaz.shafaei-bajestan@uni-tuebingen.de>
Initial release
2019-01-28

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.