Introduction to mixed-effects regression for (psycho)linguists

Similar documents
The linear mixed model: modeling hierarchical and longitudinal data

An introduction to SPSS

Organizing data in R. Fitting Mixed-Effects Models Using the lme4 Package in R. R packages. Accessing documentation. The Dyestuff data set

Random coefficients models

Frequently Asked Questions Updated 2006 (TRIM version 3.51) PREPARING DATA & RUNNING TRIM

GLM II. Basic Modeling Strategy CAS Ratemaking and Product Management Seminar by Paul Bailey. March 10, 2015

Performing Cluster Bootstrapped Regressions in R

Resources for statistical assistance. Quantitative covariates and regression analysis. Methods for predicting continuous outcomes.

Mixed Effects Models. Biljana Jonoska Stojkova Applied Statistics and Data Science Group (ASDa) Department of Statistics, UBC.

A short explanation of Linear Mixed Models (LMM)

THIS IS NOT REPRESNTATIVE OF CURRENT CLASS MATERIAL. STOR 455 Midterm 1 September 28, 2010

Additional Issues: Random effects diagnostics, multiple comparisons

Statistics Lab #7 ANOVA Part 2 & ANCOVA

Using R for Analyzing Delay Discounting Choice Data. analysis of discounting choice data requires the use of tools that allow for repeated measures

Practical 4: Mixed effect models

9.1 Random coefficients models Constructed data Consumer preference mapping of carrots... 10

CHAPTER 7 EXAMPLES: MIXTURE MODELING WITH CROSS- SECTIONAL DATA

Regression Lab 1. The data set cholesterol.txt available on your thumb drive contains the following variables:

Random coefficients models

Model selection Outline for today

Regression. Dr. G. Bharadwaja Kumar VIT Chennai

Panel Data 4: Fixed Effects vs Random Effects Models

Output from redwing2.r

STAT 2607 REVIEW PROBLEMS Word problems must be answered in words of the problem.

STATISTICS (STAT) Statistics (STAT) 1

THE UNIVERSITY OF BRITISH COLUMBIA FORESTRY 430 and 533. Time: 50 minutes 40 Marks FRST Marks FRST 533 (extra questions)

Study Guide. Module 1. Key Terms

Fathom Dynamic Data TM Version 2 Specifications

Stat 5100 Handout #14.a SAS: Logistic Regression

THE L.L. THURSTONE PSYCHOMETRIC LABORATORY UNIVERSITY OF NORTH CAROLINA. Forrest W. Young & Carla M. Bann

Introduction to Statistical Analyses in SAS

Goals of the Lecture. SOC6078 Advanced Statistics: 9. Generalized Additive Models. Limitations of the Multiple Nonparametric Models (2)

Centering and Interactions: The Training Data

Mean Tests & X 2 Parametric vs Nonparametric Errors Selection of a Statistical Test SW242

Stat 500 lab notes c Philip M. Dixon, Week 10: Autocorrelated errors

Week 4: Simple Linear Regression III

Introduction to hypothesis testing

Statistical Analysis of Series of N-of-1 Trials Using R. Artur Araujo

SPSS QM II. SPSS Manual Quantitative methods II (7.5hp) SHORT INSTRUCTIONS BE CAREFUL

Exploratory model analysis

Minitab detailed

Multivariate Analysis Multivariate Calibration part 2

Nuts and Bolts Research Methods Symposium

Analysis of variance - ANOVA

SYS 6021 Linear Statistical Models

Correctly Compute Complex Samples Statistics

Problem set for Week 7 Linear models: Linear regression, multiple linear regression, ANOVA, ANCOVA

Using Multivariate Adaptive Regression Splines (MARS ) to enhance Generalised Linear Models. Inna Kolyshkina PriceWaterhouseCoopers

Predicting Web Service Levels During VM Live Migrations

CHAPTER 5. BASIC STEPS FOR MODEL DEVELOPMENT

Regression Analysis and Linear Regression Models

Correctly Compute Complex Samples Statistics

CHAPTER 3 AN OVERVIEW OF DESIGN OF EXPERIMENTS AND RESPONSE SURFACE METHODOLOGY

Week 5: Multiple Linear Regression II

Applied Statistics and Econometrics Lecture 6

Source df SS MS F A a-1 [A] [T] SS A. / MS S/A S/A (a)(n-1) [AS] [A] SS S/A. / MS BxS/A A x B (a-1)(b-1) [AB] [A] [B] + [T] SS AxB

Course Business. types of designs. " Week 4. circle back to if we have time later. ! Two new datasets for class today:

Enterprise Miner Tutorial Notes 2 1

Robust Linear Regression (Passing- Bablok Median-Slope)

Package simr. April 30, 2018

Table Of Contents. Table Of Contents

Regression III: Lab 4

Heteroskedasticity and Homoskedasticity, and Homoskedasticity-Only Standard Errors

Quantitative Methods in Management

Variable selection is intended to select the best subset of predictors. But why bother?

Two-Stage Least Squares

Bivariate (Simple) Regression Analysis

SPSS INSTRUCTION CHAPTER 9

Introduction. About this Document. What is SPSS. ohow to get SPSS. oopening Data

Chapters 5-6: Statistical Inference Methods

Repeated Measures Part 4: Blood Flow data

The Power and Sample Size Application

Chapter 6: Linear Model Selection and Regularization

Data Analysis and Solver Plugins for KSpread USER S MANUAL. Tomasz Maliszewski

Section 2.3: Simple Linear Regression: Predictions and Inference

Statistical Modelling for Social Scientists. Manchester University. January 20, 21 and 24, Exploratory regression and model selection

Binary IFA-IRT Models in Mplus version 7.11

Applied Regression Modeling: A Business Approach

Fly wing length data Sokal and Rohlf Box 10.1 Ch13.xls. on chalk board

8. MINITAB COMMANDS WEEK-BY-WEEK

Product Catalog. AcaStat. Software

Online Supplementary Appendix for. Dziak, Nahum-Shani and Collins (2012), Multilevel Factorial Experiments for Developing Behavioral Interventions:

Linear Model Selection and Regularization. especially usefull in high dimensions p>>100.

Generalized least squares (GLS) estimates of the level-2 coefficients,

CDAA No. 4 - Part Two - Multiple Regression - Initial Data Screening

Hierarchical Generalized Linear Models

Learner Expectations UNIT 1: GRAPICAL AND NUMERIC REPRESENTATIONS OF DATA. Sept. Fathom Lab: Distributions and Best Methods of Display

Cross-validation and the Bootstrap

Recitation Supplement: Creating a Neural Network for Classification SAS EM December 2, 2002

Lab #9: ANOVA and TUKEY tests

Tutorial #1: Using Latent GOLD choice to Estimate Discrete Choice Models

IBM SPSS Categories 23

Missing Data. SPIDA 2012 Part 6 Mixed Models with R:

Modelling Proportions and Count Data

SASEG 9B Regression Assumptions

Introduction to Mixed-Effects Models for Hierarchical and Longitudinal Data

range: [1,20] units: 1 unique values: 20 missing.: 0/20 percentiles: 10% 25% 50% 75% 90%

Package glmmml. R topics documented: March 25, Encoding UTF-8 Version Date Title Generalized Linear Models with Clustering

Workshop 5: Linear mixed-effects models

Factorial ANOVA. Skipping... Page 1 of 18

Transcription:

Introduction to mixed-effects regression for (psycho)linguists Martijn Wieling Department of Humanities Computing, University of Groningen Groningen, April 21, 2015 1 Martijn Wieling Introduction to mixed-effects regression for (psycho)linguists University of Groningen

Overview Introduction Recap: multiple regression Mixed-effects regression analysis: explanation Methodological issues Case-study: Lexical decision latencies (Baayen, 2008: 7.5.1) Conclusion 2 Martijn Wieling Introduction to mixed-effects regression for (psycho)linguists University of Groningen

Introduction Consider the following situation (taken from Clark, 1973): Mr. A and Mrs. B study reading latencies of verbs and nouns Each randomly selects 20 words and tests 50 participants Mr. A finds (using a sign test) verbs to have faster responses Mrs. B finds nouns to have faster responses How is this possible? 3 Martijn Wieling Introduction to mixed-effects regression for (psycho)linguists University of Groningen

Introduction Consider the following situation (taken from Clark, 1973): Mr. A and Mrs. B study reading latencies of verbs and nouns Each randomly selects 20 words and tests 50 participants Mr. A finds (using a sign test) verbs to have faster responses Mrs. B finds nouns to have faster responses How is this possible? 3 Martijn Wieling Introduction to mixed-effects regression for (psycho)linguists University of Groningen

The language-as-fixed-effect fallacy The problem is that Mr. A and Mrs. B disregard the variability in the words (which is huge) Mr. A included a difficult noun, but Mrs. B included a difficult verb Their set of words does not constitute the complete population of nouns and verbs, therefore their results are limited to their words This is known as the language-as-fixed-effect fallacy (LAFEF) Fixed-effect factors have repeatable and a small number of levels Word is a random-effect factor (a non-repeatable random sample from a larger population) 4 Martijn Wieling Introduction to mixed-effects regression for (psycho)linguists University of Groningen

Why linguists are not always good statisticians LAFEF occurs frequently in linguistic research until the 1970 s Many reported significant results are wrong (the method is anti-conservative)! Clark (1973) combined a by-subject (F 1 ) analysis and by-item (F 2 ) analysis in a measure called min F Results are significant and generalizable across subjects and items when min F is significant Unfortunately many researchers (>50%!) incorrectly interpreted this study and may report wrong results (Raaijmakers et al., 1999) E.g., they only use F1 and F 2 and not min F or they use F 2 while unneccesary (e.g., counterbalanced design) 5 Martijn Wieling Introduction to mixed-effects regression for (psycho)linguists University of Groningen

Our problems solved... Apparently, analyzing this type of data is difficult... Fortunately, using mixed-effects regression models solves these problems! The method is easier than using the approach of Clark (1973) Results can be generalized across subjects and items Mixed-effects models are robust to missing data (Baayen, 2008, p. 266) We can easily test if it is necessary to treat item as a random effect But first some words about regression... 6 Martijn Wieling Introduction to mixed-effects regression for (psycho)linguists University of Groningen

Our problems solved... Apparently, analyzing this type of data is difficult... Fortunately, using mixed-effects regression models solves these problems! The method is easier than using the approach of Clark (1973) Results can be generalized across subjects and items Mixed-effects models are robust to missing data (Baayen, 2008, p. 266) We can easily test if it is necessary to treat item as a random effect But first some words about regression... 6 Martijn Wieling Introduction to mixed-effects regression for (psycho)linguists University of Groningen

Regression vs. ANOVA Most people either use ANOVA or regression ANOVA: categorical predictor variables Regression: continuous predictor variables Both can be used for the same thing! ANCOVA: continuous and categorical predictors Regression: categorical (dummy coding) and continuous predictors Why I use regression as opposed to ANOVA No temptation to dichotomize continuous predictors Intuitive interpretation (your mileage may vary) Mixed-effects analysis is relatively easy to do and does not require a balanced design (which is generally necessary for repeated-measures ANOVA) This course will focus on regression 7 Martijn Wieling Introduction to mixed-effects regression for (psycho)linguists University of Groningen

Recap: multiple regression Multiple regression: predict one numerical variable on the basis of other independent variables (numerical or categorical) (Logistic regression is used to predict a binary dependent variable) We can write a regression formula as y = I + ax 1 + bx 2 +... E.g., predict the reaction time of a subject on the basis of word frequency, word length and subject age: RT = 200 5WF + 3WL + 10SA 8 Martijn Wieling Introduction to mixed-effects regression for (psycho)linguists University of Groningen

Mixed-effects regression modeling: introduction Mixed-effects regression modeling distinguishes fixed-effect and random-effect factors Fixed-effect factors: Repeatable levels Small number of levels (e.g., Gender, Word Category) Same treatment as in multiple regression (treatment coding) Random-effect factors: Levels are a non-repeatable random sample from a larger population Often large number of levels (e.g., Subject, Item) 9 Martijn Wieling Introduction to mixed-effects regression for (psycho)linguists University of Groningen

What are random-effects factors? Random-effect factors are factors which are likely to introduce systematic variation Some participants have a slow response (RT), while others are fast = Random Intercept for Subject Some words are easy to recognize, others hard = Random Intercept for Item The effect of word frequency on RT might be higher for one participant than another: e.g., non-native participants might benefit more from frequent words than native participants = Random Slope for Item Frequency per Subject The effect of subject age on RT might be different for one word than another: e.g., modern words might be recognized faster by younger participants = Random Slope for Subject Age per Item Note that it is essential to test for random slopes! 10 Martijn Wieling Introduction to mixed-effects regression for (psycho)linguists University of Groningen

Random slopes are necessary! Estimate Std. Error t value Pr(> t ) Linear regression DistOrigin -6.418e-05 1.808e-06-35.49 <2e-16 + Random intercepts DistOrigin -2.224e-05 6.863e-06-3.240 <0.001 + Random slopes DistOrigin -1.478e-05 1.519e-05-0.973 n.s. This example is explained at http://hlplab.wordpress.com 11 Martijn Wieling Introduction to mixed-effects regression for (psycho)linguists University of Groningen

Specific models for every observation Mixed-effects regression analysis allow us to use random intercepts and slopes (i.e. adjustments to the population intercept and slopes) to make the regression formula as precise as possible for every individual observation in our random effects Parsimony: a single parameter (standard deviation) models this variation for every random slope or intercept (a normal distribution with mean 0 is assumed) The adjustments to population slopes and intercepts are Best Linear Unbiased Predictors (BLUPs) AIC comparisons assess whether the inclusion of random intercepts and slopes is warranted Note that multiple observations for each level of a random effect are necessary for mixed-effects analysis to be useful (e.g., participants respond to multiple items) 12 Martijn Wieling Introduction to mixed-effects regression for (psycho)linguists University of Groningen

Specific models for every observation RT = 200 5WF + 3WL + 10SA (general model) The intercepts and slopes may vary (according to the estimated standard variation for each parameter) and this influences the word- and subject-specific values RT = 400 5WF + 3WL 2SA (word: scythe) RT = 300 5WF + 3WL + 15SA (word: twitter) RT = 300 7WF + 3WL + 10SA (subject: non-native) RT = 150 5WF + 3WL + 10SA (subject: fast) And it is easy to use! > lmer( RT WF + WL + SA + (1+SA Wrd) + (1+WF Subj) ) lmer figures out by itself if the random-effects are nested (schools-pupils), or crossed (participants-items) 13 Martijn Wieling Introduction to mixed-effects regression for (psycho)linguists University of Groningen

Specific models for every subject 14 Martijn Wieling Introduction to mixed-effects regression for (psycho)linguists University of Groningen

BLUPs of lmer do not suffer from shrinkage 2 4 6 8 10 random regression mixed effects regression 550 S4 500 S7 S6 450 S3 coef 400 350 S1 S8 S10 S7 S8 S3 S2 S5 S1 S9 S10 S6 S4 S2 S5 300 250 S9 2 4 6 8 10 rank The BLUPS (i.e. adjustment to the model estimates per item/participant) are close to the real adjustments, as lmer takes into account regression towards the mean (fast subjects will be slower next time, and slow subjects will be faster) thereby avoiding overfitting and improving prediction see Efron & Morris (1977) 15 Martijn Wieling Introduction to mixed-effects regression for (psycho)linguists University of Groningen

Methodological issues Parsimony Centering Assumptions about the residuals Normally distributed and homoskedastic No trial-by-trial dependencies Assumptions about the predictors We assume linearity, if this is not suitable you can use Generalized additive mixed-effects regression modeling (Wood, 2006) Model criticism How to select the best model? 16 Martijn Wieling Introduction to mixed-effects regression for (psycho)linguists University of Groningen

Parsimony All models are wrong Some models are better than others The correct model can never be known with certainty The simpler the model, the better it is 17 Martijn Wieling Introduction to mixed-effects regression for (psycho)linguists University of Groningen

Center your variables (i.e. subtract the mean) x y 2 4 6 8 10 10 5 0 5 10 uncentered 10 5 0 5 10 centered Otherwise random slopes and intercepts may show a spurious correlation Also helps the interpretation of factorial predictors in model (marking differences at means of other variables, rather than at values equal to 0) 18 Martijn Wieling Introduction to mixed-effects regression for (psycho)linguists University of Groningen

Residuals: normally distributed and homoskedastic The errors should follow a normal distribution with mean zero and the same standard deviation for any cell in your design, and for any covariate If not then transform the dependent variable: log(y), or -1000/Y And use mixed-effects regression Note: not required for logistic regression untransformed log inverse Sample Quantiles 200 200 600 3 2 1 0 1 2 3 Sample Quantiles 0.4 0.0 0.4 0.8 3 2 1 0 1 2 3 Sample Quantiles 1e 03 0e+00 1e 03 3 2 1 0 1 2 3 Theoretical Quantiles Theoretical Quantiles Theoretical Quantiles 19 Martijn Wieling Introduction to mixed-effects regression for (psycho)linguists University of Groningen

Residuals: no trial-by-trial dependencies Residuals should be independent With trial-by-trial dependencies, this assumption is violated, which may result in models that underperform Possible remedies: Include trial as a predictor in your model Include the value of the dependent variable at the previous trial as a predictor in your model 20 Martijn Wieling Introduction to mixed-effects regression for (psycho)linguists University of Groningen

Trial-by-trial dependencies in a word naming task Word naming (reading aloud) of Dutch verbs Trial-by-trial dependencies in the residuals of the model > acf(resid(model), main=" ", ylab="autocorrelation function") autocorrelation function 0.0 0.2 0.4 0.6 0.8 1.0 0 5 10 15 20 Lag 21 Martijn Wieling Introduction to mixed-effects regression for (psycho)linguists University of Groningen

Taking into account trial-by-trial dependencies uncorrected model corrected for Trial corrected for Trial and Preceding RT ACF 0.0 0.2 0.4 0.6 0.8 1.0 adj R squared 0.029 ACF 0.0 0.2 0.4 0.6 0.8 1.0 adj R squared 0.298 ACF 0.0 0.2 0.4 0.6 0.8 1.0 adj R squared 0.35 0 5 10 15 20 0 5 10 15 20 0 5 10 15 20 Lag Lag Lag 22 Martijn Wieling Introduction to mixed-effects regression for (psycho)linguists University of Groningen

Model criticism Check the distribution of residuals: if not normally distributed then transform dependent variable (as illustrated before) Check outlier characteristics and refit the model when large outliers are excluded to verify that your effects are not carried by these outliers Important: no a priori exclusion of outliers without a clear reason A good reason is not that the value is over 2.5 SD above the mean A good reason (e.g.,) is that the response is faster than possible 23 Martijn Wieling Introduction to mixed-effects regression for (psycho)linguists University of Groningen

Model selection I The data analyst knows more than the computer. (Henderson & Velleman, 1981) - Get to know your data! There is no adequate automatic procedure to find the best model My stepwise variable-selection procedure (for exploratory analysis): Include random intercepts Add other potential explanatory variables one-by-one Insignificant predictors are dropped Test predictors for inclusion which were excluded at an earlier stage Test possible interactions (don t make it too complex) Try to break the model by including significant predictors as random slopes Only choose a more complex model if it decreases AIC by at least 2 Then the model with the lowest AIC is at least 2.7 (e AIC 2 ) times more likely Starting from the most complex model in the context of a mixed-effects regression model is frequently impossible (the model with the full random-effects structure may not converge) 24 Martijn Wieling Introduction to mixed-effects regression for (psycho)linguists University of Groningen

Model selection II For a hypothesis-driven analysis, stepwise selection is problematic Confidence intervals too narrow: p-values too low (multiple comparisons) See, e.g., Burnham & Anderson (2002) Solutions: Careful specification of potential a priori models lining up with the hypotheses (including random intercepts and slopes) and evaluating only these models (e.g., via AIC) Validating a stepwise procedure via cross validation (e.g., bootstrap analysis) 25 Martijn Wieling Introduction to mixed-effects regression for (psycho)linguists University of Groningen

Case study: long-distance priming De Vaan, Schreuder & Baayen (The Mental Lexicon, 2007) Design long-distance priming (39 intervening items) base condition (baseheid): base preceded neologism (fluffy - fluffiness) derived condition (heid): identity priming (fluffiness - fluffiness) only items judged to be real words are included Prediction Subjects in the derived condition (heid) would be faster than those in the base condition (baseheid) 26 Martijn Wieling Introduction to mixed-effects regression for (psycho)linguists University of Groningen

A first model: counterintuitive results! (note: t > 2 p < 0.05, for N 100) > library(lme4) # version 1.1.7 (NOT compatible with version 0.9...) > dat = read.table('datprevrt.txt', header=t) # adapted primingheid data set > dat.lmer1 = lmer(rt ~ Condition + (1 Word) + (1 Subject), data=dat) > summary(dat.lmer1)... Random effects: Groups Name Variance Std.Dev. Word (Intercept) 0.003411 0.05841 Subject (Intercept) 0.040843 0.20210 Residual 0.044084 0.20996 Number of obs: 832, groups: Word, 40; Subject, 26 Fixed effects: Estimate Std. Error t value (Intercept) 6.60296 0.04215 156.66 Conditionheid 0.03127 0.01467 2.13 # slower...... 27 Martijn Wieling Introduction to mixed-effects regression for (psycho)linguists University of Groningen

Evaluation Counterintuitive inhibition But various potential factors are not accounted for in the model Longitudinal effects: trial rank, RT to preceding trial RT to prime as predictor Response to the prime (correct/incorrect): a yes response to a target associated with a previously rejected prime may take longer The presence of atypical outliers 28 Martijn Wieling Introduction to mixed-effects regression for (psycho)linguists University of Groningen

An effect of trial? > dat.lmer2 = lmer(rt ~ Trial + Condition + (1 Subject) + (1 Word), data=dat) > round( summary(dat.lmer2)$coef, 3 ) Estimate Std. Error t value (Intercept) 6.633 0.047 142.153 Trial 0.001 0.001-1.519 Conditionheid 0.031 0.015 2.114 29 Martijn Wieling Introduction to mixed-effects regression for (psycho)linguists University of Groningen

An effect of previous trial RT? > dat$prevrt = log(dat$prevrt) # RT is already log-transformed > dat.lmer3 = lmer(rt ~ PrevRT + Condition + (1 Subject) + (1 Word), data=dat) > round( summary(dat.lmer3)$coef, 3 ) Estimate Std. Error t value (Intercept) 5.805 0.223 26.032 PrevRT 0.121 0.033 3.633 Conditionheid 0.028 0.015 1.903 30 Martijn Wieling Introduction to mixed-effects regression for (psycho)linguists University of Groningen

An effect of RT to prime? > dat.lmer4 = lmer(rt ~ RTtoPrime + PrevRT + Condition + (1 Subject) + (1 Word), data=dat) > round( summary(dat.lmer4)$coef, 3 ) Estimate Std. Error t value (Intercept) 4.749 0.295 16.080 RTtoPrime 0.164 0.032 5.141 PrevRT 0.119 0.033 3.605 Conditionheid -0.006 0.016-0.383 31 Martijn Wieling Introduction to mixed-effects regression for (psycho)linguists University of Groningen

An effect of the decision for the prime? > dat.lmer5 = lmer(rt ~ RTtoPrime + ResponseToPrime + PrevRT + Condition + (1 Subject) + (1 Word), data=dat) > round( summary(dat.lmer5)$coef, 3 ) Estimate Std. Error t value (Intercept) 4.763 0.292 16.299 RTtoPrime 0.165 0.031 5.242 ResponseToPrimeincorrect 0.100 0.023 4.445 PrevRT 0.114 0.033 3.495 Conditionheid -0.018 0.016-1.107 32 Martijn Wieling Introduction to mixed-effects regression for (psycho)linguists University of Groningen

Interaction for prime-related predictors? > dat.lmer6 = lmer(rt ~ RTtoPrime * ResponseToPrime + PrevRT + Condition + (1 Subject) + (1 Word), data=dat) > round( summary(dat.lmer6)$coef, 3 ) Estimate Std. Error t value (Intercept) 4.324 0.315 13.720 RTtoPrime 0.228 0.036 6.334 ResponseToPrimeincorrect 1.455 0.405 3.590 PrevRT 0.118 0.033 3.640 Conditionheid -0.027 0.016-1.642 RTtoPrime:ResponseToPrimeincorrect -0.202 0.061-3.344 Interpretation: the RT to the prime is only predictive for the RT of the target word when the prime was judged to be a correct word 33 Martijn Wieling Introduction to mixed-effects regression for (psycho)linguists University of Groningen

An effect of base frequency? (Note the lower variance of the random intercept for word: previous value was 0.0034) > dat.lmer7 = lmer(rt ~ RTtoPrime * ResponseToPrime + PrevRT + BaseFrequency + Condition + (1 Subject) + (1 Word), data=dat) > summary(dat.lmer7) Random effects: Groups Name Variance Std.Dev. Word (Intercept) 0.001151 0.03393 Subject (Intercept) 0.023991 0.15489 Residual 0.042240 0.20552 Number of obs: 832, groups: Word, 40; Subject, 26 Fixed effects: Estimate Std. Error t value (Intercept) 4.440979 0.319605 13.895 RTtoPrime 0.218242 0.036153 6.037 ResponseToPrimeincorrect 1.397052 0.405164 3.448 PrevRT 0.115424 0.032456 3.556 BaseFrequency -0.009243 0.004371-2.115 Conditionheid -0.024656 0.016179-1.524 RTtoPrime:ResponseToPrimeincorrect -0.193987 0.060550-3.204 34 Martijn Wieling Introduction to mixed-effects regression for (psycho)linguists University of Groningen

Testing random slopes: no main frequency effect! > dat.lmer7a = lmer(rt ~ RTtoPrime * ResponseToPrime + PrevRT + BaseFrequency + Condition + (1 Subject) + (0+BaseFrequency Subject) + (1 Word), data=dat) > AIC(dat.lmer7) - AIC(dat.lmer7a) # compare AIC [1] 3.647772 # at least 2 lower: dat.lmer7a is better # Alternative to AIC comparison: Likelihood Ratio Test > anova(dat.lmer7,dat.lmer7a,refit=f) # compares models Df AIC BIC loglik deviance Chisq Chi Df Pr(>Chisq) dat.lmer7 10-125.55-78.315 72.777-145.55 dat.lmer7a 11-129.20-77.239 75.601-151.20 5.6478 1 0.01748 * > round( summary(dat.lmer7a)$coef, 3 ) Estimate Std. Error t value (Intercept) 4.482 0.317 14.124 RTtoPrime 0.218 0.036 6.067 ResponseToPrimeincorrect 1.417 0.402 3.524 PrevRT 0.108 0.032 3.354 BaseFrequency -0.008 0.005-1.485 Conditionheid -0.025 0.016-1.530 RTtoPrime:ResponseToPrimeincorrect -0.197 0.060-3.274 35 Martijn Wieling Introduction to mixed-effects regression for (psycho)linguists University of Groningen

Testing for correlation parameters in random effects > dat.lmer7b = lmer(rt ~ RTtoPrime * ResponseToPrime + PrevRT + BaseFrequency + Condition + (1+BaseFrequency Subject) + (1 Word), data=dat) > summary(dat.lmer7b)... Random effects: Groups Name Variance Std.Dev. Corr Word (Intercept) 0.0011857 0.03443 Subject (Intercept) 0.0166775 0.12914 BaseFrequency 0.0001861 0.01364 0.41 Residual 0.0414192 0.20352 Number of obs: 832, groups: Word, 40; Subject, 26... > AIC(dat.lmer7a) - AIC(dat.lmer7b) [1] -1.138734 > anova(dat.lmer7a,dat.lmer7b,refit=f) Df AIC BIC loglik deviance Chisq Chi Df Pr(>Chisq) dat.lmer7a 11-129.20-77.239 75.601-151.20 dat.lmer7b 12-128.06-71.377 76.031-152.06 0.8613 1 0.3534 36 Martijn Wieling Introduction to mixed-effects regression for (psycho)linguists University of Groningen

Model criticism > qqnorm(resid(dat.lmer7a)) > qqline(resid(dat.lmer7a)) Normal Q Q Plot Sample Quantiles 0.4 0.2 0.0 0.2 0.4 0.6 0.8 3 2 1 0 1 2 3 Theoretical Quantiles 37 Martijn Wieling Introduction to mixed-effects regression for (psycho)linguists University of Groningen

The trimmed model > dat2 = dat[ abs(scale(resid(dat.lmer7a))) < 2.5, ] > dat2.lmer7a = lmer(rt ~ RTtoPrime * ResponseToPrime + PrevRT + BaseFrequency + Condition + (1 Subject) + (0+BaseFrequency Subject) + (1 Word), data=dat2) > round( summary(dat2.lmer7a)$coef, 3 ) Estimate Std. Error t value (Intercept) 4.447 0.286 15.551 RTtoPrime 0.235 0.032 7.347 ResponseToPrimeincorrect 1.560 0.356 4.388 PrevRT 0.096 0.029 3.266 BaseFrequency -0.008 0.005-1.775 Conditionheid -0.038 0.014-2.657 RTtoPrime:ResponseToPrimeincorrect -0.216 0.053-4.066 38 Martijn Wieling Introduction to mixed-effects regression for (psycho)linguists University of Groningen

The trimmed model Just 2% of the data removed > noutliers = sum(abs(scale(resid(dat.lmer7a)))>=2.5) > noutliers [1] 17 > noutliers/nrow(dat) [1] 0.02043269 Improved fit (explained variance): > cor(dat$rt,fitted(dat.lmer7a))^2 [1] 0.5210606 > cor(dat2$rt,fitted(dat2.lmer7a))^2 [1] 0.5717716 39 Martijn Wieling Introduction to mixed-effects regression for (psycho)linguists University of Groningen

Checking the residuals of trimmed model > library(car) > qqp(resid(dat2.lmer7a)) resid(dat2.lmer7a) 0.4 0.2 0.0 0.2 0.4 3 2 1 0 1 2 3 norm quantiles 40 Martijn Wieling Introduction to mixed-effects regression for (psycho)linguists University of Groningen

Bootstrap sampling to validate results > library(boot) > bs.lmer7a = confint(dat2.lmer7a, method="boot", nsim = 1000, level = 0.95) > bs.lmer7a 2.5 % 97.5 % sd_(intercept) Word 0.000000000 0.0388402702 sd_basefrequency Subject 0.003271268 0.0218704020 sd_(intercept) Subject 0.096063055 0.1898946632 sigma 0.170499205 0.1900119424 (Intercept) 3.877547385 5.0447555391 RTtoPrime 0.172898282 0.2990675635 ResponseToPrimeincorrect 0.862874611 2.3142086875 PrevRT 0.033960630 0.1591520465 BaseFrequency -0.017415646 0.0007102762 # n.s. Conditionheid -0.064896445-0.0084641311 RTtoPrime:ResponseToPrimeincorrect -0.329769967-0.1099138944 41 Martijn Wieling Introduction to mixed-effects regression for (psycho)linguists University of Groningen

Conclusion Mixed-effects regression is more flexible than using ANOVAs Testing for inclusion of random intercepts and slopes is essential when you have multiple responses per subject or item Mixed-effects regression is easy with lmer in R Don t forget model criticism! Lab session to illustrate the commands used here http://www.let.rug.nl/wieling/statscourse/lecture1 Lab session contains additional information: how to do multiple comparisons, using other optimizers, and conducting logistic regression 42 Martijn Wieling Introduction to mixed-effects regression for (psycho)linguists University of Groningen

Thank you for your attention! 43 Martijn Wieling Introduction to mixed-effects regression for (psycho)linguists University of Groningen