SlideShare une entreprise Scribd logo
1  sur  41
Télécharger pour lire hors ligne
Course Business
! Lab materials on Canvas
! Package to install for today’s analyses:
languageR
Week 11.2: Autocorrelation
! Autocorrelation
! Introduction
! Testing for Autocorrelation
! Visualizing Autocorrelation
! Direction & Lag
! Why Does Autocorrelation Matter?
! Lab
Longitudinal Designs
• Two big questions mixed-effects models can
help us answer about longitudinal data:
1) What is the overall trajectory of change
across time?
" Monday: Growth curve analysis
2) How does an observation at one time point
relate to the next time point?
" Today: Autocorrelation
Autocorrelation
• Previously, we looked at general trajectory
across time
• e.g., kids who are 28 months old have larger
vocabs than kids who are 20 months old
• But, there may be relations among specific
observations
• Does reading to your kids a lot one month
increase their vocab growth the next month?
• Does being in a positive mood one day carry over
to the next day?
• Does purchasing a particular brand once make
you more likely to purchase it again?
relationship.csv
• One member of a dating couple rates their
warmth towards the partner
• For each of 10 consecutive days
• First, let’s see if WarmthToday consistently
increases or decreases across the 10 Days of
the study
• model.time <- lmer(WarmthToday ~ 1 + Day +
(1 + Day|Couple), data=relationship)
relationship.csv
• No linear increase or decrease in warmth over
the 10 days
• Makes sense … this is a relatively short timescale
Autocorrelation
• We found no overall increase/decrease
• Nevertheless, succeeding days might be more
similar, even if there is no overall trend
1 2 3 4 5
L I N E A R T R E N D
Autocorrelation
• We found no overall increase/decrease
• Nevertheless, succeeding days might be more
similar, even if there is no overall trend
• If you have warm feelings towards your partner
one day, maybe warmer the next, too
+ 2 3 4 5
L I N E A R T R E N D
Autocorrelation
• We found no overall increase/decrease
• Nevertheless, succeeding days might be more
similar, even if there is no overall trend
• If you have warm feelings towards your partner
one day, maybe warmer the next, too
+ + 3 4 5
L I N E A R T R E N D
Autocorrelation
• We found no overall increase/decrease
• Nevertheless, succeeding days might be more
similar, even if there is no overall trend
• If you have warm feelings towards your partner
one day, maybe warmer the next, too
• If you have negative feelings, maybe less warm
the next day
+ + 3 - 5
L I N E A R T R E N D
Autocorrelation
• We found no overall increase/decrease
• Nevertheless, succeeding days might be more
similar, even if there is no overall trend
• If you have warm feelings towards your partner
one day, maybe warmer the next, too
• If you have negative feelings, maybe less warm
the next day
+ + 3 - -
L I N E A R T R E N D
Autocorrelation
• We found no overall increase/decrease
• Nevertheless, succeeding days might be more
similar, even if there is no overall trend
• If you have warm feelings towards your partner
one day, maybe warmer the next, too
• If you have negative feelings, maybe less warm
the next day
+ + 3 - -
Autocorrelation
• relationship %>% head(n=10)
Couple 01
Autocorrelation
• These are examples of autocorrelation
Couple 01 Couple 02
Autocorrelation
"Maybe in order to understand mankind, we have
to look at that word itself: MANKIND. Basically,
it's made up of two separate words, 'mank' and
'ind.' What do these words mean? It's a mystery,
and that's why so is mankind.”
-- Jack Handey
Autocorrelation
To understand autocorrelation, we have to look
at the two separate words that make it up
auto (self) + correlation
• Autocorrelation refers to a variable correlating
with itself, over time
• Examples:
• Positive mood in the morning # Positive mood in
the afternoon
• RT on the previous trial # RT on this trial due to
waxing & waning of attention
Autocorrelation
• These are examples of autocorrelation
Couple 01 Couple 02
Week 11.2: Autocorrelation
! Autocorrelation
! Introduction
! Testing for Autocorrelation
! Visualizing Autocorrelation
! Direction & Lag
! Why Does Autocorrelation Matter?
! Lab
Testing for Autocorrelation
• Is there autocorrelation in relationship warmth?
• We want to test whether yesterday’s warmth
predicts today’s warmth
• So, we need to add WarmthYesterday as a variable
• With package languageR…
• relationship %>% mutate(WarmthYesterday =
lags.fnc(relationship,
time='Day',
depvar='WarmthToday',
group='Couple’,
lag=1)) -> relationship
• For each observation, get the value of WarmthToday
from 1 day previous and store in WarmthYesterday
Variable that identifies the time point
Dependent variable
Variable with the level-2 grouping
factor (e.g., subjects or schools)
Dataframe name
Baayen & Milin, 2010
Testing for Autocorrelation
• Is there autocorrelation in relationship warmth?
• We want to test whether yesterday’s warmth
predicts today’s warmth
• So, we need to add WarmthYesterday as a variable
• relationship %>% head(n=13)
Day 1 for each couple
gets the couple’s mean
Baayen & Milin, 2010
Testing for Autocorrelation
• Is there autocorrelation in relationship warmth?
• Now, include WarmthYesterday in our model
• model.auto <- lmer(WarmthToday ~
1 + Day + WarmthYesterday +
(1 + Day + WarmthYesterday|Couple),
data=relationship)
Testing for Autocorrelation
• Non-significant linear effect: No consistent
increase/decrease in warmth over these 10 days
• But, significant autocorrelation: Adjacent days are
more similar in warmth towards partner
• Random walk
1 2 3 4 5
L I N E A R T R E N D
X
Autocorrelation
• These are examples of autocorrelation
Couple 01 Couple 02
Week 11.2: Autocorrelation
! Autocorrelation
! Introduction
! Testing for Autocorrelation
! Visualizing Autocorrelation
! Direction & Lag
! Why Does Autocorrelation Matter?
! Lab
Visualization of Autocorrelation
• Visualization of the autocorrelation
• With package languageR:
• acf.fnc(xxx ,
time='xxx ',
x=' ',
group=' ')
Variable that identifies the time point
Dependent variable
Variable with the level-2 grouping
factor (e.g., subjects or schools).
Needs to be a FACTOR variable
Dataframe name
Baayen & Milin, 2010
Visualization of Autocorrelation
• Visualization of the autocorrelation
• With package languageR:
• acf.fnc(relationship,
time='Day',
x='WarmthToday',
group='Couple')
Variable that identifies the time point
Dependent variable
Variable with the level-2 grouping
factor (e.g., subjects or schools).
Needs to be a FACTOR variable
Dataframe name
Baayen & Milin, 2010
Lag
Acf
-0.5
0.0
0.5
1.0
0 2 4 6 8
Couple01 Couple02
0 2 4 6 8
Couple03 Couple04
0 2 4 6 8
Couple05 Couple06
0 2 4 6 8
Couple07
Couple08 Couple09 Couple10 Couple11 Couple12 Couple13
-0.5
0.0
0.5
1.0
Couple14
-0.5
0.0
0.5
1.0
Couple15 Couple16 Couple17 Couple18 Couple19 Couple20 Couple21
Couple22 Couple23 Couple24 Couple25 Couple26 Couple27
-0.5
0.0
0.5
1.0
Couple28
-0.5
0.0
0.5
1.0
Couple29 Couple30 Couple31 Couple32 Couple33 Couple34 Couple35
Couple36
0 2 4 6 8
Couple37 Couple38
0 2 4 6 8
Couple39
-0.5
0.0
0.5
1.0
Couple40
One box
per
couple
Height of the second
line indicates strength of
autocorrelation for that
couple
Week 11.2: Autocorrelation
! Autocorrelation
! Introduction
! Testing for Autocorrelation
! Visualizing Autocorrelation
! Direction & Lag
! Why Does Autocorrelation Matter?
! Lab
Direction of Autocorrelation
• Positive autocorrelation—Having more of something
at time t means you have more of it at time t+1
• More warmth on day 3 # More warmth on day 4
• Longer RT on one trial # Longer RT on the next trial
• Negative autocorrelation—Having more
at time t means you have less at t+1
• e.g., homeostatic processes
• Very hungry at time t # Get something
to eat # Not hungry at time t+1
• Stock prices: Price increases # People
sell the stock # Price decreases
• Both analyzed the same way—just look at the sign to
understand the effect
Positive autocorrelation.
This bar would be < 0 if
it were a negative
autocorrelation.
Lag
Acf
-0.5
0.0
0.5
1.0
0 2 4 6 8
Couple01 Couple02
0 2 4 6 8
Couple03 Couple04
0 2 4 6 8
Couple05 Couple06
0 2 4 6 8
Couple07
Couple08 Couple09 Couple10 Couple11 Couple12 Couple13
-0.5
0.0
0.5
1.0
Couple14
-0.5
0.0
0.5
1.0
Couple15 Couple16 Couple17 Couple18 Couple19 Couple20 Couple21
Couple22 Couple23 Couple24 Couple25 Couple26 Couple27
-0.5
0.0
0.5
1.0
Couple28
-0.5
0.0
0.5
1.0
Couple29 Couple30 Couple31 Couple32 Couple33 Couple34 Couple35
Couple36
0 2 4 6 8
Couple37 Couple38
0 2 4 6 8
Couple39
-0.5
0.0
0.5
1.0
Couple40
Autocorrelation: Lag
• Autocorrelation can happen at different time
scales or lags
• Most common is lag 1: an observation correlates
with the next one
1 2 3 4 5
Autocorrelation: Lag
• Autocorrelation can happen at different time
scales or lags
• Most common is lag 1: an observation correlates
with the next one
1 2 3 4 5
Autocorrelation: Lag
• Autocorrelation can happen at different time
scales or lags
• Most common is lag 1: an observation correlates
with the next one
• Lag 2: an observation correlates not with the next
observation, but the one two time points later
• Like the (false) idea that twins “skip a generation”
• Effects that recur, but not immediately (e.g.,
earthquakes)
1 2 3 4 5
Autocorrelation: Lag
• Autocorrelation can happen at different time
scales or lags
• Most common is lag 1: an observation correlates
with the next one
• Lag 2: an observation correlates not with the next
observation, but the one two time points later
• Like the (false) idea that twins “skip a generation”
• Lag 3, Lag 4, etc…
• Mood might have a lag 7 autocorrelation –
weekly change (sad Monday, happy Friday)
• But, be careful with autocorrelations >1—is
there a theoretically plausible reason to
expect them?
Lag
1
autocorrelation
Lag
2
autocorrelation
Lag
3
autocorrelation
Leftmost line
is lag 0—i.e.,
the correlation
of an
observation
with itself
This will
always be 1
It’s shown for
purposes of
comparison
Lag
Acf
-0.5
0.0
0.5
1.0
0 2 4 6 8
Couple01 Couple02
0 2 4 6 8
Couple03 Couple04
0 2 4 6 8
Couple05 Couple06
0 2 4 6 8
Couple07
Couple08 Couple09 Couple10 Couple11 Couple12 Couple13
-0.5
0.0
0.5
1.0
Couple14
-0.5
0.0
0.5
1.0
Couple15 Couple16 Couple17 Couple18 Couple19 Couple20 Couple21
Couple22 Couple23 Couple24 Couple25 Couple26 Couple27
-0.5
0.0
0.5
1.0
Couple28
-0.5
0.0
0.5
1.0
Couple29 Couple30 Couple31 Couple32 Couple33 Couple34 Couple35
Couple36
0 2 4 6 8
Couple37 Couple38
0 2 4 6 8
Couple39
-0.5
0.0
0.5
1.0
Couple40
Testing Autocorrelation, continued
• Does our lag 1 autocorrelation account for the
sequential dependency?
• Examine the autocorrelation of the model
residuals
• relationship %>% mutate(resids =
resid(model.auto)) -> relationship
• Now run acf.fnc() on resids rather than
WarmthToday
Baayen & Milin, 2010
Lag
Acf
-0.5
0.0
0.5
1.0
0 2 4 6 8
Couple01 Couple02
0 2 4 6 8
Couple03 Couple04
0 2 4 6 8
Couple05 Couple06
0 2 4 6 8
Couple07
Couple08 Couple09 Couple10 Couple11 Couple12 Couple13
-0.5
0.0
0.5
1.0
Couple14
-0.5
0.0
0.5
1.0
Couple15 Couple16 Couple17 Couple18 Couple19 Couple20 Couple21
Couple22 Couple23 Couple24 Couple25 Couple26 Couple27
-0.5
0.0
0.5
1.0
Couple28
-0.5
0.0
0.5
1.0
Couple29 Couple30 Couple31 Couple32 Couple33 Couple34 Couple35
Couple36
0 2 4 6 8
Couple37 Couple38
0 2 4 6 8
Couple39
-0.5
0.0
0.5
1.0
Couple40 No consistent
autocorrelation
remaining in the
data
Week 11.2: Autocorrelation
! Autocorrelation
! Introduction
! Testing for Autocorrelation
! Visualizing Autocorrelation
! Direction & Lag
! Why Does Autocorrelation Matter?
! Lab
Why Does Autocorrelation Matter?
• Autocorrelation can be an interesting research
question in its own right
• Important for model assumptions
• A simple growth-curve model:
• Assumes that time matters only insofar
as there’s a general increase/decrease with time
• Otherwise, all observations from a couple equally
similar or dissimilar … error terms independent
=
Warmth
Yi(j) γ00
Overall
baseline
Time
γ10x1(j)
+ U0j
Random
intercept for
couple
+ Error term—
independent,
identically
distributed
Ei(j)
+
Why Does Autocorrelation Matter?
• Autocorrelation can be an interesting research
question in its own right
• Important for model assumptions
• Assumption all observations from a couple equally
similar or dissimilar … error terms independent
• Not true if there’s autocorrelation … observations
similar in time dependent on one another
• Underestimates
standard error
# inflates Type I
error 1 2 3 4 5
L I N E A R T R E N D
Week 11.2: Autocorrelation
! Autocorrelation
! Introduction
! Testing for Autocorrelation
! Visualizing Autocorrelation
! Direction & Lag
! Why Does Autocorrelation Matter?
! Lab

Contenu connexe

Tendances

3 2 polynomial inequalities
3 2 polynomial inequalities3 2 polynomial inequalities
3 2 polynomial inequalities
hisema01
 
Family of Functions Introduction
Family of Functions IntroductionFamily of Functions Introduction
Family of Functions Introduction
kshoskey
 
Unitary ratio, direct and inverse proportions
Unitary ratio, direct and inverse proportionsUnitary ratio, direct and inverse proportions
Unitary ratio, direct and inverse proportions
Pensil Dan Pemadam
 

Tendances (20)

Mixed Effects Models - Post-Hoc Comparisons
Mixed Effects Models - Post-Hoc ComparisonsMixed Effects Models - Post-Hoc Comparisons
Mixed Effects Models - Post-Hoc Comparisons
 
Mixed Effects Models - Crossed Random Effects
Mixed Effects Models - Crossed Random EffectsMixed Effects Models - Crossed Random Effects
Mixed Effects Models - Crossed Random Effects
 
NUMERICAL METHODS
NUMERICAL METHODSNUMERICAL METHODS
NUMERICAL METHODS
 
Multinomial Logistic Regression
Multinomial Logistic RegressionMultinomial Logistic Regression
Multinomial Logistic Regression
 
Introduction of mixed effect model
Introduction of mixed effect modelIntroduction of mixed effect model
Introduction of mixed effect model
 
What is a kendall's tau?
What is a kendall's tau?What is a kendall's tau?
What is a kendall's tau?
 
Stepwise regression Backward selection
Stepwise regression Backward selectionStepwise regression Backward selection
Stepwise regression Backward selection
 
Reporting Chi Square Test of Independence in APA
Reporting Chi Square Test of Independence in APAReporting Chi Square Test of Independence in APA
Reporting Chi Square Test of Independence in APA
 
Normal curve
Normal curveNormal curve
Normal curve
 
Reporting spearman rho in apa
Reporting spearman rho in apaReporting spearman rho in apa
Reporting spearman rho in apa
 
3 2 polynomial inequalities
3 2 polynomial inequalities3 2 polynomial inequalities
3 2 polynomial inequalities
 
Reporting kendall's tau in apa (1)
Reporting kendall's tau in apa (1)Reporting kendall's tau in apa (1)
Reporting kendall's tau in apa (1)
 
mathematical model
mathematical modelmathematical model
mathematical model
 
Numerical Analysis and Its application to Boundary Value Problems
Numerical Analysis and Its application to Boundary Value ProblemsNumerical Analysis and Its application to Boundary Value Problems
Numerical Analysis and Its application to Boundary Value Problems
 
Wilcoxon Signed Rank Test
Wilcoxon Signed Rank Test Wilcoxon Signed Rank Test
Wilcoxon Signed Rank Test
 
Sample size by formula
Sample size by formulaSample size by formula
Sample size by formula
 
Family of Functions Introduction
Family of Functions IntroductionFamily of Functions Introduction
Family of Functions Introduction
 
Unitary ratio, direct and inverse proportions
Unitary ratio, direct and inverse proportionsUnitary ratio, direct and inverse proportions
Unitary ratio, direct and inverse proportions
 
Repeated Measures ANOVA
Repeated Measures ANOVARepeated Measures ANOVA
Repeated Measures ANOVA
 
Logistic regression with SPSS
Logistic regression with SPSSLogistic regression with SPSS
Logistic regression with SPSS
 

Similaire à Mixed Effects Models - Autocorrelation

Correlation coefficient and it’s use in day to.pptx
Correlation coefficient and it’s use in day to.pptxCorrelation coefficient and it’s use in day to.pptx
Correlation coefficient and it’s use in day to.pptx
PrathamSiddannavar
 
Illogical frameworks
Illogical frameworksIllogical frameworks
Illogical frameworks
Steve Powell
 
The Crucible Character Analysis Essay. Crucible Character Analysis Facebook a...
The Crucible Character Analysis Essay. Crucible Character Analysis Facebook a...The Crucible Character Analysis Essay. Crucible Character Analysis Facebook a...
The Crucible Character Analysis Essay. Crucible Character Analysis Facebook a...
Carolyn Collum
 
· Self-Assessment· InterpretationValues and Moral Survey of St
· Self-Assessment· InterpretationValues and Moral Survey of St· Self-Assessment· InterpretationValues and Moral Survey of St
· Self-Assessment· InterpretationValues and Moral Survey of St
LesleyWhitesidefv
 
Problem-Solving Strategies
Problem-Solving StrategiesProblem-Solving Strategies
Problem-Solving Strategies
Stephen Babbitt
 

Similaire à Mixed Effects Models - Autocorrelation (20)

Correlation coefficient and it’s use in day to.pptx
Correlation coefficient and it’s use in day to.pptxCorrelation coefficient and it’s use in day to.pptx
Correlation coefficient and it’s use in day to.pptx
 
Integrated Math 2 Section 1-4 and 1-5
Integrated Math 2 Section 1-4 and 1-5Integrated Math 2 Section 1-4 and 1-5
Integrated Math 2 Section 1-4 and 1-5
 
Illogical frameworks
Illogical frameworksIllogical frameworks
Illogical frameworks
 
IELTS WRITING TAST 2 Tips and Overview.pdf
IELTS WRITING TAST 2 Tips and Overview.pdfIELTS WRITING TAST 2 Tips and Overview.pdf
IELTS WRITING TAST 2 Tips and Overview.pdf
 
The Crucible Character Analysis Essay. Crucible Character Analysis Facebook a...
The Crucible Character Analysis Essay. Crucible Character Analysis Facebook a...The Crucible Character Analysis Essay. Crucible Character Analysis Facebook a...
The Crucible Character Analysis Essay. Crucible Character Analysis Facebook a...
 
Topic 5 (multiple regression)
Topic 5 (multiple regression)Topic 5 (multiple regression)
Topic 5 (multiple regression)
 
Topic 5 (multiple regression)
Topic 5 (multiple regression)Topic 5 (multiple regression)
Topic 5 (multiple regression)
 
· Self-Assessment· InterpretationValues and Moral Survey of St
· Self-Assessment· InterpretationValues and Moral Survey of St· Self-Assessment· InterpretationValues and Moral Survey of St
· Self-Assessment· InterpretationValues and Moral Survey of St
 
Problem solving& Decision Making
Problem solving& Decision MakingProblem solving& Decision Making
Problem solving& Decision Making
 
B1 nurturing your relationship
B1 nurturing your relationshipB1 nurturing your relationship
B1 nurturing your relationship
 
Problem-Solving Strategies
Problem-Solving StrategiesProblem-Solving Strategies
Problem-Solving Strategies
 
What is A/B-testing? An Introduction
What is A/B-testing? An IntroductionWhat is A/B-testing? An Introduction
What is A/B-testing? An Introduction
 
Mixed Effects Models - Random Intercepts
Mixed Effects Models - Random InterceptsMixed Effects Models - Random Intercepts
Mixed Effects Models - Random Intercepts
 
Correlation Tutorial
Correlation TutorialCorrelation Tutorial
Correlation Tutorial
 
Chapter 3 powerpoint_jsd_
Chapter 3 powerpoint_jsd_Chapter 3 powerpoint_jsd_
Chapter 3 powerpoint_jsd_
 
L2 - Simplifing Ratios.pptx
L2 - Simplifing              Ratios.pptxL2 - Simplifing              Ratios.pptx
L2 - Simplifing Ratios.pptx
 
Cause and effect essay
Cause and effect essayCause and effect essay
Cause and effect essay
 
HSC Chemistry Revision Module 5.pptx
HSC Chemistry Revision Module 5.pptxHSC Chemistry Revision Module 5.pptx
HSC Chemistry Revision Module 5.pptx
 
Lec5
Lec5Lec5
Lec5
 
IELTS Task 2 Agree or Disagree Lesson
IELTS Task 2 Agree or Disagree Lesson IELTS Task 2 Agree or Disagree Lesson
IELTS Task 2 Agree or Disagree Lesson
 

Plus de Scott Fraundorf

Plus de Scott Fraundorf (11)

Mixed Effects Models - Signal Detection Theory
Mixed Effects Models - Signal Detection TheoryMixed Effects Models - Signal Detection Theory
Mixed Effects Models - Signal Detection Theory
 
Mixed Effects Models - Power
Mixed Effects Models - PowerMixed Effects Models - Power
Mixed Effects Models - Power
 
Mixed Effects Models - Missing Data
Mixed Effects Models - Missing DataMixed Effects Models - Missing Data
Mixed Effects Models - Missing Data
 
Mixed Effects Models - Empirical Logit
Mixed Effects Models - Empirical LogitMixed Effects Models - Empirical Logit
Mixed Effects Models - Empirical Logit
 
Mixed Effects Models - Simple and Main Effects
Mixed Effects Models - Simple and Main EffectsMixed Effects Models - Simple and Main Effects
Mixed Effects Models - Simple and Main Effects
 
Mixed Effects Models - Centering and Transformations
Mixed Effects Models - Centering and TransformationsMixed Effects Models - Centering and Transformations
Mixed Effects Models - Centering and Transformations
 
Mixed Effects Models - Level-2 Variables
Mixed Effects Models - Level-2 VariablesMixed Effects Models - Level-2 Variables
Mixed Effects Models - Level-2 Variables
 
Mixed Effects Models - Model Comparison
Mixed Effects Models - Model ComparisonMixed Effects Models - Model Comparison
Mixed Effects Models - Model Comparison
 
Mixed Effects Models - Fixed Effect Interactions
Mixed Effects Models - Fixed Effect InteractionsMixed Effects Models - Fixed Effect Interactions
Mixed Effects Models - Fixed Effect Interactions
 
Mixed Effects Models - Descriptive Statistics
Mixed Effects Models - Descriptive StatisticsMixed Effects Models - Descriptive Statistics
Mixed Effects Models - Descriptive Statistics
 
Scott_Fraundorf_Resume
Scott_Fraundorf_ResumeScott_Fraundorf_Resume
Scott_Fraundorf_Resume
 

Dernier

Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
PECB
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
QucHHunhnh
 
Making and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfMaking and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdf
Chris Hunter
 

Dernier (20)

Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
Energy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural Resources
Energy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural ResourcesEnergy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural Resources
Energy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural Resources
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
 
Role Of Transgenic Animal In Target Validation-1.pptx
Role Of Transgenic Animal In Target Validation-1.pptxRole Of Transgenic Animal In Target Validation-1.pptx
Role Of Transgenic Animal In Target Validation-1.pptx
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SD
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptx
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
Asian American Pacific Islander Month DDSD 2024.pptx
Asian American Pacific Islander Month DDSD 2024.pptxAsian American Pacific Islander Month DDSD 2024.pptx
Asian American Pacific Islander Month DDSD 2024.pptx
 
Making and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfMaking and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdf
 
Food Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-II
Food Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-IIFood Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-II
Food Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-II
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 

Mixed Effects Models - Autocorrelation

  • 1. Course Business ! Lab materials on Canvas ! Package to install for today’s analyses: languageR
  • 2. Week 11.2: Autocorrelation ! Autocorrelation ! Introduction ! Testing for Autocorrelation ! Visualizing Autocorrelation ! Direction & Lag ! Why Does Autocorrelation Matter? ! Lab
  • 3. Longitudinal Designs • Two big questions mixed-effects models can help us answer about longitudinal data: 1) What is the overall trajectory of change across time? " Monday: Growth curve analysis 2) How does an observation at one time point relate to the next time point? " Today: Autocorrelation
  • 4. Autocorrelation • Previously, we looked at general trajectory across time • e.g., kids who are 28 months old have larger vocabs than kids who are 20 months old • But, there may be relations among specific observations • Does reading to your kids a lot one month increase their vocab growth the next month? • Does being in a positive mood one day carry over to the next day? • Does purchasing a particular brand once make you more likely to purchase it again?
  • 5. relationship.csv • One member of a dating couple rates their warmth towards the partner • For each of 10 consecutive days • First, let’s see if WarmthToday consistently increases or decreases across the 10 Days of the study • model.time <- lmer(WarmthToday ~ 1 + Day + (1 + Day|Couple), data=relationship)
  • 6. relationship.csv • No linear increase or decrease in warmth over the 10 days • Makes sense … this is a relatively short timescale
  • 7. Autocorrelation • We found no overall increase/decrease • Nevertheless, succeeding days might be more similar, even if there is no overall trend 1 2 3 4 5 L I N E A R T R E N D
  • 8. Autocorrelation • We found no overall increase/decrease • Nevertheless, succeeding days might be more similar, even if there is no overall trend • If you have warm feelings towards your partner one day, maybe warmer the next, too + 2 3 4 5 L I N E A R T R E N D
  • 9. Autocorrelation • We found no overall increase/decrease • Nevertheless, succeeding days might be more similar, even if there is no overall trend • If you have warm feelings towards your partner one day, maybe warmer the next, too + + 3 4 5 L I N E A R T R E N D
  • 10. Autocorrelation • We found no overall increase/decrease • Nevertheless, succeeding days might be more similar, even if there is no overall trend • If you have warm feelings towards your partner one day, maybe warmer the next, too • If you have negative feelings, maybe less warm the next day + + 3 - 5 L I N E A R T R E N D
  • 11. Autocorrelation • We found no overall increase/decrease • Nevertheless, succeeding days might be more similar, even if there is no overall trend • If you have warm feelings towards your partner one day, maybe warmer the next, too • If you have negative feelings, maybe less warm the next day + + 3 - - L I N E A R T R E N D
  • 12. Autocorrelation • We found no overall increase/decrease • Nevertheless, succeeding days might be more similar, even if there is no overall trend • If you have warm feelings towards your partner one day, maybe warmer the next, too • If you have negative feelings, maybe less warm the next day + + 3 - -
  • 13. Autocorrelation • relationship %>% head(n=10) Couple 01
  • 14. Autocorrelation • These are examples of autocorrelation Couple 01 Couple 02
  • 15. Autocorrelation "Maybe in order to understand mankind, we have to look at that word itself: MANKIND. Basically, it's made up of two separate words, 'mank' and 'ind.' What do these words mean? It's a mystery, and that's why so is mankind.” -- Jack Handey
  • 16. Autocorrelation To understand autocorrelation, we have to look at the two separate words that make it up auto (self) + correlation • Autocorrelation refers to a variable correlating with itself, over time • Examples: • Positive mood in the morning # Positive mood in the afternoon • RT on the previous trial # RT on this trial due to waxing & waning of attention
  • 17. Autocorrelation • These are examples of autocorrelation Couple 01 Couple 02
  • 18. Week 11.2: Autocorrelation ! Autocorrelation ! Introduction ! Testing for Autocorrelation ! Visualizing Autocorrelation ! Direction & Lag ! Why Does Autocorrelation Matter? ! Lab
  • 19. Testing for Autocorrelation • Is there autocorrelation in relationship warmth? • We want to test whether yesterday’s warmth predicts today’s warmth • So, we need to add WarmthYesterday as a variable • With package languageR… • relationship %>% mutate(WarmthYesterday = lags.fnc(relationship, time='Day', depvar='WarmthToday', group='Couple’, lag=1)) -> relationship • For each observation, get the value of WarmthToday from 1 day previous and store in WarmthYesterday Variable that identifies the time point Dependent variable Variable with the level-2 grouping factor (e.g., subjects or schools) Dataframe name Baayen & Milin, 2010
  • 20. Testing for Autocorrelation • Is there autocorrelation in relationship warmth? • We want to test whether yesterday’s warmth predicts today’s warmth • So, we need to add WarmthYesterday as a variable • relationship %>% head(n=13) Day 1 for each couple gets the couple’s mean Baayen & Milin, 2010
  • 21. Testing for Autocorrelation • Is there autocorrelation in relationship warmth? • Now, include WarmthYesterday in our model • model.auto <- lmer(WarmthToday ~ 1 + Day + WarmthYesterday + (1 + Day + WarmthYesterday|Couple), data=relationship)
  • 22. Testing for Autocorrelation • Non-significant linear effect: No consistent increase/decrease in warmth over these 10 days • But, significant autocorrelation: Adjacent days are more similar in warmth towards partner • Random walk 1 2 3 4 5 L I N E A R T R E N D X
  • 23. Autocorrelation • These are examples of autocorrelation Couple 01 Couple 02
  • 24. Week 11.2: Autocorrelation ! Autocorrelation ! Introduction ! Testing for Autocorrelation ! Visualizing Autocorrelation ! Direction & Lag ! Why Does Autocorrelation Matter? ! Lab
  • 25. Visualization of Autocorrelation • Visualization of the autocorrelation • With package languageR: • acf.fnc(xxx , time='xxx ', x=' ', group=' ') Variable that identifies the time point Dependent variable Variable with the level-2 grouping factor (e.g., subjects or schools). Needs to be a FACTOR variable Dataframe name Baayen & Milin, 2010
  • 26. Visualization of Autocorrelation • Visualization of the autocorrelation • With package languageR: • acf.fnc(relationship, time='Day', x='WarmthToday', group='Couple') Variable that identifies the time point Dependent variable Variable with the level-2 grouping factor (e.g., subjects or schools). Needs to be a FACTOR variable Dataframe name Baayen & Milin, 2010
  • 27. Lag Acf -0.5 0.0 0.5 1.0 0 2 4 6 8 Couple01 Couple02 0 2 4 6 8 Couple03 Couple04 0 2 4 6 8 Couple05 Couple06 0 2 4 6 8 Couple07 Couple08 Couple09 Couple10 Couple11 Couple12 Couple13 -0.5 0.0 0.5 1.0 Couple14 -0.5 0.0 0.5 1.0 Couple15 Couple16 Couple17 Couple18 Couple19 Couple20 Couple21 Couple22 Couple23 Couple24 Couple25 Couple26 Couple27 -0.5 0.0 0.5 1.0 Couple28 -0.5 0.0 0.5 1.0 Couple29 Couple30 Couple31 Couple32 Couple33 Couple34 Couple35 Couple36 0 2 4 6 8 Couple37 Couple38 0 2 4 6 8 Couple39 -0.5 0.0 0.5 1.0 Couple40 One box per couple Height of the second line indicates strength of autocorrelation for that couple
  • 28. Week 11.2: Autocorrelation ! Autocorrelation ! Introduction ! Testing for Autocorrelation ! Visualizing Autocorrelation ! Direction & Lag ! Why Does Autocorrelation Matter? ! Lab
  • 29. Direction of Autocorrelation • Positive autocorrelation—Having more of something at time t means you have more of it at time t+1 • More warmth on day 3 # More warmth on day 4 • Longer RT on one trial # Longer RT on the next trial • Negative autocorrelation—Having more at time t means you have less at t+1 • e.g., homeostatic processes • Very hungry at time t # Get something to eat # Not hungry at time t+1 • Stock prices: Price increases # People sell the stock # Price decreases • Both analyzed the same way—just look at the sign to understand the effect
  • 30. Positive autocorrelation. This bar would be < 0 if it were a negative autocorrelation. Lag Acf -0.5 0.0 0.5 1.0 0 2 4 6 8 Couple01 Couple02 0 2 4 6 8 Couple03 Couple04 0 2 4 6 8 Couple05 Couple06 0 2 4 6 8 Couple07 Couple08 Couple09 Couple10 Couple11 Couple12 Couple13 -0.5 0.0 0.5 1.0 Couple14 -0.5 0.0 0.5 1.0 Couple15 Couple16 Couple17 Couple18 Couple19 Couple20 Couple21 Couple22 Couple23 Couple24 Couple25 Couple26 Couple27 -0.5 0.0 0.5 1.0 Couple28 -0.5 0.0 0.5 1.0 Couple29 Couple30 Couple31 Couple32 Couple33 Couple34 Couple35 Couple36 0 2 4 6 8 Couple37 Couple38 0 2 4 6 8 Couple39 -0.5 0.0 0.5 1.0 Couple40
  • 31. Autocorrelation: Lag • Autocorrelation can happen at different time scales or lags • Most common is lag 1: an observation correlates with the next one 1 2 3 4 5 Autocorrelation: Lag • Autocorrelation can happen at different time scales or lags • Most common is lag 1: an observation correlates with the next one 1 2 3 4 5
  • 32. Autocorrelation: Lag • Autocorrelation can happen at different time scales or lags • Most common is lag 1: an observation correlates with the next one • Lag 2: an observation correlates not with the next observation, but the one two time points later • Like the (false) idea that twins “skip a generation” • Effects that recur, but not immediately (e.g., earthquakes) 1 2 3 4 5
  • 33. Autocorrelation: Lag • Autocorrelation can happen at different time scales or lags • Most common is lag 1: an observation correlates with the next one • Lag 2: an observation correlates not with the next observation, but the one two time points later • Like the (false) idea that twins “skip a generation” • Lag 3, Lag 4, etc… • Mood might have a lag 7 autocorrelation – weekly change (sad Monday, happy Friday) • But, be careful with autocorrelations >1—is there a theoretically plausible reason to expect them?
  • 34. Lag 1 autocorrelation Lag 2 autocorrelation Lag 3 autocorrelation Leftmost line is lag 0—i.e., the correlation of an observation with itself This will always be 1 It’s shown for purposes of comparison
  • 35. Lag Acf -0.5 0.0 0.5 1.0 0 2 4 6 8 Couple01 Couple02 0 2 4 6 8 Couple03 Couple04 0 2 4 6 8 Couple05 Couple06 0 2 4 6 8 Couple07 Couple08 Couple09 Couple10 Couple11 Couple12 Couple13 -0.5 0.0 0.5 1.0 Couple14 -0.5 0.0 0.5 1.0 Couple15 Couple16 Couple17 Couple18 Couple19 Couple20 Couple21 Couple22 Couple23 Couple24 Couple25 Couple26 Couple27 -0.5 0.0 0.5 1.0 Couple28 -0.5 0.0 0.5 1.0 Couple29 Couple30 Couple31 Couple32 Couple33 Couple34 Couple35 Couple36 0 2 4 6 8 Couple37 Couple38 0 2 4 6 8 Couple39 -0.5 0.0 0.5 1.0 Couple40
  • 36. Testing Autocorrelation, continued • Does our lag 1 autocorrelation account for the sequential dependency? • Examine the autocorrelation of the model residuals • relationship %>% mutate(resids = resid(model.auto)) -> relationship • Now run acf.fnc() on resids rather than WarmthToday Baayen & Milin, 2010
  • 37. Lag Acf -0.5 0.0 0.5 1.0 0 2 4 6 8 Couple01 Couple02 0 2 4 6 8 Couple03 Couple04 0 2 4 6 8 Couple05 Couple06 0 2 4 6 8 Couple07 Couple08 Couple09 Couple10 Couple11 Couple12 Couple13 -0.5 0.0 0.5 1.0 Couple14 -0.5 0.0 0.5 1.0 Couple15 Couple16 Couple17 Couple18 Couple19 Couple20 Couple21 Couple22 Couple23 Couple24 Couple25 Couple26 Couple27 -0.5 0.0 0.5 1.0 Couple28 -0.5 0.0 0.5 1.0 Couple29 Couple30 Couple31 Couple32 Couple33 Couple34 Couple35 Couple36 0 2 4 6 8 Couple37 Couple38 0 2 4 6 8 Couple39 -0.5 0.0 0.5 1.0 Couple40 No consistent autocorrelation remaining in the data
  • 38. Week 11.2: Autocorrelation ! Autocorrelation ! Introduction ! Testing for Autocorrelation ! Visualizing Autocorrelation ! Direction & Lag ! Why Does Autocorrelation Matter? ! Lab
  • 39. Why Does Autocorrelation Matter? • Autocorrelation can be an interesting research question in its own right • Important for model assumptions • A simple growth-curve model: • Assumes that time matters only insofar as there’s a general increase/decrease with time • Otherwise, all observations from a couple equally similar or dissimilar … error terms independent = Warmth Yi(j) γ00 Overall baseline Time γ10x1(j) + U0j Random intercept for couple + Error term— independent, identically distributed Ei(j) +
  • 40. Why Does Autocorrelation Matter? • Autocorrelation can be an interesting research question in its own right • Important for model assumptions • Assumption all observations from a couple equally similar or dissimilar … error terms independent • Not true if there’s autocorrelation … observations similar in time dependent on one another • Underestimates standard error # inflates Type I error 1 2 3 4 5 L I N E A R T R E N D
  • 41. Week 11.2: Autocorrelation ! Autocorrelation ! Introduction ! Testing for Autocorrelation ! Visualizing Autocorrelation ! Direction & Lag ! Why Does Autocorrelation Matter? ! Lab