Multilevel Models 3 Sociology 8811, Class 25 Copyright © 2007 by Evan Schofer Do not copy or distribute without permission.

Slides:



Advertisements
Similar presentations
Introduction Describe what panel data is and the reasons for using it in this format Assess the importance of fixed and random effects Examine the Hausman.
Advertisements

PANEL DATA 1. Dummy Variable Regression 2. LSDV Estimator
Multiple Regression Analysis
AMMBR - final stuff xtmixed (and xtreg) (checking for normality, random slopes)
AMMBR from xtreg to xtmixed (+checking for normality, random slopes)
Toolkit + “show your skills” AMMBR from xtreg to xtmixed (+checking for normality, and random slopes, and cross-classified models, and then we are almost.
Objectives 10.1 Simple linear regression
SC968: Panel Data Methods for Sociologists Random coefficients models.
1 FE Panel Data assumptions. 2 Assumption #1: E(u it |X i1,…,X iT,  i ) = 0.
Lecture 4 (Chapter 4). Linear Models for Correlated Data We aim to develop a general linear model framework for longitudinal data, in which the inference.
Repeated Measures, Part 3 May, 2009 Charles E. McCulloch, Division of Biostatistics, Dept of Epidemiology and Biostatistics, UCSF.
1 BINARY CHOICE MODELS: LOGIT ANALYSIS The linear probability model may make the nonsense predictions that an event will occur with probability greater.
Lecture 9 Today: Ch. 3: Multiple Regression Analysis Example with two independent variables Frisch-Waugh-Lovell theorem.
Advanced Panel Data Techniques
Objectives (BPS chapter 24)
Multilevel Models 4 Sociology 8811, Class 26 Copyright © 2007 by Evan Schofer Do not copy or distribute without permission.
Session 2. Applied Regression -- Prof. Juran2 Outline for Session 2 More Simple Regression –Bottom Part of the Output Hypothesis Testing –Significance.
Multinomial Logit Sociology 8811 Lecture 11 Copyright © 2007 by Evan Schofer Do not copy or distribute without permission.
Sociology 601 Class 19: November 3, 2008 Review of correlation and standardized coefficients Statistical inference for the slope (9.5) Violations of Model.
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.
Shall we take Solow seriously?? Empirics of growth Ania Nicińska Agnieszka Postępska Paweł Zaboklicki.
Chapter 12 Simple Regression
Multilevel Models 1 Sociology 229: Advanced Regression
Multilevel Models 2 Sociology 8811, Class 24
Multilevel Models 2 Sociology 229A, Class 18
Multilevel Models 1 Sociology 229A Copyright © 2008 by Evan Schofer Do not copy or distribute without permission.
Clustered or Multilevel Data
The Basics of Regression continued
1 Review of Correlation A correlation coefficient measures the strength of a linear relation between two measurement variables. The measure is based on.
Stat 217 – Day 25 Regression. Last Time - ANOVA When?  Comparing 2 or means (one categorical and one quantitative variable) Research question  Null.
Topic 3: Regression.
Event History Models Sociology 229: Advanced Regression Class 5
Correlation and Regression Analysis
Week 14 Chapter 16 – Partial Correlation and Multiple Regression and Correlation.
BINARY CHOICE MODELS: LOGIT ANALYSIS
Linear Regression 2 Sociology 5811 Lecture 21 Copyright © 2005 by Evan Schofer Do not copy or distribute without permission.
Regression and Correlation Methods Judy Zhong Ph.D.
Inference for regression - Simple linear regression
Chapter 13: Inference in Regression
Hypothesis Testing in Linear Regression Analysis
Methods Workshop (3/10/07) Topic: Event Count Models.
2-1 MGMG 522 : Session #2 Learning to Use Regression Analysis & The Classical Model (Ch. 3 & 4)
How do Lawyers Set fees?. Learning Objectives 1.Model i.e. “Story” or question 2.Multiple regression review 3.Omitted variables (our first failure of.
Section Copyright © 2014, 2012, 2010 Pearson Education, Inc. Lecture Slides Elementary Statistics Twelfth Edition and the Triola Statistics Series.
1 Experimental Statistics - week 10 Chapter 11: Linear Regression and Correlation.
Introduction Multilevel Analysis
+ Chapter 12: Inference for Regression Inference for Linear Regression.
Introduction to Linear Regression
Multiple regression - Inference for multiple regression - A case study IPS chapters 11.1 and 11.2 © 2006 W.H. Freeman and Company.
Count Models 1 Sociology 8811 Lecture 12
Lecture 8 Simple Linear Regression (cont.). Section Objectives: Statistical model for linear regression Data for simple linear regression Estimation.
+ Chapter 12: More About Regression Section 12.1 Inference for Linear Regression.
Lecture 3 Linear random intercept models. Example: Weight of Guinea Pigs Body weights of 48 pigs in 9 successive weeks of follow-up (Table 3.1 DLZ) The.
STA 286 week 131 Inference for the Regression Coefficient Recall, b 0 and b 1 are the estimates of the slope β 1 and intercept β 0 of population regression.
Multiple Regression. Simple Regression in detail Y i = β o + β 1 x i + ε i Where Y => Dependent variable X => Independent variable β o => Model parameter.
Multilevel Models 3 Sociology 229A, Class 10 Copyright © 2008 by Evan Schofer Do not copy or distribute without permission.
ANOVA, Regression and Multiple Regression March
1 In the Monte Carlo experiment in the previous sequence we used the rate of unemployment, U, as an instrument for w in the price inflation equation. SIMULTANEOUS.
1 BINARY CHOICE MODELS: LOGIT ANALYSIS The linear probability model may make the nonsense predictions that an event will occur with probability greater.
Regression Analysis Presentation 13. Regression In Chapter 15, we looked at associations between two categorical variables. We will now focus on relationships.
Linear Regression 1 Sociology 5811 Lecture 19 Copyright © 2005 by Evan Schofer Do not copy or distribute without permission.
From t-test to multilevel analyses Del-2
Lecture 18 Matched Case Control Studies
PANEL DATA 1. Dummy Variable Regression 2. LSDV Estimator
CHAPTER 29: Multiple Regression*
Advanced quantitative methods for social scientists (2017–2018) LC & PVK Session 2 Multilevel analysis in Stata (with a focus on random slope models for.
Simple Linear Regression
Count Models 2 Sociology 8811 Lecture 13
Presentation transcript:

Multilevel Models 3 Sociology 8811, Class 25 Copyright © 2007 by Evan Schofer Do not copy or distribute without permission

Announcements Paper #2 due April 26 Come see me ASAP if you don’t have a plan –Class topic: More multilevel models

Paper #1 Comments Papers were very good overall! Main issues: –1. A few people didn’t devote much time to diagnostics… they are important! –2. Some issues with models… choice of variables needs to be thought through –3. Some issues with focus / attention Don’t spend 2 pages describing the histogram of each and every variable Prioritize! Focus on interesting / important things –Ex: spend more time on problematic diagnostics, less on unimportant detail

Paper #1 Comments Main issues: –4. Avoid obviously useless plots/diagrams/info Ex: useless scatterplots of nominal/ordinal variables (without jitter) –5. Avoid over-strong / absolute language “There were no standardized residuals over 3, so I was able to determine that there were no outliers.” –First, standardized residuals is not the best way to diagnose outliers. Cooks D and other statistics help paint a full picture. –Second, (and more importantly): conclusion is too strong –Better to say: Examination of standardized residuals, cooks D, and scatterplots found no indication of influential cases.

Fixed Effects Model (FEM) Fixed effects model: For i cases within j groups Therefore  j is a separate intercept for each group It is equivalent to solely at within-group variation: X-bar-sub-j is mean of X for group j, etc Model is “within group” because all variables are centered around mean of each group.

Random Effects Issue: The dummy variable approach (ANOVA, FEM) treats group differences as a fixed effect Alternatively, we can treat it as a random effect Don’t estimate values for each case, but model it This requires making assumptions –e.g., that group differences are normally distributed with a standard deviation that can be estimated from data.

Random Effects A simple random intercept model –Notation from Rabe-Hesketh & Skrondal 2005, p. 4-5 Random Intercept Model Where  is the main intercept u is a random effect for each group –Allowing each of j groups to have its own intercept –Assumed to be independent & normally distributed Error (e) is the error term for each case –Also assumed to be independent & normally distributed Note: Other texts refer to random intercepts as u j or j.

Linear Random Intercepts Model The random intercept idea can be applied to linear regression Often called a “random effects” model… Result is similar to FEM, BUT: FEM looks only at within group effects Aggregate models (“between effects”) looks across groups –Random effects models yield a weighted average of between & within group effects It exploits between & within information, and thus can be more efficient than FEM & aggregate models. –IF distributional assumptions are correct.

Linear Random Intercepts Model. xtreg supportenv age male dmar demp educ incomerel ses, i(country) re Random-effects GLS regression Number of obs = Group variable (i): country Number of groups = 26 R-sq: within = Obs per group: min = 511 between = avg = overall = max = 2154 Random effects u_i ~ Gaussian Wald chi2(7) = corr(u_i, X) = 0 (assumed) Prob > chi2 = supportenv | Coef. Std. Err. z P>|z| [95% Conf. Interval] age | male | dmar | demp | educ | incomerel | ses | _cons | sigma_u | sigma_e | rho | (fraction of variance due to u_i) Assumes normal u j, uncorrelated with X vars SD of u (intercepts); SD of e; intra-class correlation

Linear Random Intercepts Model Notes: Model can also be estimated with maximum likelihood estimation (MLE) Stata: xtreg y x1 x2 x3, i(groupid) mle –Versus “re”, which specifies weighted least squares estimator Results tend to be similar But, MLE results include a formal test to see whether intercepts really vary across groups –Significant p-value indicates that intercepts vary. xtreg supportenv age male dmar demp educ incomerel ses, i(country) mle Random-effects ML regression Number of obs = Group variable (i): country Number of groups = 26 … MODEL RESULTS OMITTED … /sigma_u | /sigma_e | rho | Likelihood-ratio test of sigma_u=0: chibar2(01)= Prob>=chibar2 = 0.000

Choosing Models Which model is best? There is much discussion (e.g, Halaby 2004) Fixed effects are most consistent under a wide range of circumstances Consistent: Estimates approach true parameter values as N grows very large But, they are less efficient than random effects –In cases with low within-group variation (big between group variation) and small sample size, results can be very poor –Random Effects = more efficient But, runs into problems if specification is poor –Esp. if X variables correlate with random group effects –Usually due to omitted variables.

Hausman Specification Test Hausman Specification Test: A tool to help evaluate fit of fixed vs. random effects Logic: Both fixed & random effects models are consistent if models are properly specified However, some model violations cause random effects models to be inconsistent –Ex: if X variables are correlated to random error In short: Models should give the same results… If not, random effects may be biased –If results are similar, use the most efficient model: random effects –If results diverge, odds are that the random effects model is biased. In that case use fixed effects…

Hausman Specification Test Strategy: Estimate both fixed & random effects models Save the estimates each time Finally invoke Hausman test –Ex: streg var1 var2 var3, i(groupid) fe estimates store fixed streg var1 var2 var3, i(groupid) re estimates store random hausman fixed random

Hausman Specification Test Example: Environmental attitudes fe vs re. hausman fixed random ---- Coefficients ---- | (b) (B) (b-B) sqrt(diag(V_b-V_B)) | fixed random Difference S.E age | male | dmar | demp | educ | incomerel | ses | b = consistent under Ho and Ha; obtained from xtreg B = inconsistent under Ha, efficient under Ho; obtained from xtreg Test: Ho: difference in coefficients not systematic chi2(7) = (b-B)'[(V_b-V_B)^(-1)](b-B) = 2.70 Prob>chi2 = Non-significant p- value indicates that models yield similar results… Direct comparison of coefficients…

Within & Between Effects What is the relationship between within-group effects (FEM) and between-effects (BEM)? Usually they are similar Ex: Student skills & test performance Within any classroom, skilled students do best on tests Between classrooms, classes with more skilled students have higher mean test scores.

Within & Between Effects Issue: Between and within effects can differ! Ex: Effects of wealth on attitudes toward welfare At the individual level (within group) –Wealthier people are conservative, don’t support welfare At the country level (between groups): –Wealthier countries (high aggregate mean) tend to have pro- welfare attitudes (ex: Scandinavia) Result: Wealth has opposite between vs within effects! –Issue: Such dynamics often result from omitted level-1 variables (omitted variable bias) Ex: If we control for individual “political conservatism”, effects may be consistent at both levels…

Within & Between Effects You can estimate BOTH within- and between- group effects in a single model Strategy: Split a variable (e.g., SES) into two new variables… –1. Group mean SES –2. Within-group deviation from mean SES »Often called “group mean centering” Then, put both variables into a random effects model Model will estimate separate coefficients for between vs. within effects –Ex: egen meanvar1 = mean(var1), by(groupid) egen withinvar1 = var1 – meanvar1 Include mean (aggregate) & within variable in model.

Within & Between Effects. xtreg supportenv meanage withinage male dmar demp educ incomerel ses, i(country) mle Random-effects ML regression Number of obs = Group variable (i): country Number of groups = 26 Random effects u_i ~ Gaussian Obs per group: min = 511 avg = max = 2154 LR chi2(8) = Log likelihood = Prob > chi2 = supportenv | Coef. Std. Err. z P>|z| [95% Conf. Interval] meanage | withinage | male | dmar | demp | educ | incomerel | ses | _cons | Between & within effects are opposite. Older countries are MORE environmental, but older people are LESS. Omitted variables? Wealthy European countries with strong green parties have older populations! Example: Pro-environmental attitudes

Within & Between Effects / Centering Multilevel models & “centering” variables Grand mean centering: computing variables as deviations from overall mean Often done to X variables Has effect that baseline constant in model reflects mean of all cases –Useful for interpretation Group mean centering: computing variables as deviation from group mean Useful for decomposing within vs. between effects Often in conjunction with aggregate group mean vars.

Generalizing: Random Coefficients Linear random intercept model allows random variation in intercept (mean) for groups But, the same idea can be applied to other coefficients That is, slope coefficients can ALSO be random! Random Coefficient Model Which can be written as: Where zeta-1 is a random intercept component Zeta-2 is a random slope component.

Linear Random Coefficient Model Rabe-Hesketh & Skrondal 2004, p. 63 Both intercepts and slopes vary randomly across j groups

Random Coefficients Summary Some things to remember: Dummy variables allow fixed estimates of intercepts across groups Interactions allow fixed estimates of slopes across groups Random coefficients allow intercepts and/or slopes to vary across groups randomly! –The model does not directly estimate those effects, just as a model does not estimate coefficients for each case residual –BUT, random components can be predicted after the fact (just as you can compute residuals – random error).

STATA Notes: xtreg, xtmixed xtreg – allows estimation of between, within (fixed), and random intercept models xtreg y x1 x2 x3, i(groupid) fe - fixed (within) model xtreg y x1 x2 x3, i(groupid) be - between model xtreg y x1 x2 x3, i(groupid) re - random intercept (GLS) xtreg y x1 x2 x3, i(groupid) mle - random intercept (MLE) xtmixed – allows random slopes & coefs “Mixed” models refer to models that have both fixed and random components xtmixed [depvar] [fixed equation] || [random eq], options Ex: xtmixed y x1 x2 x3 || groupid: x2 –Random intercept is assumed. Random coef for X2 specified.

STATA Notes: xtreg, xtmixed Random intercepts xtreg y x1 x2 x3, i(groupid) mle –Is equivalent to xtmixed y x1 x2 x3 || groupid:, mle xtmixed assumes random intercept – even if no other random effects are specified after “groupid” –But, we can add random coefficients for all Xs: xtmixed y x1 x2 x3 || groupid: x1 x2 x3, mle –Note: xtmixed can do a lot… but GLLAMM can do even more! “General linear & latent mixed models” Must be downloaded into stata. Type “search gllamm” and follow instructions to install…

Random intercepts: xtmixed. xtmixed supportenv age male dmar demp educ incomerel ses || country:, mle Mixed-effects ML regression Number of obs = Group variable: country Number of groups = 26 Obs per group: min = 511 avg = max = 2154 Wald chi2(7) = Log likelihood = Prob > chi2 = supportenv | Coef. Std. Err. z P>|z| [95% Conf. Interval] age | male | dmar | demp | educ | incomerel | ses | _cons | [remainder of output cut off] Note: xtmixed yields identical results to xtreg, mle Example: Pro-environmental attitudes

Random intercepts: xtmixed supportenv | Coef. Std. Err. z P>|z| [95% Conf. Interval] age | male | dmar | demp | educ | incomerel | ses | _cons | Random-effects Parameters | Estimate Std. Err. [95% Conf. Interval] country: Identity | sd(_cons) | sd(Residual) | LR test vs. linear regression: chibar2(01) = Prob >= chibar2 = xtmixed output puts all random effects below main coefficients. Here, they are “cons” (constant) for groups defined by “country”, plus residual (e) Ex: Pro-environmental attitudes (cont’d) Non-zero SD indicates that intercepts vary

Random Coefficients: xtmixed. xtmixed supportenv age male dmar demp educ incomerel ses || country: educ, mle [output omitted] supportenv | Coef. Std. Err. z P>|z| [95% Conf. Interval] age | male | dmar | demp | educ | incomerel | ses | _cons | Random-effects Parameters | Estimate Std. Err. [95% Conf. Interval] country: Independent | sd(educ) | sd(_cons) | sd(Residual) | LR test vs. linear regression: chi2(2) = Prob > chi2 = Ex: Pro-environmental attitudes (cont’d) Here, we have allowed the slope of educ to vary randomly across countries Educ (slope) varies, too!

Random Coefficients: xtmixed What are random coefficients doing? Let’s look at results from a simplified model –Only random slope & intercept for education Model fits a different slope & intercept for each group!

Random Coefficients Why bother with random coefficients? 1. A solution for clustering (non-independence) –Usually people just use random intercepts, but slopes may be an issue also 2. You can create a better-fitting model –If slopes & intercepts vary, a random coefficient model may fit better –Assuming distributional assumptions are met –Model fit compared to OLS can be tested…. 3. Better predictions –Attention to group-specific random effects can yield better predictions (e.g., slopes) for each group »Rather than just looking at “average” slope for all groups 4. Helps us think about multilevel data »Ex: cross-level interactions (we’ll discuss soon!)

Multilevel Model Notation So far, we have expressed random effects in a single equation: Random Coefficient Model However, it is common to separate the fixed and random parts into multiple equations: Just a basic OLS model… But, intercept & slope are each specified separately as having a random component Intercept equation Slope Equation

Multilevel Model Notation The “separate equation” formulation is no different from what we did before… But it is a vivid & clear way to present your models All random components are obvious because they are stated in separate equations NOTE: Some software (e.g., HLM) requires this –Rules: 1. Specify an OLS model, just like normal 2. Consider which OLS coefficients should have a random component –These could be the intercept or any X variable (slope) 3. Specify an additional formula for each random coefficient.