Statistics 196A, Education 401D  Spring 2017
    Multilevel Modeling Using R

David Rogosa Sequoia 224,   rag{AT}stat{DOT}stanford{DOT}edu   Office hours: Class meeting days, 5:30 - 6:30
Course web page:

                To see full course materials from Spring 2016 go here

From explorecourses
  STATS 196A (EDUC 401D): Multilevel Modeling Using R
Multilevel data analysis examples using R. 
Topics include: two-level nested data, growth curve modeling, generalized linear models for counts and categorical data, 
three-level analyses. For more information, see course website:
Terms: Spr | Units: 1 | Grading: Satisfactory/No Credit
Instructors: Rogosa, D. (PI) 
STATS 196A | 1 units | Class # 19357 | Section 01 | Grading: Satisfactory/No Credit | WKS |  
Wed 3:30 PM - 5:20 PM at Littlefield 107 with Rogosa, D. (PI) 
Instructors: Rogosa, D. (PI) 
Notes: Class meets on  April 12, April 19, April 26, May 3, May 17.
 Course Schedule
Five (2hr) mtgs W 3:30 - 5:20 on April 12, April 19, April 26, May 3, May 17.  Littlefield 107
 Weeks 1 - 4. 
    a. Introduction: Basic analyses for two-level nested data, normal models  (UK Exam data)
    b. Additional two-level (normal) models: experimental designs (Dyestuff), longitudinal data (growth curves, sleepstudy), observational data (High School and Beyond) 
    c. Generalized linear mixed models for counts and categorical outcomes 
    d. Three-level analyses (nested data and longitudinal data)    
    e. Specialized applications (as time permits):  regression diagnostics, power calculations and design, ecological inference, survival analysis, nonlinear functional forms, mediation analysis, propensity scores and matching, imputation, item response theory
 Week 5. Student presentations of multilevel data analyses  
For the 1-unit enrollment in this short course, students are expected to engage in the four presentation class sessions, and for the fifth session each student makes a short (~10 min) presentation of a relevant data analysis they have conducted.

Note to auditors. We will have room for auditors.
The Registrar does have a form (no-fee) for faculty, staff, post-docs: Application for Auditor or Permit to Attend (PTA) Status   

Core Sources
Many of the example presented in this short course are described in Examples from Multilevel Software Comparative Reviews  Douglas Bates.    Code version of MlmSoftRev
R-package containing mlmRev data examples.     Bates talk on mlmRev      U Bristol documentation      Additional examples in core package lme4
Another set of examples: lmer for SAS PROC MIXED Users Douglas Bates Department of Statistics University of Wisconsin Madison    Data sets from SAS System for Mixed Models
Overviews and additional examples from Doug Bates:
lme4: Mixed-effects modeling with R  February 17, 2010 Springer (chapters). An merged version of Bates book: lme4: Mixed-effects modeling with R January 11, 2010
R Journal intro Fitting linear mixed models in R Using the lme4 package Douglas Bates (pp.27-30)
Collection of all Doug Bates lme4 talks      Fitting linear mixed-effects models using lme4, Journal of Statistical Software Douglas Bates Martin Machler Ben Bolker.       Technical topics: Mixed models in R using the lme4 package Part 4: Theory of linear mixed models
HSB and growth curve examples in  John Fox lme tutorial

Current version of R is R version 3.3.3 released on 2017-03-06. For references and software: The R Project for Statistical Computing   Closest download mirror is Berkeley

A recent text (potentially) provides more infrastructure for this short course, but sadly it has many shortcomings. This text has free access at Stanford via      Multilevel Modeling Using R        Chapman & Hall/CRC Statistics in the Social and Behavioral Sciences Published:June 23, 2014 by CRC Press
     Journal of Statistical Software Book Review
Book website, including data

4/20  In sleuthing the lmList issues, I came across a nice document: Mixed-effects models, Remko Duursma, Jeff Powell  Hawkesbury Institute for the Environment, Western Sydney University. September 2016.  HIE Datasets

Week 1 April 12
1. Introductory Example. Goldstein Exam Data.     Exam {mlmRev}  UK HS data.   Subset: Coed schools exam data, mixed schools, cleaned
    a. Introductory descriptive approaches for gender gap analysis (Smart First Year Student analyses using lmList, additional plots).
    b. Various lmer analyses for gender gap.
             Rogosa R-session     basic plots    models used             Stat 209 Gender gap data analysis. scanned class handout
     c. Residual plots, add-on regression diagnostics: packages   HLMdiaginfluence.ME
           Rogosa session with Exam data (week 1) (ascii)         resulting plots
     d. more P-values, tests add-ons to lmer. Faraway text addendums: Inferential Methods for Linear Mixed Models
4/20 update on Faraway document. Appears this useful note has been removed from the internet (the U of Bath host is his home institution) but not from Google cache so you can get it from this and the useful links to his text and examples still work. Note we used afex in the Exam data example to provide supplemental p-values, for those with the desire. Note also the Google cache has a snapshot from 4/12 so if I had gotten to this in the first class mtg, the doc would have been there.

2. Growth Curve Modeling exercise, Brain Volume Data Analysis. analyses from "Variation in longitudinal trajectories of regional brain volumes of healthy men and women (ages 10 to 85 years) measured with atlas-based parcellation of MRI"     cartoon plot of Lateral Ventricles data;     actual data plot of Lateral Ventricles data;    development of lmer (mixed effect) growth models

Week 2 April 19
0. Exam data example linked week1. Complete parts b, c, d.     Plots for random, fixed effects.
1. Data from designed experiments.
     a. Dyestuff data, Bates book, Chapter 1 (sec 1.2, 1.3)      Rogosa Dyestuff session
     b. Penicillin data (also Pastes, ratbrain), Bates book, Chapter 2.  From Doug Bates presentation
2. Two-level nested (normal) data recap.   Brief overview of HSB (High School and Beyond) analysis (from Stat209): plots and model.
      a full single Bryk dataset (longform)              (abbreviated) Rogosa R-session  Bryk data        plots, Rogosa R-session
new! 4/20 side-by-side boxplot creation and lmList subset issue
     A nice teaching document from Indiana that does HSB data with every known statistical package (including lmer)
3. Growth Curve models and analysis. Sleepstudy example (from Stat222).
     Sleepstudy class handout, pdf scan     [more Doug Bates Slides (pdf pages 8-28) ]        Individual plots (frame-by-frame)       Plot of straight-line fits         
4. Start Generalized Linear Mixed Models: counts and proportions.
    nice overview: Generalized Linear Mixed Models   from Encyclopedia of Statistics in Behavioral Science.   

Week 3 April 26
0. Two-level normal model wrap-up. HSB boxplot update (linked above). Matrix Formulation for Mixed Effects Models (growth curves and nested data).
      Main topic:   Generalized Linear Mixed Models: counts and proportions.
    nice overview: Generalized Linear Mixed Models   from Encyclopedia of Statistics in Behavioral Science.   
1.        Dichotomous outcomes, glmer analysis examples.
    a. Respiratory clinical trial from HSAUR.     lmList does logistic, introducing glmer      lmList, glmer for respiration data (placebo group)
    b. Contraception (Bangladesh) use from Bates review         Rogosa R-session
    c. Test scores (pass/fail outcome) from Ch 8, Multilevel Modeling Using R.    Rogosa R-session
2. Count outcome, GLMM poisson models.
        a.   Count data: Contagious bovine pleuropneumonia, data(cbpp) in lme4.    Rogosa R-session     herd plots
        b.  Another count data example from mlmRev package,       data(Mmmec): Malignant Melanoma Mortality in the European Community associated with the impact of UV radiation exposure.     Rogosa glmer session

hglm -- a different package for fitting hierarchical generalized linear models. R Journal December 2010.

Week 4 May 3

0. Revisit Mmmec example analysis    Rogosa session

1. Three-level (and above) lmer examples.
Measured outcomes
  a. Achieve data from Multilevel Modeling Using R book.    Rogosa R-session
  b. example from mlmRev package, data(Chem97): Scores on A-level Chemistry in 1997.    Rogosa R-session
Count outcome.
  c. data(Mmmec): Malignant Melanoma Mortality in the European Community associated with the impact of UV radiation exposure.      Rogosa 3-level session

2.     Special and Specialized Multi-level Topics:
From week3 hglm -- a different package for fitting hierarchical generalized linear models. R Journal December 2010.
A. Nonlinear Models. nlmer in lme4    Bates presentation    Orange trees, logistic, in Stat222 (week3)
B. Extensions of lme4 modeling: npmlreg Nonparametric Maximum Likelihood (NPML) estimation; hglm    Hierarchical Generalized Linear Models,
    Package RLRsim Title Exact (Restricted) Likelihood Ratio Tests for Mixed and Additive Models    An Introduction to merTools
C. Multilevel Survival Analysis.
Mixed effects (Frailty) survival models. Package coxme Terry Therneau July 2014: Cox proportional hazards models containing Gaussian random effects, also known as frailty models coxme manual. Maintainer Terry Therneau. Mixed Effects Cox Models Terry Therneau Mayo Clinic June 15, 2015.     Additional materials.   frailtyHL: A Package for Fitting Frailty Models with H-likelihood
            Stat222 coxme handout      plain text version
D. Mediation Analysis Package multilevel    Package mediation  package vignette
E. Propensity Score and Matching Methods.  Package matchMulti   Title Optimal Multilevel Matching using a Network Algorithm     Package multilevelPSA Title Multilevel Propensity Score Analysis
F. Ecological Inference R-package eiPack: R x C Ecological Inference and Higher-Dimension Data Management.  R News Oct 2007  
G. Multiple Imputation. Package mitml Title Tools for Multiple Imputation in Multilevel Modeling
H. Power calculations and Design;
   Package pamm Title Power Analysis for Random Effects in Mixed Models
   Package simr Title Power Analysis for Generalised Linear Mixed Models by Simulation.
    longpower power and sample size for linear models of longitudinal data
    Package MultiRR Title Bias, Precision, and Power for Multi-Level Random Regression

Week 5 May 17
Student presentations, multilevel analysis examples.