Mixing it up: Mixed Models Tracy Tomlinson December 11, 2009 Tracy Tomlinson December 11, 2009.

Slides:



Advertisements
Similar presentations
Multilevel modelling short course
Advertisements

Week 2 – PART III POST-HOC TESTS. POST HOC TESTS When we get a significant F test result in an ANOVA test for a main effect of a factor with more than.
Hierarchical Linear Modeling: An Introduction & Applications in Organizational Research Michael C. Rodriguez.
1-Way Analysis of Variance
Topic 12: Multiple Linear Regression
Research Support Center Chongming Yang
GENERAL LINEAR MODELS: Estimation algorithms
Statistical Analysis Overview I Session 2 Peg Burchinal Frank Porter Graham Child Development Institute, University of North Carolina-Chapel Hill.
SPH 247 Statistical Analysis of Laboratory Data 1April 2, 2013SPH 247 Statistical Analysis of Laboratory Data.
1 Chapter 4 Experiments with Blocking Factors The Randomized Complete Block Design Nuisance factor: a design factor that probably has an effect.
Chapter 4 Randomized Blocks, Latin Squares, and Related Designs
Using Multilevel Modeling to Analyze Longitudinal Data Mark A. Ferro, PhD Offord Centre for Child Studies Lunch & Learn Seminar Series January 22, 2013.
STA305 week 31 Assessing Model Adequacy A number of assumptions were made about the model, and these need to be verified in order to use the model for.
6-1 Introduction To Empirical Models 6-1 Introduction To Empirical Models.
HLM – ESTIMATING MULTI-LEVEL MODELS Hierarchical Linear Modeling.
Some Terms Y =  o +  1 X Regression of Y on X Regress Y on X X called independent variable or predictor variable or covariate or factor Which factors.
LECTURE 13 ANALYSIS OF COVARIANCE AND COVARIANCE INTERACTION and ATI (Aptitude-Treatment Interaction)
Additional Topics in Regression Analysis
ANalysis Of VAriance (ANOVA) Comparing > 2 means Frequently applied to experimental data Why not do multiple t-tests? If you want to test H 0 : m 1 = m.
Clustered or Multilevel Data
Experimental Design & Analysis
Mixed models Various types of models and their relation
13-1 Designing Engineering Experiments Every experiment involves a sequence of activities: Conjecture – the original hypothesis that motivates the.
Incomplete Block Designs
Analysis of Variance & Multivariate Analysis of Variance
Longitudinal Data Analysis: Why and How to Do it With Multi-Level Modeling (MLM)? Oi-man Kwok Texas A & M University.
Analysis of Clustered and Longitudinal Data
Introduction to Multilevel Modeling Using SPSS
SAS Lecture 5 – Some regression procedures Aidan McDermott, April 25, 2005.
Issues in Experimental Design Reliability and ‘Error’
Chapter Outline 5.0 PROC GLM
Fixed vs. Random Effects Fixed effect –we are interested in the effects of the treatments (or blocks) per se –if the experiment were repeated, the levels.
More complicated ANOVA models: two-way and repeated measures Chapter 12 Zar Chapter 11 Sokal & Rohlf First, remember your ANOVA basics……….
G Lecture 5 Example fixed Repeated measures as clustered data
Hierarchical Linear Modeling (HLM): A Conceptual Introduction Jessaca Spybrook Educational Leadership, Research, and Technology.
Biostatistics Case Studies 2007 Peter D. Christenson Biostatistician Session 3: Incomplete Data in Longitudinal Studies.
Psychology 301 Chapters & Differences Between Two Means Introduction to Analysis of Variance Multiple Comparisons.
Randomized Block Design (Kirk, chapter 7) BUSI 6480 Lecture 6.
Discussion 3 1/20/2014. Outline How to fill out the table in the appendix in HW3 What does the Model statement do in SAS Proc GLM ( please download lab.
Multilevel Linear Models Field, Chapter 19. Why use multilevel models? Meeting the assumptions of the linear model – Homogeneity of regression coefficients.
Multilevel Data in Outcomes Research Types of multilevel data common in outcomes research Random versus fixed effects Statistical Model Choices “Shrinkage.
Repeated Measurements Analysis. Repeated Measures Analysis of Variance Situations in which biologists would make repeated measurements on same individual.
Multilevel Linear Modeling aka HLM. The Design We have data at two different levels In this case, 7,185 students (Level 1) Nested within 160 Schools (Level.
The Completely Randomized Design (§8.3)
BUSI 6480 Lecture 8 Repeated Measures.
Multi-level Analysis Recognizing the Problem Maureen Smith, MD PhD Depts. of Population Health Sciences and Family Medicine University of Wisconsin-Madison.
2nd meeting: Multilevel modeling: intra class correlation Subjects for today:  Multilevel data base construction  The difference between single level.
Topic 30: Random Effects. Outline One-way random effects model –Data –Model –Inference.
Topic 26: Analysis of Covariance. Outline One-way analysis of covariance –Data –Model –Inference –Diagnostics and rememdies Multifactor analysis of covariance.
PSYC 3030 Review Session April 19, Housekeeping Exam: –April 26, 2004 (Monday) –RN 203 –Use pencil, bring calculator & eraser –Make use of your.
1 Overview of Experimental Design. 2 3 Examples of Experimental Designs.
Single-Factor Studies KNNL – Chapter 16. Single-Factor Models Independent Variable can be qualitative or quantitative If Quantitative, we typically assume.
General Linear Model.
FIXED AND RANDOM EFFECTS IN HLM. Fixed effects produce constant impact on DV. Random effects produce variable impact on DV. F IXED VS RANDOM EFFECTS.
IE241: Introduction to Design of Experiments. Last term we talked about testing the difference between two independent means. For means from a normal.
Analysis of Experiments
Tutorial I: Missing Value Analysis
1 Statistics 262: Intermediate Biostatistics Regression Models for longitudinal data: Mixed Models.
The Mixed Effects Model - Introduction In many situations, one of the factors of interest will have its levels chosen because they are of specific interest.
CRD, Strength of Association, Effect Size, Power, and Sample Size Calculations BUSI 6480 Lecture 4.
ANOVA Overview of Major Designs. Between or Within Subjects Between-subjects (completely randomized) designs –Subjects are nested within treatment conditions.
Topic 27: Strategies of Analysis. Outline Strategy for analysis of two-way studies –Interaction is not significant –Interaction is significant What if.
ANCOVA.
Biostatistics Case Studies Peter D. Christenson Biostatistician Session 3: Missing Data in Longitudinal Studies.
G Lecture 71 Revisiting Hierarchical Mixed Models A General Version of the Model Variance/Covariances of Two Kinds of Random Effects Parameter Estimation.
Psychology 202a Advanced Psychological Statistics December 8, 2015.
12 Inferential Analysis.
CHAPTER 29: Multiple Regression*
12 Inferential Analysis.
Fixed, Random and Mixed effects
Presentation transcript:

Mixing it up: Mixed Models Tracy Tomlinson December 11, 2009 Tracy Tomlinson December 11, 2009

Outline  What are fixed effects  What are random effects  How do I know if my effects are fixed or random  Why do I care about fixed and random effects  Mixed models  SAS and mixed models  SPSS and mixed models  What are fixed effects  What are random effects  How do I know if my effects are fixed or random  Why do I care about fixed and random effects  Mixed models  SAS and mixed models  SPSS and mixed models

Fixed Effects  Specific levels of interest of a factor are selected  May use all levels or a subset of levels  These are the specific levels of interest  Interest in comparing these levels  Inference only for these levels  Specific levels of interest of a factor are selected  May use all levels or a subset of levels  These are the specific levels of interest  Interest in comparing these levels  Inference only for these levels

Random Effects  Levels of a factor selected from a probability distribution  Interested in the extent to which the random factor accounts for variance in the dependent variable  May be a control variable or a variable of interest  Rather than being interested in the individual means across the levels of the fixed factor, we are interested in the variance of means across the levels of a random factor  Levels of a factor selected from a probability distribution  Interested in the extent to which the random factor accounts for variance in the dependent variable  May be a control variable or a variable of interest  Rather than being interested in the individual means across the levels of the fixed factor, we are interested in the variance of means across the levels of a random factor

Fixed Effects: One Factor  Running a clinical trial in which a drug is administered at four different dose levels  Model Equation: Y ij =  +  i + e ij  i corresponds to 1, 2, 3, or 4 dose levels   is the effect of the drug on the mean  Running a clinical trial in which a drug is administered at four different dose levels  Model Equation: Y ij =  +  i + e ij  i corresponds to 1, 2, 3, or 4 dose levels   is the effect of the drug on the mean

Random Effects: One Factor  Clinical trial using a new drug at 20 different clinics in DC selected at random  Model Equation:  Where i corresponds to the 20 clinics  Where  represents the mean of all dosages in the population, not just the observed study  The effects of a i are random variables with mean 0 and variance  a 2  Clinical trial using a new drug at 20 different clinics in DC selected at random  Model Equation:  Where i corresponds to the 20 clinics  Where  represents the mean of all dosages in the population, not just the observed study  The effects of a i are random variables with mean 0 and variance  a 2 Y ij =  + a i + e ij Y ij =  +  i + e ij Y ij =  + i + e ij

Fixed Versus Random  Levels of a factor chosen of specific interest  Interested in the means across the chosen levels of the factor  Levels of a factor chosen of specific interest  Interested in the means across the chosen levels of the factor  Levels of a factor selected from a probability distribution  Interested in the variance of means across the levels of the factor

Determining Fixed and Random Effects  YOU determine what effects you have!  As the researcher you select your levels of interest:  Are the specific levels of interest?  Are you interested in comparing group means?  Did you sample the levels from a larger population?  YOU determine the population!  YOU determine what effects you have!  As the researcher you select your levels of interest:  Are the specific levels of interest?  Are you interested in comparing group means?  Did you sample the levels from a larger population?  YOU determine the population!

Fixed or Random Effect? Is it reasonable to assume that the levels of the factor come from a probability distribution? Fixed FactorRandom Factor NoYes

Fixed or Random Effect? Do you care about comparing the specific factor level means? Fixed FactorRandom Factor NoYes

Why does it Matter, or Does it?  Assumptions about random effects differ from those for fixed effects  Error terms are different depending on fixed versus random effects  Random effects have additional error terms beyond  2  The effects of a i are random variables with mean 0 and variance  a 2  Important for inferential statistics  Assumptions about random effects differ from those for fixed effects  Error terms are different depending on fixed versus random effects  Random effects have additional error terms beyond  2  The effects of a i are random variables with mean 0 and variance  a 2  Important for inferential statistics

Fixed and Random Effects Error Terms  Fixed effects error = MS error = MS within =  2  Random effects error: Depends on the nature of the random and fixed effects  Fixed effects error = MS error = MS within =  2  Random effects error: Depends on the nature of the random and fixed effects

Two Factor Model  A fixed, B fixed  Y ij =  +  i +  j + (  ) ij + e ij  A fixed, B random  Y ij =  +  i + b j + (ab) ij + e ij  A random, B fixed  Y ij =  +  i + b j + (ab) ij + e ij  A random, B random  Y ij =  + a i +  j + (ab) ij + e ij  A fixed, B fixed  Y ij =  +  i +  j + (  ) ij + e ij  A fixed, B random  Y ij =  +  i + b j + (ab) ij + e ij  A random, B fixed  Y ij =  +  i + b j + (ab) ij + e ij  A random, B random  Y ij =  + a i +  j + (ab) ij + e ij One error term: MS within  e 2 Two error terms: 1) MS within  e 2 2) MS ab  ab 2

Two Factor Model  A fixed, B fixed  Y ij =  +  i +  j + (  ) ij + e ij  A fixed, B random  Y ij =  +  i + b j + (ab) ij + e ij  A random, B fixed  Y ij =  +  i + b j + (ab) ij + e ij  A random, B random  Y ij =  + a i +  j + (ab) ij + e ij  A fixed, B fixed  Y ij =  +  i +  j + (  ) ij + e ij  A fixed, B random  Y ij =  +  i + b j + (ab) ij + e ij  A random, B fixed  Y ij =  +  i + b j + (ab) ij + e ij  A random, B random  Y ij =  + a i +  j + (ab) ij + e ij In all cases the highest level interaction term is tested against MS within  e 2

Two Factor Model  A fixed, B fixed  Y ij =  +  i +  j + (  ) ij + e ij  A fixed, B random  Y ij =  +  i + b j + (ab) ij + e ij  A random, B fixed  Y ij =  +  i + b j + (ab) ij + e ij  A random, B random  Y ij =  + a i +  j + (ab) ij + e ij  A fixed, B fixed  Y ij =  +  i +  j + (  ) ij + e ij  A fixed, B random  Y ij =  +  i + b j + (ab) ij + e ij  A random, B fixed  Y ij =  +  i + b j + (ab) ij + e ij  A random, B random  Y ij =  + a i +  j + (ab) ij + e ij All effects tested against MS within  e 2

Two Factor Model  A fixed, B fixed  Y ij =  +  i +  j + (  ) ij + e ij  A fixed, B random  Y ij =  +  i + b j + (ab) ij + e ij  A random, B fixed  Y ij =  +  i + b j + (ab) ij + e ij  A random, B random  Y ij =  + a i +  j + (ab) ij + e ij  A fixed, B fixed  Y ij =  +  i +  j + (  ) ij + e ij  A fixed, B random  Y ij =  +  i + b j + (ab) ij + e ij  A random, B fixed  Y ij =  +  i + b j + (ab) ij + e ij  A random, B random  Y ij =  + a i +  j + (ab) ij + e ij Fixed effect A tested against MS ab  ab 2 Random effect B tested against MS within  e 2

Two Factor Model  A fixed, B fixed  Y ij =  +  i +  j + (  ) ij + e ij  A fixed, B random  Y ij =  +  i + b j + (ab) ij + e ij  A random, B fixed  Y ij =  +  i + b j + (ab) ij + e ij  A random, B random  Y ij =  + a i +  j + (ab) ij + e ij  A fixed, B fixed  Y ij =  +  i +  j + (  ) ij + e ij  A fixed, B random  Y ij =  +  i + b j + (ab) ij + e ij  A random, B fixed  Y ij =  +  i + b j + (ab) ij + e ij  A random, B random  Y ij =  + a i +  j + (ab) ij + e ij Random effect A tested against MS within  e 2 Fixed effect B tested against MS ab  ab 2

Two Factor Model  A fixed, B fixed  Y ij =  +  i +  j + (  ) ij + e ij  A fixed, B random  Y ij =  +  i + b j + (ab) ij + e ij  A random, B fixed  Y ij =  + a i +  j + (ab) ij + e ij  A random, B random  Y ij =  + a i + b j + (ab) ij + e ij  A fixed, B fixed  Y ij =  +  i +  j + (  ) ij + e ij  A fixed, B random  Y ij =  +  i + b j + (ab) ij + e ij  A random, B fixed  Y ij =  + a i +  j + (ab) ij + e ij  A random, B random  Y ij =  + a i + b j + (ab) ij + e ij All effects tested against MS within  e 2

Fixed and Random Effects and Effect Size  Effect size estimates assume effects are fixed or random  Fixed   2   2  Random    Effect size estimates assume effects are fixed or random  Fixed   2   2  Random  

Why does it Matter, or Does it?  Assumptions about random effects differ from those for fixed effects  Error terms are different depending on fixed versus random effects  Random effects have additional error terms beyond  2  The effects of a i are random variables with mean 0 and variance  a 2  Important for inferential statistics  Interpretation differs  Fixed effects interpretations constrained to the levels of the factor(s) in the study  Random effects interpretations have a broader generalization to the population of interest  Assumptions about random effects differ from those for fixed effects  Error terms are different depending on fixed versus random effects  Random effects have additional error terms beyond  2  The effects of a i are random variables with mean 0 and variance  a 2  Important for inferential statistics  Interpretation differs  Fixed effects interpretations constrained to the levels of the factor(s) in the study  Random effects interpretations have a broader generalization to the population of interest

Mixed Models  Contains both fixed and random effects  Randomized blocks designs  Nested/ Hierarchical designs  Split-plot designs  Clustered designs  Repeated measures  Analysis comparable  One way ANOVA  Two way ANOVA  ANCOVA  Contains both fixed and random effects  Randomized blocks designs  Nested/ Hierarchical designs  Split-plot designs  Clustered designs  Repeated measures  Analysis comparable  One way ANOVA  Two way ANOVA  ANCOVA

Linear Mixed Model (LMM) Handles data where observations are not independent LMM correctly models correlated errors, whereas procedures in the general linear model family (GLM) usually do not Nature [structure] of the correlation must be correctly modeled for the tests of mean differences to be unbiased LMM is a further generalization of GLM to better support analysis of a continuous dependent for: Random effects Hierarchical effects Repeated measures Handles data where observations are not independent LMM correctly models correlated errors, whereas procedures in the general linear model family (GLM) usually do not Nature [structure] of the correlation must be correctly modeled for the tests of mean differences to be unbiased LMM is a further generalization of GLM to better support analysis of a continuous dependent for: Random effects Hierarchical effects Repeated measures

Mixed Models Randomized Blocks Example  Testing four drugs and assigning n subjects to one of 4 groups carefully matched by demographic variables. Each person in the four groups gets one of the drugs.  Fixed effect of treatment  Random effect of blocks Y ij =  +  i + b j + e ij   represents unknown fixed parameters - intercept and the four drug treatment effects  b j and e ij are random variables representing blocks and error  b j assumed to have an error of  b 2  Error (e ij ) assumed to have an error of  2  Testing four drugs and assigning n subjects to one of 4 groups carefully matched by demographic variables. Each person in the four groups gets one of the drugs.  Fixed effect of treatment  Random effect of blocks Y ij =  +  i + b j + e ij   represents unknown fixed parameters - intercept and the four drug treatment effects  b j and e ij are random variables representing blocks and error  b j assumed to have an error of  b 2  Error (e ij ) assumed to have an error of  2

Mixed Models Hierarchical Example  Using four dosage levels of a drug in 20 clinics. In each clinic each patient was randomly assigned to one of the 4 dose levels. Y ijk =  +  i + b j + c ij + e ijk  Where a i, b j, and c ij are the effects due to drug dose i, clinic j, and clinic-by-dose interaction  IF you assume that the 20 clinics are not sampled this experiment may now have only fixed effects Y ijk =  +  i +  j + c ij + e ijk  Using four dosage levels of a drug in 20 clinics. In each clinic each patient was randomly assigned to one of the 4 dose levels. Y ijk =  +  i + b j + c ij + e ijk  Where a i, b j, and c ij are the effects due to drug dose i, clinic j, and clinic-by-dose interaction  IF you assume that the 20 clinics are not sampled this experiment may now have only fixed effects Y ijk =  +  i +  j + c ij + e ijk

Mixed Models Repeated Measures and Split-Plot  Three drug treatments randomly assigned to subjects with subjects observed at 1, 2, …, 7, and 8 hours post-treatment Where Y ijk =  +  i + s(  ) ij +  k + (  ) ik + e ijk  Where  represents treatment effects   represents time (or hour) effects  s(  ) represents the random subject within treatment effects  Three drug treatments randomly assigned to subjects with subjects observed at 1, 2, …, 7, and 8 hours post-treatment Where Y ijk =  +  i + s(  ) ij +  k + (  ) ik + e ijk  Where  represents treatment effects   represents time (or hour) effects  s(  ) represents the random subject within treatment effects

Mixed Models  Contains both fixed and random effects  Randomized blocks designs  Nested/ Hierarchical designs  Split-plot designs  Clustered designs  Repeated measures  Analysis comparable  One way ANOVA  Two way ANOVA  ANCOVA  Contains both fixed and random effects  Randomized blocks designs  Nested/ Hierarchical designs  Split-plot designs  Clustered designs  Repeated measures  Analysis comparable  One way ANOVA  Two way ANOVA  ANCOVA

PROC MIXED  Specifically designed to fit mixed effect models.  It can model:  Random and mixed effect data  Repeated measures  Spatial data  Data with heterogeneous variances and autocorrelated observations  The MIXED procedure is more general than GLM in the sense that it gives a user more flexibility in specifying the correlation structures, particularly useful in repeated measures and random effect models  GLM uses OLS estimation  Mixed uses ML, REML, or MIVQUE0 estimation  Specifically designed to fit mixed effect models.  It can model:  Random and mixed effect data  Repeated measures  Spatial data  Data with heterogeneous variances and autocorrelated observations  The MIXED procedure is more general than GLM in the sense that it gives a user more flexibility in specifying the correlation structures, particularly useful in repeated measures and random effect models  GLM uses OLS estimation  Mixed uses ML, REML, or MIVQUE0 estimation

PROC MIXED v. GLM  The PROC MIXED syntax is similar to the syntax of PROC GLM.  The random effects and repeated statements are used differently  Random effects are not listed in the model statement for MIXED  GLM has MEANS and LSMEANS statements  MIXED has only the LSMEANS statement  The PROC MIXED syntax is similar to the syntax of PROC GLM.  The random effects and repeated statements are used differently  Random effects are not listed in the model statement for MIXED  GLM has MEANS and LSMEANS statements  MIXED has only the LSMEANS statement

General SAS Mixed Model Syntax  PROC MIXED options; options CLASS variable-list; MODEL dependent=fixed effects/ options;MODEL dependent=fixed effects/ options; RANDOM random effects / options; RANDOM random effects / options; REPEATED repeated effects / options;REPEATED repeated effects / options; CONTRAST 'label' fixed-effect values | random-effect values/ options; CONTRAST 'label' fixed-effect values | random-effect values/ options; ESTIMATE 'label' fixed-effect values | random-effect values/ options;ESTIMATE 'label' fixed-effect values | random-effect values/ options; LSMEANS fixed-effects / options;LSMEANS fixed-effects / options; MAKE 'table' OUT= SAS-data-set ;MAKE 'table' OUT= SAS-data-set ; RUN;  PROC MIXED options; options CLASS variable-list; MODEL dependent=fixed effects/ options;MODEL dependent=fixed effects/ options; RANDOM random effects / options; RANDOM random effects / options; REPEATED repeated effects / options;REPEATED repeated effects / options; CONTRAST 'label' fixed-effect values | random-effect values/ options; CONTRAST 'label' fixed-effect values | random-effect values/ options; ESTIMATE 'label' fixed-effect values | random-effect values/ options;ESTIMATE 'label' fixed-effect values | random-effect values/ options; LSMEANS fixed-effects / options;LSMEANS fixed-effects / options; MAKE 'table' OUT= SAS-data-set ;MAKE 'table' OUT= SAS-data-set ; RUN;

PROC MIXED statement PROC MIXED options; PROC MIXED noclprint covtest ;  The NOCLPRINT option prevents the printing of the CLASS level information  The first time you run the program you probably don’t want to include noclprint  When there are lots of group units, use NOCLPRINT to suppress the printing of group names.  The COVTEST option tells SAS that you would like hypothesis tests for the variance and covariance components. PROC MIXED options; PROC MIXED noclprint covtest ;  The NOCLPRINT option prevents the printing of the CLASS level information  The first time you run the program you probably don’t want to include noclprint  When there are lots of group units, use NOCLPRINT to suppress the printing of group names.  The COVTEST option tells SAS that you would like hypothesis tests for the variance and covariance components.

CLASS statement CLASS variable-list; CLASS IDpatient IDclinic;  The CLASS statement indicates that SCHOOL is a classification variable whose values do not contain quantitative information  The variables that we want SAS to treat as categorical variables go here.  Variables that are characters (e.g., city names) must be on this line (it won’t run otherwise). CLASS variable-list; CLASS IDpatient IDclinic;  The CLASS statement indicates that SCHOOL is a classification variable whose values do not contain quantitative information  The variables that we want SAS to treat as categorical variables go here.  Variables that are characters (e.g., city names) must be on this line (it won’t run otherwise).

MODEL statement MODEL dependent = fixed effects/options; MODEL dosage = /solution;  If you have no fixed effects you would have no independent variables listed in the model statement  /solution option asks SAS to print the estimates for the fixed effects  Intercept is included as a default in SAS  If you would like to fit a model without the intercept you add the /NOINT option to the model statement MODEL dependent = fixed effects/options; MODEL dosage = /solution;  If you have no fixed effects you would have no independent variables listed in the model statement  /solution option asks SAS to print the estimates for the fixed effects  Intercept is included as a default in SAS  If you would like to fit a model without the intercept you add the /NOINT option to the model statement

Random statement RANDOM intercept /sub=IDclinic;  By default there is always at least one random effect, usually the lowest-level residual  You can specify the intercept on the RANDOM statement: This indicates the presence of a second random effect and the intercept should be treated not only as a fixed effect but also as a random effect  The SUB option on the RANDOM statement specifies the multilevel structure, indicating how the individuals (level-1 units) are divided into higher level groups (level-2 units) RANDOM intercept /sub=IDclinic;  By default there is always at least one random effect, usually the lowest-level residual  You can specify the intercept on the RANDOM statement: This indicates the presence of a second random effect and the intercept should be treated not only as a fixed effect but also as a random effect  The SUB option on the RANDOM statement specifies the multilevel structure, indicating how the individuals (level-1 units) are divided into higher level groups (level-2 units)

General SAS Mixed Model Syntax PROC MIXED options; options CLASS variable-list; MODEL dependent=fixed effects/ options;MODEL dependent=fixed effects/ options; RANDOM random effects / options; RANDOM random effects / options; REPEATED repeated effects / options;REPEATED repeated effects / options; CONTRAST 'label' fixed-effect values | random-effect values/ options; CONTRAST 'label' fixed-effect values | random-effect values/ options; ESTIMATE 'label' fixed-effect values | random-effect values/ options;ESTIMATE 'label' fixed-effect values | random-effect values/ options; LSMEANS fixed-effects / options;LSMEANS fixed-effects / options; MAKE 'table' OUT= SAS-data-set ;MAKE 'table' OUT= SAS-data-set ; RUN; PROC MIXED options; options CLASS variable-list; MODEL dependent=fixed effects/ options;MODEL dependent=fixed effects/ options; RANDOM random effects / options; RANDOM random effects / options; REPEATED repeated effects / options;REPEATED repeated effects / options; CONTRAST 'label' fixed-effect values | random-effect values/ options; CONTRAST 'label' fixed-effect values | random-effect values/ options; ESTIMATE 'label' fixed-effect values | random-effect values/ options;ESTIMATE 'label' fixed-effect values | random-effect values/ options; LSMEANS fixed-effects / options;LSMEANS fixed-effects / options; MAKE 'table' OUT= SAS-data-set ;MAKE 'table' OUT= SAS-data-set ; RUN;

General SPSS Mixed Model Syntax Mixed dependent with independent /print=solution /fixed=fixed effects /random intercept random effects | subject(random effect grouping) covtype (options) /repeated = repeated effect | subject(repeated effect grouping) covtype (options). Mixed dependent with independent /print=solution /fixed=fixed effects /random intercept random effects | subject(random effect grouping) covtype (options) /repeated = repeated effect | subject(repeated effect grouping) covtype (options).

Recap Main Points Slide  Fixed versus random effects  Error terms  Effect size  Interpretation/inference  Sampling  Independence of observations  SAS and SPSS syntax for random and mixed models  Fixed versus random effects  Error terms  Effect size  Interpretation/inference  Sampling  Independence of observations  SAS and SPSS syntax for random and mixed models

For your Reading Pleasure  Schabenberger, O. (2006). SAS system for mixed models (Second Edition). Cary, NC: SAS Institute.  McCullagh, P., & Nelder, J. A. (1989). Generalized linear models (Second Edition). New York: Chapman and Hall.  McCulloch, C., & Searle, S. (2008) Generalized, linear, and mixed models (Second Edition). New York: Wiley.  Verbeke, G. E., & Molenberghs, G. (1997). Linear mixed models in practice: A SAS-oriented approach. New York: Springer.  Fahrmeir, L., & Tutz, G. (1994). Multivariate statistical modeling based on generalized linear models.  Heidelberg: Springer-Verlag. Lindsey, J. (1993). Models for repeated measurements. Oxford: Clarendon Press.  Singer website:  Schabenberger, O. (2006). SAS system for mixed models (Second Edition). Cary, NC: SAS Institute.  McCullagh, P., & Nelder, J. A. (1989). Generalized linear models (Second Edition). New York: Chapman and Hall.  McCulloch, C., & Searle, S. (2008) Generalized, linear, and mixed models (Second Edition). New York: Wiley.  Verbeke, G. E., & Molenberghs, G. (1997). Linear mixed models in practice: A SAS-oriented approach. New York: Springer.  Fahrmeir, L., & Tutz, G. (1994). Multivariate statistical modeling based on generalized linear models.  Heidelberg: Springer-Verlag. Lindsey, J. (1993). Models for repeated measurements. Oxford: Clarendon Press.  Singer website:

Data Example with PROC MIXED  High School and Beyond data example (Byrk & Raudenbush, 1992)  7,185 students in 160 schools  MATHACH: Student level (level-1) outcome is math achievement  SES: Student level (levl-1) covariate is socio- economic status  MEANSES: School-level (level-2) covariate of mean SES for the school  SECTOR: School-level (level-2) covariate of school type (dummy coded, public= 0 and Catholic=1)  High School and Beyond data example (Byrk & Raudenbush, 1992)  7,185 students in 160 schools  MATHACH: Student level (level-1) outcome is math achievement  SES: Student level (levl-1) covariate is socio- economic status  MEANSES: School-level (level-2) covariate of mean SES for the school  SECTOR: School-level (level-2) covariate of school type (dummy coded, public= 0 and Catholic=1) Singer (1998)

Random Effects Model  Unconditional means model examining the variation of MATHACH across schools  One-way random effects ANOVA model  Model Equation  Y ij =  +  j + r ij  SAS syntax  Unconditional means model examining the variation of MATHACH across schools  One-way random effects ANOVA model  Model Equation  Y ij =  +  j + r ij  SAS syntax proc mixed; class school; model mathach = ; random school;

MIXED Model Two-Level Approach  Level 1: students outcome (Y ij ) is expressed as the sum of an intercept for the students school (  0j ) and a random error term (r ij ) associated with the i th student in the j th school Y ij =  0j + r ij  Level 2: We express the school level intercept as the sum of an overall mean (  00 ) and a series of random deviations from that mean (  0j ).  0j =  00 +  0j  This leads to a model equation of Y ij =  00 +  0j + r ij  SAS syntax  Level 1: students outcome (Y ij ) is expressed as the sum of an intercept for the students school (  0j ) and a random error term (r ij ) associated with the i th student in the j th school Y ij =  0j + r ij  Level 2: We express the school level intercept as the sum of an overall mean (  00 ) and a series of random deviations from that mean (  0j ).  0j =  00 +  0j  This leads to a model equation of Y ij =  00 +  0j + r ij  SAS syntax proc mixed noclprint covtest; class school; model mathach = /solution; random intercept/sub=school;

Mixed Model Two-Level Approach Output Variance component for between school:  00 Variance component for within school:  2

SPSS for Random Effects Model SAS syntax proc mixed noclprint covtest; class school; model mathach = /solution; random intercept/sub=school; mixed mathach /print=solution /random intercept | subject(school). SPSS syntax SPSS output

Including Level-2 Predictors  School-level (level-2) predictor of MEANSES  Level 1: students outcome (Y ij ) is expressed as the sum of an intercept for the students school (  0j ) and a random error term (r ij ) associated with the i th student in the j th school Y ij =  0j + r ij  Level 2: We express the school level intercept as the sum of an overall mean (  00 ), MEANSES and a series of random deviations from that mean (  0j ).  0j =  00 +  01 MEANSES j +  0j  This leads to a model equation of Y ij = [  00 +  01 MEANSES j ] + [  0j + r ij ]  SAS syntax  School-level (level-2) predictor of MEANSES  Level 1: students outcome (Y ij ) is expressed as the sum of an intercept for the students school (  0j ) and a random error term (r ij ) associated with the i th student in the j th school Y ij =  0j + r ij  Level 2: We express the school level intercept as the sum of an overall mean (  00 ), MEANSES and a series of random deviations from that mean (  0j ).  0j =  00 +  01 MEANSES j +  0j  This leads to a model equation of Y ij = [  00 +  01 MEANSES j ] + [  0j + r ij ]  SAS syntax proc mixed noclprint covtest; class school; model mathach = meanses/solution ddfm=bw; random intercept/sub=school; Fixed Effects Random Effects Compute df for fixed effects with “between/ within”

SAS Output Fixed effect:  00 Fixed effect:  01 Random effect:  00 Random effect:  2

SPSS for Including Level-2 Predictor SAS syntax proc mixed noclprint covtest; class school; model mathach = meanses/solution ddfm=bw; random intercept/sub=school; mixed mathach with meanses /print=solution /fixed = meanses /random intercept | subject(school). SPSS syntax SPSS output

Including Level-1 Predictors  Student-level (level-1) predictor of SES  Level 1: students outcome (Y ij ) is expressed as a function of an intercept for the students school (  0j ), individual CSES (centered by MEANSES), and a random error term (r ij ) associated with the i th student in the j th school Y ij =  0j +  1j CSES ij +r ij  Level 2: We express the school level intercept as the sum of an overall mean (  00 ) and a series of random deviations from that mean (  0j ).  0j =  00 +  0j  0j =  10 +  1j  This leads to a model equation of Y ij = [  00 +  01 CSES j ] + [  0j +  1j (CSES)+ r ij ]  SAS syntax  Student-level (level-1) predictor of SES  Level 1: students outcome (Y ij ) is expressed as a function of an intercept for the students school (  0j ), individual CSES (centered by MEANSES), and a random error term (r ij ) associated with the i th student in the j th school Y ij =  0j +  1j CSES ij +r ij  Level 2: We express the school level intercept as the sum of an overall mean (  00 ) and a series of random deviations from that mean (  0j ).  0j =  00 +  0j  0j =  10 +  1j  This leads to a model equation of Y ij = [  00 +  01 CSES j ] + [  0j +  1j (CSES)+ r ij ]  SAS syntax proc mixed noclprint covtest noitprint; class school; model mathach = cses/solution ddfm=bw notest; random intercept cses/sub=school type = un; Fixed Effects Random Effects Don’t print iteration page Unstructured specification

SAS Output

Including Level-1 Predictors in SPSS Y ij = [  00 +  01 CSES j ] + [  0j +  1j (CSES)+ r ij ]  SAS syntax  SPSS syntax Y ij = [  00 +  01 CSES j ] + [  0j +  1j (CSES)+ r ij ]  SAS syntax  SPSS syntax proc mixed noclprint covtest noitprint; class school; model mathach = cses/solution ddfm=bw notest; random intercept cses/sub=school type = un; mixed mathach with cses /print=solution /fixed = cses /random intercept cses | subject(school) covtype(un).

Including Level-1 AND Level-2 Predictors  Model with the effect of students SES (CSES) and school SES (MEANSES) with a second level-2 factor of SECTOR Y ij =  0j +  1j CSES ij +r ij  0j =  00 +  01 MEANSES j +  02 SECTOR j +  0j  0j =  10 +  11 MEANSES j +  12 SECTOR j +  1j  This leads to a model equation of Y ij =  00 +  01 MEANSES j +  02 SECTOR j +  10 CSES ij +  11 MEANSES j (CSES ij ) +  12 SECTOR j (CSES ij ) +  0j +  1j (CSES ij ) + r ij  SAS syntax  Model with the effect of students SES (CSES) and school SES (MEANSES) with a second level-2 factor of SECTOR Y ij =  0j +  1j CSES ij +r ij  0j =  00 +  01 MEANSES j +  02 SECTOR j +  0j  0j =  10 +  11 MEANSES j +  12 SECTOR j +  1j  This leads to a model equation of Y ij =  00 +  01 MEANSES j +  02 SECTOR j +  10 CSES ij +  11 MEANSES j (CSES ij ) +  12 SECTOR j (CSES ij ) +  0j +  1j (CSES ij ) + r ij  SAS syntax proc mixed noclprint covtest noitprint; class school; model mathach = meanses sector cses meanses*cses sector*cses/solution ddfm=bw notest; random intercept cses/type=un sub=school;

SAS Output

Including Level-1 and Level-2 Predictors in SPSS Y ij =  00 +  01 MEANSES j +  02 SECTOR j +  10 CSES ij +  11 MEANSES j (CSES ij ) +  12 SECTOR j (CSES ij ) +  0j +  1j (CSES ij ) + r ij  SAS syntax  SPSS syntax Y ij =  00 +  01 MEANSES j +  02 SECTOR j +  10 CSES ij +  11 MEANSES j (CSES ij ) +  12 SECTOR j (CSES ij ) +  0j +  1j (CSES ij ) + r ij  SAS syntax  SPSS syntax proc mixed noclprint covtest noitprint; class school; model mathach = meanses sector cses meanses*cses sector*cses/solution ddfm=bw notest; random intercept cses/type=un sub=school; mixed mathach with meanses sector cses /print=solution /fixed = meanses sector cses meanses*cses sector*cses /random intercept cses | subject(school) covtype(un).