Lesson 6, Part 1: Linear Mixed Effects Models

Similar documents
Random Forests. Gradient Boosting. and. Bagging and Boosting

A Study on Chinese Firms in Hamburg

SIMPLE LINEAR REGRESSION OF CPS DATA

AVOTE FOR PEROT WAS A VOTE FOR THE STATUS QUO

Preferences in Political Mapping (Measuring, Modeling, and Visualization)

Lab 3: Logistic regression models

Abstract for: Population Association of America 2005 Annual Meeting Philadelphia PA March 31 to April 2

JUDGE, JURY AND CLASSIFIER

Impact of the EU Enlargement on the Agricultural Income. Components in the Member States

Distorting Democracy: How Gerrymandering Skews the Composition of the House of Representatives

Practice Questions for Exam #2

Running head: POLITICAL PARTISANSHIP AND RESPONSES TO SEXUAL HARASSMENT ALLEGATIONS AGAINST POLITICIANS 1

Paul M. Sommers Alyssa A. Chong Monica B. Ralston And Andrew C. Waxman. March 2010 MIDDLEBURY COLLEGE ECONOMICS DISCUSSION PAPER NO.

Global Public Opinion toward the United Nations: Insights from the Gallup World Poll

Statistics, Politics, and Policy

Combining national and constituency polling for forecasting

3B Circle Graphs. COLORS Use the graph that shows the results of a survey.

Hoboken Public Schools. AP Statistics Curriculum

Allocating the US Federal Budget to the States: the Impact of the President. Statistical Appendix

Europeans support a proportional allocation of asylum seekers

In Relative Policy Support and Coincidental Representation,

Transitional Jobs for Ex-Prisoners

List of Tables and Appendices

The Electoral Process STEP BY STEP. the worksheet activity to the class. the answers with the class. (The PowerPoint works well for this.

ANES Panel Study Proposal Voter Turnout and the Electoral College 1. Voter Turnout and Electoral College Attitudes. Gregory D.

Who says elections in Ghana are free and fair?

Why The National Popular Vote Bill Is Not A Good Choice

is the process by which individuals acquire their political values and outlooks.

ANALYSES OF JUVENILE CHINOOK SALMON AND STEELHEAD TRANSPORT FROM LOWER GRANITE AND LITTLE GOOSE DAMS, NOAA Fisheries

NBER WORKING PAPER SERIES HOMEOWNERSHIP IN THE IMMIGRANT POPULATION. George J. Borjas. Working Paper

MIGRATION STATISTICS AND BRAIN DRAIN/GAIN

Election of Worksheet #1 - Candidates and Parties. Abraham Lincoln. Stephen A. Douglas. John C. Breckinridge. John Bell

Introduction to Path Analysis: Multivariate Regression

I. The relationship between states ratio of Democratic/Republican votes and measures of personal responsibility

Overview. Ø Neural Networks are considered black-box models Ø They are complex and do not provide much insight into variable relationships

(a) Draw side-by-side box plots that show the yields of the two types of land. Check for outliers before making the plots.

Name Date Period. Approximate population in millions. Arizona Colorado Connecticut Georgia Idaho Iowa 3.

I-35W Bridge Collapse: Travel Impacts and Adjustment Strategies

Marist College Institute for Public Opinion Poughkeepsie, NY Phone Fax

INTRODUCTION AND SUMMARY

Changing the COLA. Findings from a national omnibus survey of 1000 adults.

! = ( tapping time ).

Residual Wage Inequality: A Re-examination* Thomas Lemieux University of British Columbia. June Abstract

Comment on Voter Identification Laws and the Suppression of Minority Votes

RAY C. BLISS INSTITUTE OF APPLIED POLITICS & REGULA CENTER FOR PUBLIC SERVICE. Presentation on Civility Research

BYLAWS OF THE AMERICAN ASSOCIATION OF ORTHOPAEDIC EXECUTIVES

Who Really Voted for Obama in 2008 and 2012?

Turnout and the New American Majority

The Case of the Disappearing Bias: A 2014 Update to the Gerrymandering or Geography Debate

Declaration of Charles Stewart III on Excess Undervotes Cast in Sarasota County, Florida for the 13th Congressional District Race

The Timeline Method of Studying Electoral Dynamics. Christopher Wlezien, Will Jennings, and Robert S. Erikson

UC Davis UC Davis Previously Published Works

Inferring Directional Migration Propensities from the Migration Propensities of Infants: The United States

Should Politicians Choose Their Voters? League of Women Voters of MI Education Fund

The Electoral Process. Learning Objectives Students will be able to: STEP BY STEP. reading pages (double-sided ok) to the students.

What makes people feel free: Subjective freedom in comparative perspective Progress Report

College Voting in the 2018 Midterms: A Survey of US College Students. (Medium)

The authors acknowledge the support of CNPq and FAPEMIG to the development of the work. 2. PhD candidate in Economics at Cedeplar/UFMG Brazil.

Chapter. Describing the Relation between Two Variables Pearson Pren-ce Hall. All rights reserved

A survey of 200 adults in the U.S. found that 76% regularly wear seatbelts while driving. True or false: 76% is a parameter.

Earnings Inequality and the Gender Wage Gap. in U.S. Metropolitan Areas. Zsuzsa Daczó

Roles of children and elderly in migration decision of adults: case from rural China

STATISTICAL GRAPHICS FOR VISUALIZING DATA

Bayesian Combination of State Polls and Election Forecasts

Regulating Elections: Districts /252 Fall 2012

Hoboken Public Schools. Algebra I Curriculum

Supplementary Materials A: Figures for All 7 Surveys Figure S1-A: Distribution of Predicted Probabilities of Voting in Primary Elections

oductivity Estimates for Alien and Domestic Strawberry Workers and the Number of Farm Workers Required to Harvest the 1988 Strawberry Crop

A disaggregate approach to economic models of voting in U.S. presidential elections: forecasts of the 2008 election. Abstract

Support for Restoring U.S.-Cuba Relations March 11-15, 2016

Congressional samples Juho Lamminmäki

Personality and Individual Differences

Political Parties and the Tax Level in the American states: Two Regression Discontinuity Designs

net Spending Support for Different Programs, by Income Level

Asking about social circles improves election predictions

CS 229 Final Project - Party Predictor: Predicting Political A liation

2010 CENSUS POPULATION REAPPORTIONMENT DATA

Owner-Occupied Housing and Crime rates in Denmark

The Seventeenth Amendment, Senate Ideology, and the Growth of Government

Who influences the formation of political attitudes and decisions in young people? Evidence from the referendum on Scottish independence

Lesson Title: Lesson Authors: Key Curriculum Words: Grade Level: Time Allotted: Enduring Understandings: Key Concepts/Definitions of this Lesson:

Regulating Elections: Districts /252 Fall 2008

The Forum. Volume 8, Issue Article 14. Forecasting Control of State Governments and Redistricting Authority After the 2010 Elections

THE PEOPLE OF THE STATE OF MICHIGAN ENACT:

APPENDIX: HUMAN RIGHTS AND PUBLIC SUPPORT FOR WAR

The Election Process

Obstacles to estimating voter ID laws e ect on turnout

Incumbency as a Source of Spillover Effects in Mixed Electoral Systems: Evidence from a Regression-Discontinuity Design.

1. The Relationship Between Party Control, Latino CVAP and the Passage of Bills Benefitting Immigrants

Methodology. 1 State benchmarks are from the American Community Survey Three Year averages

PERCEIVED ACCURACY AND BIAS IN THE NEWS MEDIA A GALLUP/KNIGHT FOUNDATION SURVEY

Constitution of Future Business Leaders of America-Phi Beta Lambda University of California, San Diego

Legitimacy Crisis. Myth and Reality. of the. Explaining Trends and Cross-National OXPORD. Differences in Established Democracies

ATTACHMENT 16. Source and Accuracy Statement for the November 2008 CPS Microdata File on Voting and Registration

Submission to the Speaker s Digital Democracy Commission

Can information that raises voter expectations improve accountability?

Understanding factors that influence L1-visa outcomes in US

EXTENDED FAMILY INFLUENCE ON INDIVIDUAL MIGRATION DECISION IN RURAL CHINA

Supporting Information for Signaling and Counter-Signaling in the Judicial Hierarchy: An Empirical Analysis of En Banc Review

A Global Perspective on Socioeconomic Differences in Learning Outcomes

Transcription:

Lesson 6, Part 1: Linear Mixed Effects Models

This Lesson s Goals Learn about linear mixed effects models (LMEM) Make figures for data for LMEMs Run some preliminary LMEMs in R Summarise results in an R Markdown document

This Lesson s Goals Learn about linear mixed effects models (LMEM) Make figures for data for LMEMs Run some preliminary LMEMs in R Summarise results in an R Markdown document

End of Lesson 5 Questions But aren t percentages really just summarized count data? But we had to drop a bunch of Union states, isn t that a problem? But Alabama was missing one Democrat data point, isn t it not balanced? But what about the variance for year, shouldn t we try and account for that too? generalized linear mixed effects models

Math (Part 1)

yi = a + b1x1i + b2x2i + b3x1ix2i + ei How do I add factors for random variance? (i.e. things we re not directly testing)

yi = a + b1x1i + b2x2i + b3x1ix2i + ei yi = a + as + b1x1i + b2x2i + b3x1ix2i + ei random effect s = state

yi = a + b1x1i + b2x2i + b3x1ix2i + ei yi = a + as + b1x1i + b2x2i + b3x1ix2i + ei random intercept s = state

yi = a + b1x1i + b2x2i + b3x1ix2i + ei yi = a + as + ay + b1x1i + b2x2i + b3x1ix2i + ei random intercept #1 random intercept #2 s = state y = year

In this paper we tested the effect of time on weight. A total of 50 baby chicks were included in the study. ANOVA language LMEM language weight dependent variable dependent variable time independent variable fixed effect baby chick error variable random effect mixed effects

yi = a + as + ay + b1x1i + b2x2i +b3x1ix2i + ei yi = specific y value a = intercept as = random intercept #1 for specific level ay = random intercept #2 for specific level b1 = slope of first variable x1i = specific x value for first variable b2 = slope of second variable x2i = specific x value for second variable b3 = slope of third variable (interaction) ei = random variance or the residual

yi = a + as + ay + b1x1i + b2x2i + b3x1ix2i + ei Percentage of Votes for Incumbent by Country in Civil War and Party of Incumbent Democrat Republican 100 Percentage of vote for incumbent 75 50 25 0 Union Confederacy Civil War country

yi = a + as + ay + b1x1i + b2x2i + b3x1ix2i + ei Percentage of Votes for Incumbent by Country in Civil War and Party of Incumbent Democrat Republican 100 Percentage of vote for incumbent 75 50 25 0 Union Confederacy Civil War country

yi = a + as + ay + b1x1i + b2x2i + b3x1ix2i + ei Percentage of Votes for Incumbent by Country in Civil War and Party of Incumbent Democrat Republican 100 Percentage of vote for incumbent 75 50 25 0 Union Confederacy Civil War country

yi = a + as + ay + b1x1i + b2x2i + b3x1ix2i + ei Percentage of Votes for Incumbent by Country in Civil War and Party of Incumbent Democrat Republican 100 Percentage of vote for incumbent 75 50 25 0 Union Confederacy Civil War country

yi = a + as + ay + b1x1i + b2x2i + b3x1ix2i + ei Percentage of Votes for Incumbent by Country in Civil War and Party of Incumbent Democrat Republican 100 Percentage of vote for incumbent 75 50 25 Rhode Island Rhode Island Rhode Island Rhode Island 0 Union Confederacy Civil War country

yi = a + as + ay + b1x1i + b2x2i + b3x1ix2i + ei Percentage of Votes for Incumbent by Country in Civil War and Party of Incumbent Democrat Republican 100 Percentage of vote for incumbent 75 50 25 Kentucky Kentucky Kentucky Kentucky 0 Union Confederacy Civil War country

yi = a + as + ay + b1x1i + b2x2i + b3x1ix2i + ei Percentage of Votes for Incumbent by Country in Civil War and Party of Incumbent Democrat Republican 100 Percentage of vote for incumbent 75 50 25 1964 1964 1964 1964 0 Union Confederacy Civil War country

yi = a + as + ay + b1x1i + b2x2i + b3x1ix2i + ei Percentage of Votes for Incumbent by Country in Civil War and Party of Incumbent Democrat Republican 100 Percentage of vote for incumbent 75 50 25 2012 2012 2012 2012 0 Union Confederacy Civil War country

But, at the end of the last lesson we said this was bad, because it was a percentage of a count?

yi = a + as + ay + b1x1i + b2x2i +b3x1ix2i + ei log[p/(1-p)]i = a + as + ay + b1x1i + b2x2i + b3x1ix2i + ei logistic regression > generalized linear mixed effects model

R Code (Part 1)

lme4 yi = a + as + ay + b1x1i + b2x2i + b3x1ix2i + ei lmer(perc_votes_incumbent ~ incumbent_party * civil_war + (1 state) + (1 year))

lme4 yi = a + as + ay + b1x1i + b2x2i + b3x1ix2i + ei lmer(perc_votes_incumbent ~ incumbent_party * civil_war + (1 state) + (1 year))

But, in the ANOVA we accounted for the fact that a variable could be within- or between-subject?

Math (Part 2)

yi = a + as + ay + b1x1i + b2x2i +b3x1ix2i + ei yi = a + as + ay + bs1+b1)x1i + (by1+b2)x2i + random slope s = state b3x1ix2i + ei random slope y = year

yi = a + as + ay + (bs1+b1)x1i + (by1+b2)x2i + yi = specific y value b3x1ix2i + ei x1i = x value for variable #1 a = intercept as = random intercept #1 ay = random intercept #2 bs1 = slope of r.e. #1 b1 = slope of variable #1 by1 = slope of r.e. #2 b2 = slope of variable #2 x2i = x value for variable #2 b3 = slope of variable #3 ei = random variance

yi = a + as + ay + (bs1+b1)x1i + (by1+b2)x2i + b3x1ix2i + ei Percentage of Votes for Incumbent by Country in Civil War and Party of Incumbent Democrat Republican 100 Percentage of vote for incumbent 75 50 25 Rhode Island Rhode Island Rhode Island Rhode Island 0 Union Confederacy Civil War country

yi = a + as + ay + (bs1+b1)x1i + (by1+b2)x2i + b3x1ix2i + ei Percentage of Votes for Incumbent by Country in Civil War and Party of Incumbent Democrat Republican 100 Percentage of vote for incumbent 75 50 25 Rhode Island Rhode Island Rhode Island Rhode Island Rhode Island Rhode Island Rhode Island Rhode Island 0 Union Confederacy Civil War country

R Code (Part 2)

lme4 yi = a + as + ay + (bs1+b1)x1i + (by1+b2)x2i + b3x1ix2i + ei lmer(perc_votes_incumbent ~ incumbent_party * civil_war + (1+incumbent_party state) + (1+civil_war year))

lme4 yi = a + as + ay + (bs1+b1)x1i + (by1+b2)x2i + b3x1ix2i + ei lmer(perc_votes_incumbent ~ incumbent_party * civil_war + (1+incumbent_party state) + (1+civil_war year))

LMEM with only random intercepts LMEM with only random intercepts and slopes

Lab

Data set: Stroop Task source: real students!

Say the color of the ink not the written word. blue

Say the color of the ink not the written word. blue

Say the color of the ink not the written word. blue blue word = ink color congruent trial word ink color incongruent trial

Data set: Stroop Task Congruency: Are responses to incongruent trials less accurate and slower than to congruent trials? Experiment half: Are responses more accurate and faster in the second half of the experiment than the first half of the experiment? Congruency x Experiment half: Is there an interaction between these variables? accuracy (logistic) logit pi = accuracy x1 = congruency x2 = experiment half r1 = subject r2 = item reaction times (linear) yi = reaction times x1 = congruency x2 = experiment half r1 = subject r2 = item source: real students!

dplyr data_clean = data_results

dplyr data_clean = data_results %>% rename(trial_number = SimpleRTBLock.TrialNr.) change variable name

dplyr data_clean = data_results %>% rename(trial_number = SimpleRTBLock.TrialNr.) %>% rename(congruency = Congruency) %>% rename(correct_response = StroopItem.CRESP.) %>% rename(given_response = StroopItem.RESP.) %>% rename(accuracy = StroopItem.ACC.) %>% rename(rt = StroopItem.RT.) %>% change variable name

dplyr data_clean = data_results %>% rename(trial_number = SimpleRTBLock.TrialNr.) %>% rename(congruency = Congruency) %>% rename(correct_response = StroopItem.CRESP.) %>% rename(given_response = StroopItem.RESP.) %>% rename(accuracy = StroopItem.ACC.) %>% rename(rt = StroopItem.RT.) %>% select(subject_id, block, item, trial_number, congruency, correct_response, given_response, accuracy, rt) change variable name choose subset of variables

RColorBrewer cols = brewer.pal(5, PuOr") call to make palette

RColorBrewer cols = brewer.pal(5, PuOr") call to make palette number of colors

RColorBrewer cols = brewer.pal(5, PuOr") call to make palette number of colors palette name

RColorBrewer cols = brewer.pal(5, PuOr") call to make palette number of colors palette name > cols [1] "#E66101" "#FDB863" "#F7F7F7" "#B2ABD2" "#5E3C99" 7.5 7.5 7.5 7.5 7.5 5.0 5.0 5.0 5.0 5.0 2.5 2.5 2.5 2.5 2.5 0.0 0.0 0.0 0.0 0.0 60 90 120 150 60 90 120 150 60 90 120 150 60 90 120 150 60 90 120 150

RColorBrewer cols = brewer.pal(5, PuOr") col_con = cols[1] call to make palette number of colors palette name > cols [1] "#E66101" "#FDB863" "#F7F7F7" "#B2ABD2" "#5E3C99" 7.5 7.5 7.5 7.5 7.5 5.0 5.0 5.0 5.0 5.0 2.5 2.5 2.5 2.5 2.5 0.0 0.0 0.0 0.0 0.0 60 90 120 150 60 90 120 150 60 90 120 150 60 90 120 150 60 90 120 150

RColorBrewer cols = brewer.pal(5, PuOr") col_con = cols[1] col_incon = cols[5] call to make palette number of colors palette name > cols [1] "#E66101" "#FDB863" "#F7F7F7" "#B2ABD2" "#5E3C99" 7.5 7.5 7.5 7.5 7.5 5.0 5.0 5.0 5.0 5.0 2.5 2.5 2.5 2.5 2.5 0.0 0.0 0.0 0.0 0.0 60 90 120 150 60 90 120 150 60 90 120 150 60 90 120 150 60 90 120 150