# NOT RUN {
data(sleepstudy, package = 'lme4')
ss <- lme4::lmer(Reaction ~ Days + (Days | Subject), sleepstudy)
# Cook's distance for individual observations
ss.cd.lev1 <- cooks.distance(ss)
# Cook's distance for each Subject
ss.cd.subject <- cooks.distance(ss, level = "Subject")
# }
# NOT RUN {
data(Exam, package = 'mlmRev')
fm <- lme4::lmer(normexam ~ standLRT * schavg + (standLRT | school), Exam)
# Cook's distance for individual observations
cd.lev1 <- cooks.distance(fm)
# Cook's distance for each school
cd.school <- cooks.distance(fm, level = "school")
# Cook's distance when school 1 is deleted
cd.school1 <- cooks.distance(fm, level = "school", delete = 1)
# }
# NOT RUN {
# MDFFITS for individual observations
ss.m1 <- mdffits(ss)
# MDFFITS for each Subject
ss.m.subject <- mdffits(ss, level = "Subject")
# }
# NOT RUN {
# MDFFITS for individual observations
m1 <- mdffits(fm)
# MDFFITS for each school
m.school <- mdffits(fm, level = "school")
# }
Run the code above in your browser using DataLab