SlideShare a Scribd company logo
1 of 62
Download to read offline
Course Business
! Lab materials on Canvas
! Final project information will be posted on
Canvas at 4:00 PM today
• Final project: Analyze your own data
• I can supply simulated data if needed—send me an intro
& methods section for the data you’d like to analyze
• In-class presentation: Last 2.5 weeks of class,
beginning Nov. 9th
• Sign up on Canvas for a time slot – first come, first
served!
• Final paper: Due on Canvas last day of class
• Canvas will have more info. on requirements
Week 11.1: Growth Curve Analysis
! Overview
! Reshaping Data
! Growth Curve Analysis
! Time as a Predictor Variable
! Quadratic & Higher Degrees
! Random Slopes
! Time-Variant & -Invariant Variables
! Breakpoints
! Lab
Longitudinal Designs
Time
Longitudinal Designs
• There are many methods available for
analyzing longitudinal data
• Aidan Wright’s class on Applied Longitudinal Data
Analysis
• Mixed-effects models are one effective
solution
• Hierarchical models naturally account for
longitudinal data
• Include all of the other features we’ve looked at
(multiple random effects, mix of categorical &
continuous variables, non-normal DVs, etc.)
School
1
School
2
Student
2
Student
1
Student
3
Student
4
Sampled SCHOOLS
Sampled STUDENTS
LEVEL 2
LEVEL 1
• What kind of random-effects structure is this?
Longitudinal Data as Hierarchical Data
School
1
School
2
Student
2
Student
1
Student
3
Student
4
Sampled SCHOOLS
Sampled STUDENTS
LEVEL 2
LEVEL 1
• What kind of random-effects structure is this?
• Two levels of nesting – sample schools, then
sample students inside each school
Longitudinal Data as Hierarchical Data
Student
1
Exam 1
Student
2
Exam 2
Student
3
Exam 1
Student
3
Exam 2
• Now imagine we observed each student several
different times
• e.g., midterm & final exam
School
1
School
2
Student
2
Student
1
Student
3
Student
4
Sampled SCHOOLS
Sampled STUDENTS
LEVEL 2
LEVEL 1
Longitudinal Data as Hierarchical Data
Student
1
Exam 1
Student
2
Exam 2
Student
3
Exam 1
Student
3
Exam 2
School
1
School
2
Student
2
Student
1
Student
3
Student
4
Sampled SCHOOLS
Sampled STUDENTS
LEVEL 3
LEVEL 2
• This is just another level of nesting
• Sample schools
• Sample student within each school
• Sample time points within each student
Longitudinal Data as Hierarchical Data
Sampled
TIME POINTS
LEVEL 1
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?
" Today
2) How does an observation at one time point
relate to the next time point?
" Wednesday
vocab.csv
! Role of language input in early
vocab acquisition
! 200 kids from lower SES families:
! 100 families given books to read
to their kids
! 100 waitlisted controls
! Vocab assessed every 2 months
from 20 mos. to 28 mos.
! Research questions:
! What is the general trajectory of
vocabulary acquisition in these ages?
! How is this altered by our intervention?
Week 11.1: Growth Curve Analysis
! Overview
! Reshaping Data
! Growth Curve Analysis
! Time as a Predictor Variable
! Quadratic & Higher Degrees
! Random Slopes
! Time-Variant & -Invariant Variables
! Breakpoints
! Lab
Long vs. Wide Format
! For lmer(), each observation
needs its own row
! “long” format
Time 1 row
Time 2 gets a separate row
One trial
Another trial
Long vs. Wide Format
! For lmer(), each observation
needs its own row
! “long” format
! Sometimes data comes to
us in “wide” format
! Each repeated measure
is a different column
in the same row
! e.g., what
SPSS uses
! vocab.csv is
in this format
Time 1 and Time 2 are considered
separate variables
Time 1 row
Time 2 gets a separate row
Long vs. Wide Format
! Tidyverse contains very easy functions for
pivoting data between formats
! pivot_longer(): To turn data into long format
! pivot_wider(): To turn data into wide format
pivot_longer()
! Here is a look at our dataframe…
We want to turn into
each of these
columns into a
separate row
pivot_longer()
! vocab %>%
pivot_longer(cols=c('Month0','Month2','Month4’,
'Month6','Month8')) -> vocab.p
! Now we have five rows per child
We want to turn into
each of these
columns into a
separate row
pivot_longer()
! By default, R saves the original column name in a
variable called “name”, and the DV in a variable called
“value”
! Not very informative
! We can specify better names :
! vocab %>%
pivot_longer(cols=c('Month0','Month2','Month4’,
'Month6','Month8’), names_to='MonthsInStudy’,
values_to='VocabWords') -> vocab.p
pivot_longer()
! By default, R saves the original column name in a
variable called “name”, and the DV in a variable called
“value”
! Not very informative
! We can specify better names :
! vocab %>%
pivot_longer(cols=c('Month0','Month2','Month4’,
'Month6','Month8’), names_to='MonthsInStudy’,
values_to='VocabWords') -> vocab.p
pivot_longer()
! What we’d really like is to turn MonthsIntoStudy into a
numeric variable
! Currently, the values are “Month0,” “Month2,” etc., because
those were the original column names
! Since these all start with the same prefix (Month), tidyverse
can automatically strip that out for us
! vocab %>%
pivot_longer(cols=c('Month0','Month2','Month4','
Month6','Month8’), names_to='MonthsInStudy',
names_prefix='Month', values_to='VocabWords')->
vocab.p
pivot_longer()
! What we’d really like is to turn MonthsIntoStudy into a
numeric variable
! Currently, the values are “Month0,” “Month2,” etc., because
those were the original column names
! Since these all start with the same prefix (Month), tidyverse
can automatically strip that out for us
! vocab %>%
pivot_longer(cols=c('Month0','Month2','Month4','
Month6','Month8’), names_to='MonthsInStudy',
names_prefix='Month', values_to='VocabWords')->
vocab.p
pivot_longer()
! Now, we can use as.numeric() on this variable
! vocab.p %>%
mutate(MonthsInStudy=as.numeric(MonthsInStudy))
-> vocab.p
pivot_longer()
! Now, we can use as.numeric() on this variable
! vocab.p %>%
mutate(MonthsInStudy=as.numeric(MonthsInStudy))
-> vocab.p
Week 11.1: Growth Curve Analysis
! Overview
! Reshaping Data
! Growth Curve Analysis
! Time as a Predictor Variable
! Quadratic & Higher Degrees
! Random Slopes
! Time-Variant & -Invariant Variables
! Breakpoints
! Lab
vocab.csv
! Role of language input in early
vocab acquisition
! 200 kids from lower SES families:
! 100 families given books to read
to their kids
! 100 waitlisted controls
! Vocab assessed every 2 months
from 20 mos. to 28 mos.
! Research questions:
! What is the general trajectory of
vocabulary acquisition in these ages?
! How is this altered by our intervention?
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?
" Today: Growth curve analysis
2) How does an observation at one time point
relate to the next time point?
" Wednesday
Time as a Predictor Variable
• How does vocabulary change over time?
• The simple way to answer this question: Add
time as a variable in our model
• Nothing “special” about time as a predictor
Time as a Predictor Variable
• Let’s add the effect of time to our model
• Here: MonthsInStudy (starting at 0)
• Fixed effect because we’re interested in time effects
• model1 <- lmer(VocabWords ~ 1 + MonthsInStudy +
(1|Child), data=vocab)
• How would you interpret the two estimates?
• Intercept:
• Slope:
Time as a Predictor Variable
• Let’s add the effect of time to our model
• Here: MonthsInStudy (starting at 0)
• Fixed effect because we’re interested in time effects
• model1 <- lmer(VocabWords ~ 1 + MonthsInStudy +
(1|Child), data=vocab)
• How would you interpret the two estimates?
• Intercept: Average vocab ~51 words at start of study
• Slope: Gain of about ~35 words per month
Time as a Predictor Variable
• Not necessary to have every time point
represented
• Don’t even have to be
the same set of time
points across
participants
• Time units also don’t matter as long as they’re
consistent
• Could be hours, days, years …
Week 11.1: Growth Curve Analysis
! Overview
! Reshaping Data
! Growth Curve Analysis
! Time as a Predictor Variable
! Quadratic & Higher Degrees
! Random Slopes
! Time-Variant & -Invariant Variables
! Breakpoints
! Lab
Quadratic & Higher Degrees
Quadratic & Higher Degrees
• We’ve been assuming a linear effect of time
Quadratic & Higher Degrees
• But, it looks like vocab growth may accelerate
• Growth between 0 mo. and 2 mo. is much smaller
than growth between 6 mo. and 8 mo.
• Suggests a curve / quadratic equation
Quadratic & Higher Degrees
• Add quadratic effect (MonthsInStudy2):
• model.poly <- lmer(VocabWords ~ 1 +
poly(MonthsInStudy,degree=2,raw=TRUE) +
(1|Child), data=vocab.p)
• degree=2 because we want MonthsInStudy2
• poly() automatically adds lower-order terms as
well
• i.e., the linear term (MonthsInStudy1)
• raw=TRUE to keep the original scale of the
variables (time measured in months)
Quadratic & Higher Degrees
• Results:
• Implied equation (approximate):
• VocabWords = 75 + 11*Months + 3*Months2
• What are predicted values if…
• Month=0?
• Month=1?
• Month=2?
Intercept
Linear term
Quadratic term
Quadratic & Higher Degrees
• Results:
• Implied equation (approximate):
• VocabWords = 75 + 11*Months + 3*Months2
• What are predicted values if…
• Month=0?
• Month=1?
• Month=2?
• Vocab growth is accelerating (larger change from
month 1 to month 2 than from month 0 to month 1)
Intercept
Linear term
Quadratic term
VocabWords=75+(11*0)+(3*02) = 75
VocabWords=75+(11*1)+(3*12) = 89
VocabWords=75+(11*2)+(3*22) = 109 +20
+14
POSITIVE
QUADRATIC TREND
& NO LINEAR
TREND
NEGATIVE
QUADRATIC TREND
& NO LINEAR
TREND
POSITIVE
QUADRATIC TREND
& POSITIVE LINEAR
TREND
NEGATIVE
QUADRATIC TREND
& POSITIVE LINEAR
TREND
Different patterns of quadratic & linear effects in
a GCA describe different curves
POSITIVE
QUADRATIC TREND
& NO LINEAR
TREND
NEGATIVE
QUADRATIC TREND
& NO LINEAR
TREND
POSITIVE
QUADRATIC TREND
& POSITIVE LINEAR
TREND
NEGATIVE
QUADRATIC TREND
& POSITIVE LINEAR
TREND
• Linear trend: Is there an overall increase over time (+),
decrease (-), or no change?
• Quadratic trend: Is the line curved up (+), down (-), or straight?
Quadratic & Higher Degrees
• The Yerkes-Dodson law (Yerkes & Dodson, 1908)
describes the optimal level of physiological arousal to
perform a task: Low arousal results in poor
performance because you are not alert enough,
medium arousal results in strong performance, and
high arousal results in poor performance because
you are too anxious.
Linear trend:
Quadratic trend:
Quadratic & Higher Degrees
• The Yerkes-Dodson law (Yerkes & Dodson, 1908)
describes the optimal level of physiological arousal to
perform a task: Low arousal results in poor
performance because you are not alert enough,
medium arousal results in strong performance, and
high arousal results in poor performance because
you are too anxious.
Linear trend:
Quadratic trend:
NONE
NEGATIVE
Quadratic & Higher Degrees
• In adulthood, working memory declines the
older you get (Park et al., 2002).
Linear trend:
Quadratic trend:
Quadratic & Higher Degrees
• In adulthood, working memory declines the
older you get (Park et al., 2002).
Linear trend:
Quadratic trend: NONE
NEGATIVE
Quadratic & Higher Degrees
• Aphasia is a neuropsychological disorder that
disrupts speech, often resulting from a stroke. After
initially acquiring aphasia, patients often experience
rapid recovery in much of their language
performance (dependent variable) as time
(independent variable) increases. But, this recovery
eventually slows down, and language performance
doesn’t get much better no matter how much more
time increases (e.g., Demeurisse et al., 1980).
Linear trend:
Quadratic trend:
Quadratic & Higher Degrees
• Aphasia is a neuropsychological disorder that
disrupts speech, often resulting from a stroke. After
initially acquiring aphasia, patients often experience
rapid recovery in much of their language
performance (dependent variable) as time
(independent variable) increases. But, this recovery
eventually slows down, and language performance
doesn’t get much better no matter how much more
time increases (e.g., Demeurisse et al., 1980).
Linear trend:
Quadratic trend:
POSITIVE
NEGATIVE
Quadratic & Higher Degrees
• Studies of practice and expertise (e.g., Logan, 1988)
show that people learning to do a task—such as
arithmetic—initially show a quick decrease in
response time (dependent variable) as the amount of
practice increases. However, eventually they hit the
point where the task can’t possibly be done any
faster, and response time reaches an asymptote and
stops decreasing.
Linear trend:
Quadratic trend:
Quadratic & Higher Degrees
• Studies of practice and expertise (e.g., Logan, 1988)
show that people learning to do a task—such as
arithmetic—initially show a quick decrease in
response time (dependent variable) as the amount of
practice increases. However, eventually they hit the
point where the task can’t possibly be done any
faster, and response time reaches an asymptote and
stops decreasing.
Linear trend:
Quadratic trend:
NEGATIVE
POSITIVE
Quadratic & Higher Degrees
• Could go up to even higher degrees (Time3,
Time4…)
• degree=3 if highest exponent is 3
• Degree minus 1 = Number of bends in the
curve
-100 -50 0 50 100
x^3
0 20 40 60 80 100
x^1
0 20 40 60 80 100
x^2
0 bends
1 bend
2 bends
Quadratic & Higher Degrees
• Maximum degree of polynomial: # of
time points minus 1
• Example: 2 time points perfectly fit by
a line (degree 1). Nothing left for
a quadratic term to explain.
• But, don’t want to overfit
• Probably not the case that the real underlying
(population) trajectory has 6 bends in it
• What degree should we include?
• Theoretical considerations
• If comparing conditions, look at mean
trajectory across conditions (Mirman et al., 2008)
Week 11.1: Growth Curve Analysis
! Overview
! Reshaping Data
! Growth Curve Analysis
! Time as a Predictor Variable
! Quadratic & Higher Degrees
! Random Slopes
! Time-Variant & -Invariant Variables
! Breakpoints
! Lab
Child
2
Child
1
Child
3
Child
4
Child 1
Assess-
ment 1
Child 2
Assess-
ment 2
Child 3
Assess-
ment 1
Child 3
Assess-
ment 2
Sampled CHILDREN
Sampled TIME
POINTS
LEVEL 2
LEVEL 1
• So far, we assume the same growth rate for all kids
• Almost certainly not true!
• At level 2, we’re sampling kids both with different
starting points (intercepts) and growth rates
(slopes)
Longitudinal Data: Random Slopes
Growth
Rate 1 Growth
Rate 2
Longitudinal Data: Random Slopes
RANDOM INTERCEPTS MODEL
Kids vary in starting point, but all
acquire vocabulary at the same rate
over this period
WITH RANDOM SLOPES
Allows rate of vocab acquisition to vary
across kids (as well as intercept)
• Let’s allow the MonthsInStudy effect to be different for
each Child
• model.Slope <- lmer(VocabWords ~ 1 +
poly(MonthsInStudy,degree=2,raw=TRUE) +
(1 + poly(MonthsInStudy,degree=2,raw=TRUE)|Child),
data=vocab.p)
Longitudinal Data: Random Slopes
Child
2
Child
1
Child
3
Child
4
Child 1
Assess-
ment 1
Child 2
Assess-
ment 2
Child 3
Assess-
ment 1
Child 3
Assess-
ment 2
Sampled CHILDREN
Sampled TIME
POINTS
LEVEL 2
LEVEL 1
Growth
Rate 1 Growth
Rate 2
Longitudinal Data: Random Slopes
Substantial variability in the MonthsInStudy slope
SD of the slope across children is ~5 words
Mean slope is 11 words/mo, but some kids might have a slope
of 6 or 16
Week 11.1: Growth Curve Analysis
! Overview
! Reshaping Data
! Growth Curve Analysis
! Time as a Predictor Variable
! Quadratic & Higher Degrees
! Random Slopes
! Time-Variant & -Invariant Variables
! Breakpoints
! Lab
Time-Variant & -Invariant Variables
• We may want to include other
(experimental or observational)
variables in a GCA model:
• e.g., our reading intervention
• MonthsInStudy + Reading
• Effect of Reading invariant across time
• Can only affect the intercept
(parallel lines)
• MonthsInStudy * Reading
• Effect of Reading varies with time
• Can affect intercept & slope
Time-Variant & -Invariant Variables
• Fixed-effect results with the interaction:
e.g., Huttenlocher et al., 1991
Also results in faster vocab growth (amplifies + Time effect)
Linear growth rate for “No” group:
8.4 words / month
Linear growth rate for “Yes” group:
8.4 + 4.7 = 13.1 words / month
Effect of reading at time 0 (intercept): ~6 words
No effect on curvature (quadratic term)
Time-Variant & -Invariant Variables
• Can be either:
• Time-Invariant Predictor:
Same across all time points
within a subject
• e.g., our intervention, race/ethnicity
• Level 2 variables
• Time-Varying Predictor: Varies
even within a subject, from one
time point to another
• e.g., hours of sleep, mood
• Level-1 variable
Child
2
Child
1
Child 1
Assess-
ment 1
Child 2
Assess-
ment 2
Sampled CHILDREN
Sampled TIME
POINTS
LEVEL 2
LEVEL 1
• Since R automatically figures out what’s a level-1
vs. level-2 variable, we don’t have to do anything
special for either kind of variable
Week 11.1: Growth Curve Analysis
! Overview
! Reshaping Data
! Growth Curve Analysis
! Time as a Predictor Variable
! Quadratic & Higher Degrees
! Random Slopes
! Time-Variant & -Invariant Variables
! Breakpoints
! Lab
! Another possibility (in general) is a qualitative
change in the trajectory at some point in the
range of time observed
! e.g., age of majority, public policy changes, etc.
! Include a breakpoint—a categorical variable
that represents whether or not you’re above
the point at which the change happens
! mydata %>%
mutate(Year2015OrLater=
ifelse(Year >= 2015, 1, 0))-> mydata
! New variable is:
! 0 before 2015
! 1 for 2015 onwards
Breakpoints
! Another possibility (in general) is a qualitative
change in the trajectory at some point in the
range of time observed
! e.g., age of majority, public policy changes, etc.
! Include a breakpoint—a categorical variable
that represents whether or not you’re above
the point at which the change happens
Breakpoints
Main effect of breakpoint only – single shift
downward (or upward) but same slope
Main effect of breakpoint & an
interaction – slope also changes
! Can apply this technique to any continuous
variables, not just time
! e.g., above/below the poverty line
! As with higher-order polynomials, be wary of
overfitting the data
! Most effective if we have an a priori reason to
expect a breakpoint somewhere
! Or, use cross-validation to support a more
exploratory analysis
Breakpoints
Week 11.1: Growth Curve Analysis
! Overview
! Reshaping Data
! Growth Curve Analysis
! Time as a Predictor Variable
! Quadratic & Higher Degrees
! Random Slopes
! Time-Variant & -Invariant Variables
! Breakpoints
! Lab

More Related Content

What's hot

Mixed Effects Models - Descriptive Statistics
Mixed Effects Models - Descriptive StatisticsMixed Effects Models - Descriptive Statistics
Mixed Effects Models - Descriptive StatisticsScott Fraundorf
 
Mixed Effects Models - Random Intercepts
Mixed Effects Models - Random InterceptsMixed Effects Models - Random Intercepts
Mixed Effects Models - Random InterceptsScott Fraundorf
 
Mixed Effects Models - Centering and Transformations
Mixed Effects Models - Centering and TransformationsMixed Effects Models - Centering and Transformations
Mixed Effects Models - Centering and TransformationsScott Fraundorf
 
Mixed Effects Models - Random Slopes
Mixed Effects Models - Random SlopesMixed Effects Models - Random Slopes
Mixed Effects Models - Random SlopesScott Fraundorf
 
Mixed Effects Models - Post-Hoc Comparisons
Mixed Effects Models - Post-Hoc ComparisonsMixed Effects Models - Post-Hoc Comparisons
Mixed Effects Models - Post-Hoc ComparisonsScott Fraundorf
 
Mixed Effects Models - Orthogonal Contrasts
Mixed Effects Models - Orthogonal ContrastsMixed Effects Models - Orthogonal Contrasts
Mixed Effects Models - Orthogonal ContrastsScott Fraundorf
 
Mixed Effects Models - Signal Detection Theory
Mixed Effects Models - Signal Detection TheoryMixed Effects Models - Signal Detection Theory
Mixed Effects Models - Signal Detection TheoryScott Fraundorf
 
Logistic regression (blyth 2006) (simplified)
Logistic regression (blyth 2006) (simplified)Logistic regression (blyth 2006) (simplified)
Logistic regression (blyth 2006) (simplified)MikeBlyth
 
Logistic regression
Logistic regressionLogistic regression
Logistic regressionVARUN KUMAR
 
Mixed Effects Models - Empirical Logit
Mixed Effects Models - Empirical LogitMixed Effects Models - Empirical Logit
Mixed Effects Models - Empirical LogitScott Fraundorf
 
Binary OR Binomial logistic regression
Binary OR Binomial logistic regression Binary OR Binomial logistic regression
Binary OR Binomial logistic regression Dr Athar Khan
 
Mixed Effects Models - Crossed Random Effects
Mixed Effects Models - Crossed Random EffectsMixed Effects Models - Crossed Random Effects
Mixed Effects Models - Crossed Random EffectsScott Fraundorf
 
t-TEst. :D
t-TEst. :Dt-TEst. :D
t-TEst. :Dpatatas
 
Logistic Regression.ppt
Logistic Regression.pptLogistic Regression.ppt
Logistic Regression.ppthabtamu biazin
 
Multivariate analysis - Multiple regression analysis
Multivariate analysis -  Multiple regression analysisMultivariate analysis -  Multiple regression analysis
Multivariate analysis - Multiple regression analysisRaihanathusSahdhiyya
 
Multiple regression presentation
Multiple regression presentationMultiple regression presentation
Multiple regression presentationCarlo Magno
 
Kaplan meier survival curves and the log-rank test
Kaplan meier survival curves and the log-rank testKaplan meier survival curves and the log-rank test
Kaplan meier survival curves and the log-rank testzhe1
 

What's hot (20)

Mixed Effects Models - Descriptive Statistics
Mixed Effects Models - Descriptive StatisticsMixed Effects Models - Descriptive Statistics
Mixed Effects Models - Descriptive Statistics
 
Mixed Effects Models - Random Intercepts
Mixed Effects Models - Random InterceptsMixed Effects Models - Random Intercepts
Mixed Effects Models - Random Intercepts
 
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 - Random Slopes
Mixed Effects Models - Random SlopesMixed Effects Models - Random Slopes
Mixed Effects Models - Random Slopes
 
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 - Orthogonal Contrasts
Mixed Effects Models - Orthogonal ContrastsMixed Effects Models - Orthogonal Contrasts
Mixed Effects Models - Orthogonal Contrasts
 
Mixed Effects Models - Signal Detection Theory
Mixed Effects Models - Signal Detection TheoryMixed Effects Models - Signal Detection Theory
Mixed Effects Models - Signal Detection Theory
 
Logistic regression (blyth 2006) (simplified)
Logistic regression (blyth 2006) (simplified)Logistic regression (blyth 2006) (simplified)
Logistic regression (blyth 2006) (simplified)
 
Logistic regression
Logistic regressionLogistic regression
Logistic regression
 
Mixed Effects Models - Empirical Logit
Mixed Effects Models - Empirical LogitMixed Effects Models - Empirical Logit
Mixed Effects Models - Empirical Logit
 
Linear regression analysis
Linear regression analysisLinear regression analysis
Linear regression analysis
 
Binary OR Binomial logistic regression
Binary OR Binomial logistic regression Binary OR Binomial logistic regression
Binary OR Binomial logistic regression
 
Mixed Effects Models - Crossed Random Effects
Mixed Effects Models - Crossed Random EffectsMixed Effects Models - Crossed Random Effects
Mixed Effects Models - Crossed Random Effects
 
t-TEst. :D
t-TEst. :Dt-TEst. :D
t-TEst. :D
 
Logistic Regression.ppt
Logistic Regression.pptLogistic Regression.ppt
Logistic Regression.ppt
 
Difference-in-Difference Methods
Difference-in-Difference MethodsDifference-in-Difference Methods
Difference-in-Difference Methods
 
Multivariate analysis - Multiple regression analysis
Multivariate analysis -  Multiple regression analysisMultivariate analysis -  Multiple regression analysis
Multivariate analysis - Multiple regression analysis
 
Multiple regression presentation
Multiple regression presentationMultiple regression presentation
Multiple regression presentation
 
Simple Linear Regression
Simple Linear RegressionSimple Linear Regression
Simple Linear Regression
 
Kaplan meier survival curves and the log-rank test
Kaplan meier survival curves and the log-rank testKaplan meier survival curves and the log-rank test
Kaplan meier survival curves and the log-rank test
 

Similar to Mixed Effects Models - Growth Curve Analysis

Trends over time
Trends over timeTrends over time
Trends over timedjleach
 
Unit 01 intro to statistics - 1 per page
Unit 01    intro to statistics - 1 per pageUnit 01    intro to statistics - 1 per page
Unit 01 intro to statistics - 1 per pageMAKABANSA
 
Reflection on LearningWrite a brief 1–2 paragraph weekly r
Reflection on LearningWrite a brief 1–2 paragraph weekly rReflection on LearningWrite a brief 1–2 paragraph weekly r
Reflection on LearningWrite a brief 1–2 paragraph weekly rfelipaser7p
 
Addictive links, Keynote talk at WWW 2014 workshop
Addictive links, Keynote talk at WWW 2014 workshopAddictive links, Keynote talk at WWW 2014 workshop
Addictive links, Keynote talk at WWW 2014 workshopPeter Brusilovsky
 
Audio Lesson Plan 1
Audio Lesson Plan 1Audio Lesson Plan 1
Audio Lesson Plan 1cprue22
 
Deming and Education
Deming and EducationDeming and Education
Deming and Educationaghersi
 
Que Sera Sera sdec15
Que Sera Sera sdec15Que Sera Sera sdec15
Que Sera Sera sdec15Andrew Annett
 
Sequencingr middleschool
Sequencingr middleschoolSequencingr middleschool
Sequencingr middleschoolKelly Kellogg
 
New York Survey DataInstructionsA consulting firm was hired to.docx
New York Survey DataInstructionsA consulting firm was hired to.docxNew York Survey DataInstructionsA consulting firm was hired to.docx
New York Survey DataInstructionsA consulting firm was hired to.docxcurwenmichaela
 
CR Bio elc mtg 11/18
CR Bio elc mtg 11/18CR Bio elc mtg 11/18
CR Bio elc mtg 11/18jsilver
 
Sequencingr highschool
Sequencingr highschoolSequencingr highschool
Sequencingr highschoolKelly Kellogg
 
The Realization ConceptAuthor(s) 1964 Concepts and Sta.docx
The Realization ConceptAuthor(s) 1964 Concepts and Sta.docxThe Realization ConceptAuthor(s) 1964 Concepts and Sta.docx
The Realization ConceptAuthor(s) 1964 Concepts and Sta.docxdurantheseldine
 
Simmons curriculum design.ppt
Simmons curriculum design.pptSimmons curriculum design.ppt
Simmons curriculum design.pptMinBulay
 
Transitioning to Common Core: What it means, What to look for
Transitioning to Common Core: What it means, What to look forTransitioning to Common Core: What it means, What to look for
Transitioning to Common Core: What it means, What to look forCurriculum Associates
 
Fostering Curriculum Development Through Artesol 2010
Fostering Curriculum Development Through Artesol 2010Fostering Curriculum Development Through Artesol 2010
Fostering Curriculum Development Through Artesol 2010shierl
 

Similar to Mixed Effects Models - Growth Curve Analysis (20)

Basic Terms in Statistics
Basic Terms in StatisticsBasic Terms in Statistics
Basic Terms in Statistics
 
Trends over time
Trends over timeTrends over time
Trends over time
 
Unit 01 intro to statistics - 1 per page
Unit 01    intro to statistics - 1 per pageUnit 01    intro to statistics - 1 per page
Unit 01 intro to statistics - 1 per page
 
Reflection on LearningWrite a brief 1–2 paragraph weekly r
Reflection on LearningWrite a brief 1–2 paragraph weekly rReflection on LearningWrite a brief 1–2 paragraph weekly r
Reflection on LearningWrite a brief 1–2 paragraph weekly r
 
Addictive links, Keynote talk at WWW 2014 workshop
Addictive links, Keynote talk at WWW 2014 workshopAddictive links, Keynote talk at WWW 2014 workshop
Addictive links, Keynote talk at WWW 2014 workshop
 
Spss
SpssSpss
Spss
 
Audio Lesson Plan 1
Audio Lesson Plan 1Audio Lesson Plan 1
Audio Lesson Plan 1
 
Bc week 9
Bc week 9Bc week 9
Bc week 9
 
Deming and Education
Deming and EducationDeming and Education
Deming and Education
 
Que Sera Sera sdec15
Que Sera Sera sdec15Que Sera Sera sdec15
Que Sera Sera sdec15
 
Sequencingr middleschool
Sequencingr middleschoolSequencingr middleschool
Sequencingr middleschool
 
New York Survey DataInstructionsA consulting firm was hired to.docx
New York Survey DataInstructionsA consulting firm was hired to.docxNew York Survey DataInstructionsA consulting firm was hired to.docx
New York Survey DataInstructionsA consulting firm was hired to.docx
 
CR Bio elc mtg 11/18
CR Bio elc mtg 11/18CR Bio elc mtg 11/18
CR Bio elc mtg 11/18
 
Sequencingr highschool
Sequencingr highschoolSequencingr highschool
Sequencingr highschool
 
The Realization ConceptAuthor(s) 1964 Concepts and Sta.docx
The Realization ConceptAuthor(s) 1964 Concepts and Sta.docxThe Realization ConceptAuthor(s) 1964 Concepts and Sta.docx
The Realization ConceptAuthor(s) 1964 Concepts and Sta.docx
 
New teacher session
New teacher sessionNew teacher session
New teacher session
 
Simmons curriculum design.ppt
Simmons curriculum design.pptSimmons curriculum design.ppt
Simmons curriculum design.ppt
 
Transitioning to Common Core: What it means, What to look for
Transitioning to Common Core: What it means, What to look forTransitioning to Common Core: What it means, What to look for
Transitioning to Common Core: What it means, What to look for
 
Fostering Curriculum Development Through Artesol 2010
Fostering Curriculum Development Through Artesol 2010Fostering Curriculum Development Through Artesol 2010
Fostering Curriculum Development Through Artesol 2010
 
Linking the Learning
Linking the LearningLinking the Learning
Linking the Learning
 

Recently uploaded

A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsTechSoup
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfagholdier
 
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.pdfJayanti Pande
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhikauryashika82
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationnomboosow
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfAyushMahapatra5
 
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...christianmathematics
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfchloefrazer622
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3JemimahLaneBuaron
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpinRaunakKeshri1
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 

Recently uploaded (20)

A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).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
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdf
 
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...
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdf
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpin
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 

Mixed Effects Models - Growth Curve Analysis

  • 1. Course Business ! Lab materials on Canvas ! Final project information will be posted on Canvas at 4:00 PM today • Final project: Analyze your own data • I can supply simulated data if needed—send me an intro & methods section for the data you’d like to analyze • In-class presentation: Last 2.5 weeks of class, beginning Nov. 9th • Sign up on Canvas for a time slot – first come, first served! • Final paper: Due on Canvas last day of class • Canvas will have more info. on requirements
  • 2. Week 11.1: Growth Curve Analysis ! Overview ! Reshaping Data ! Growth Curve Analysis ! Time as a Predictor Variable ! Quadratic & Higher Degrees ! Random Slopes ! Time-Variant & -Invariant Variables ! Breakpoints ! Lab
  • 4. Longitudinal Designs • There are many methods available for analyzing longitudinal data • Aidan Wright’s class on Applied Longitudinal Data Analysis • Mixed-effects models are one effective solution • Hierarchical models naturally account for longitudinal data • Include all of the other features we’ve looked at (multiple random effects, mix of categorical & continuous variables, non-normal DVs, etc.)
  • 5. School 1 School 2 Student 2 Student 1 Student 3 Student 4 Sampled SCHOOLS Sampled STUDENTS LEVEL 2 LEVEL 1 • What kind of random-effects structure is this? Longitudinal Data as Hierarchical Data
  • 6. School 1 School 2 Student 2 Student 1 Student 3 Student 4 Sampled SCHOOLS Sampled STUDENTS LEVEL 2 LEVEL 1 • What kind of random-effects structure is this? • Two levels of nesting – sample schools, then sample students inside each school Longitudinal Data as Hierarchical Data
  • 7. Student 1 Exam 1 Student 2 Exam 2 Student 3 Exam 1 Student 3 Exam 2 • Now imagine we observed each student several different times • e.g., midterm & final exam School 1 School 2 Student 2 Student 1 Student 3 Student 4 Sampled SCHOOLS Sampled STUDENTS LEVEL 2 LEVEL 1 Longitudinal Data as Hierarchical Data
  • 8. Student 1 Exam 1 Student 2 Exam 2 Student 3 Exam 1 Student 3 Exam 2 School 1 School 2 Student 2 Student 1 Student 3 Student 4 Sampled SCHOOLS Sampled STUDENTS LEVEL 3 LEVEL 2 • This is just another level of nesting • Sample schools • Sample student within each school • Sample time points within each student Longitudinal Data as Hierarchical Data Sampled TIME POINTS LEVEL 1
  • 9. 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? " Today 2) How does an observation at one time point relate to the next time point? " Wednesday
  • 10. vocab.csv ! Role of language input in early vocab acquisition ! 200 kids from lower SES families: ! 100 families given books to read to their kids ! 100 waitlisted controls ! Vocab assessed every 2 months from 20 mos. to 28 mos. ! Research questions: ! What is the general trajectory of vocabulary acquisition in these ages? ! How is this altered by our intervention?
  • 11. Week 11.1: Growth Curve Analysis ! Overview ! Reshaping Data ! Growth Curve Analysis ! Time as a Predictor Variable ! Quadratic & Higher Degrees ! Random Slopes ! Time-Variant & -Invariant Variables ! Breakpoints ! Lab
  • 12. Long vs. Wide Format ! For lmer(), each observation needs its own row ! “long” format Time 1 row Time 2 gets a separate row One trial Another trial
  • 13. Long vs. Wide Format ! For lmer(), each observation needs its own row ! “long” format ! Sometimes data comes to us in “wide” format ! Each repeated measure is a different column in the same row ! e.g., what SPSS uses ! vocab.csv is in this format Time 1 and Time 2 are considered separate variables Time 1 row Time 2 gets a separate row
  • 14. Long vs. Wide Format ! Tidyverse contains very easy functions for pivoting data between formats ! pivot_longer(): To turn data into long format ! pivot_wider(): To turn data into wide format
  • 15. pivot_longer() ! Here is a look at our dataframe… We want to turn into each of these columns into a separate row
  • 16. pivot_longer() ! vocab %>% pivot_longer(cols=c('Month0','Month2','Month4’, 'Month6','Month8')) -> vocab.p ! Now we have five rows per child We want to turn into each of these columns into a separate row
  • 17. pivot_longer() ! By default, R saves the original column name in a variable called “name”, and the DV in a variable called “value” ! Not very informative ! We can specify better names : ! vocab %>% pivot_longer(cols=c('Month0','Month2','Month4’, 'Month6','Month8’), names_to='MonthsInStudy’, values_to='VocabWords') -> vocab.p
  • 18. pivot_longer() ! By default, R saves the original column name in a variable called “name”, and the DV in a variable called “value” ! Not very informative ! We can specify better names : ! vocab %>% pivot_longer(cols=c('Month0','Month2','Month4’, 'Month6','Month8’), names_to='MonthsInStudy’, values_to='VocabWords') -> vocab.p
  • 19. pivot_longer() ! What we’d really like is to turn MonthsIntoStudy into a numeric variable ! Currently, the values are “Month0,” “Month2,” etc., because those were the original column names ! Since these all start with the same prefix (Month), tidyverse can automatically strip that out for us ! vocab %>% pivot_longer(cols=c('Month0','Month2','Month4',' Month6','Month8’), names_to='MonthsInStudy', names_prefix='Month', values_to='VocabWords')-> vocab.p
  • 20. pivot_longer() ! What we’d really like is to turn MonthsIntoStudy into a numeric variable ! Currently, the values are “Month0,” “Month2,” etc., because those were the original column names ! Since these all start with the same prefix (Month), tidyverse can automatically strip that out for us ! vocab %>% pivot_longer(cols=c('Month0','Month2','Month4',' Month6','Month8’), names_to='MonthsInStudy', names_prefix='Month', values_to='VocabWords')-> vocab.p
  • 21. pivot_longer() ! Now, we can use as.numeric() on this variable ! vocab.p %>% mutate(MonthsInStudy=as.numeric(MonthsInStudy)) -> vocab.p
  • 22. pivot_longer() ! Now, we can use as.numeric() on this variable ! vocab.p %>% mutate(MonthsInStudy=as.numeric(MonthsInStudy)) -> vocab.p
  • 23. Week 11.1: Growth Curve Analysis ! Overview ! Reshaping Data ! Growth Curve Analysis ! Time as a Predictor Variable ! Quadratic & Higher Degrees ! Random Slopes ! Time-Variant & -Invariant Variables ! Breakpoints ! Lab
  • 24. vocab.csv ! Role of language input in early vocab acquisition ! 200 kids from lower SES families: ! 100 families given books to read to their kids ! 100 waitlisted controls ! Vocab assessed every 2 months from 20 mos. to 28 mos. ! Research questions: ! What is the general trajectory of vocabulary acquisition in these ages? ! How is this altered by our intervention?
  • 25. 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? " Today: Growth curve analysis 2) How does an observation at one time point relate to the next time point? " Wednesday
  • 26. Time as a Predictor Variable • How does vocabulary change over time? • The simple way to answer this question: Add time as a variable in our model • Nothing “special” about time as a predictor
  • 27. Time as a Predictor Variable • Let’s add the effect of time to our model • Here: MonthsInStudy (starting at 0) • Fixed effect because we’re interested in time effects • model1 <- lmer(VocabWords ~ 1 + MonthsInStudy + (1|Child), data=vocab) • How would you interpret the two estimates? • Intercept: • Slope:
  • 28. Time as a Predictor Variable • Let’s add the effect of time to our model • Here: MonthsInStudy (starting at 0) • Fixed effect because we’re interested in time effects • model1 <- lmer(VocabWords ~ 1 + MonthsInStudy + (1|Child), data=vocab) • How would you interpret the two estimates? • Intercept: Average vocab ~51 words at start of study • Slope: Gain of about ~35 words per month
  • 29. Time as a Predictor Variable • Not necessary to have every time point represented • Don’t even have to be the same set of time points across participants • Time units also don’t matter as long as they’re consistent • Could be hours, days, years …
  • 30. Week 11.1: Growth Curve Analysis ! Overview ! Reshaping Data ! Growth Curve Analysis ! Time as a Predictor Variable ! Quadratic & Higher Degrees ! Random Slopes ! Time-Variant & -Invariant Variables ! Breakpoints ! Lab
  • 32. Quadratic & Higher Degrees • We’ve been assuming a linear effect of time
  • 33. Quadratic & Higher Degrees • But, it looks like vocab growth may accelerate • Growth between 0 mo. and 2 mo. is much smaller than growth between 6 mo. and 8 mo. • Suggests a curve / quadratic equation
  • 34. Quadratic & Higher Degrees • Add quadratic effect (MonthsInStudy2): • model.poly <- lmer(VocabWords ~ 1 + poly(MonthsInStudy,degree=2,raw=TRUE) + (1|Child), data=vocab.p) • degree=2 because we want MonthsInStudy2 • poly() automatically adds lower-order terms as well • i.e., the linear term (MonthsInStudy1) • raw=TRUE to keep the original scale of the variables (time measured in months)
  • 35. Quadratic & Higher Degrees • Results: • Implied equation (approximate): • VocabWords = 75 + 11*Months + 3*Months2 • What are predicted values if… • Month=0? • Month=1? • Month=2? Intercept Linear term Quadratic term
  • 36. Quadratic & Higher Degrees • Results: • Implied equation (approximate): • VocabWords = 75 + 11*Months + 3*Months2 • What are predicted values if… • Month=0? • Month=1? • Month=2? • Vocab growth is accelerating (larger change from month 1 to month 2 than from month 0 to month 1) Intercept Linear term Quadratic term VocabWords=75+(11*0)+(3*02) = 75 VocabWords=75+(11*1)+(3*12) = 89 VocabWords=75+(11*2)+(3*22) = 109 +20 +14
  • 37. POSITIVE QUADRATIC TREND & NO LINEAR TREND NEGATIVE QUADRATIC TREND & NO LINEAR TREND POSITIVE QUADRATIC TREND & POSITIVE LINEAR TREND NEGATIVE QUADRATIC TREND & POSITIVE LINEAR TREND Different patterns of quadratic & linear effects in a GCA describe different curves
  • 38. POSITIVE QUADRATIC TREND & NO LINEAR TREND NEGATIVE QUADRATIC TREND & NO LINEAR TREND POSITIVE QUADRATIC TREND & POSITIVE LINEAR TREND NEGATIVE QUADRATIC TREND & POSITIVE LINEAR TREND • Linear trend: Is there an overall increase over time (+), decrease (-), or no change? • Quadratic trend: Is the line curved up (+), down (-), or straight?
  • 39. Quadratic & Higher Degrees • The Yerkes-Dodson law (Yerkes & Dodson, 1908) describes the optimal level of physiological arousal to perform a task: Low arousal results in poor performance because you are not alert enough, medium arousal results in strong performance, and high arousal results in poor performance because you are too anxious. Linear trend: Quadratic trend:
  • 40. Quadratic & Higher Degrees • The Yerkes-Dodson law (Yerkes & Dodson, 1908) describes the optimal level of physiological arousal to perform a task: Low arousal results in poor performance because you are not alert enough, medium arousal results in strong performance, and high arousal results in poor performance because you are too anxious. Linear trend: Quadratic trend: NONE NEGATIVE
  • 41. Quadratic & Higher Degrees • In adulthood, working memory declines the older you get (Park et al., 2002). Linear trend: Quadratic trend:
  • 42. Quadratic & Higher Degrees • In adulthood, working memory declines the older you get (Park et al., 2002). Linear trend: Quadratic trend: NONE NEGATIVE
  • 43. Quadratic & Higher Degrees • Aphasia is a neuropsychological disorder that disrupts speech, often resulting from a stroke. After initially acquiring aphasia, patients often experience rapid recovery in much of their language performance (dependent variable) as time (independent variable) increases. But, this recovery eventually slows down, and language performance doesn’t get much better no matter how much more time increases (e.g., Demeurisse et al., 1980). Linear trend: Quadratic trend:
  • 44. Quadratic & Higher Degrees • Aphasia is a neuropsychological disorder that disrupts speech, often resulting from a stroke. After initially acquiring aphasia, patients often experience rapid recovery in much of their language performance (dependent variable) as time (independent variable) increases. But, this recovery eventually slows down, and language performance doesn’t get much better no matter how much more time increases (e.g., Demeurisse et al., 1980). Linear trend: Quadratic trend: POSITIVE NEGATIVE
  • 45. Quadratic & Higher Degrees • Studies of practice and expertise (e.g., Logan, 1988) show that people learning to do a task—such as arithmetic—initially show a quick decrease in response time (dependent variable) as the amount of practice increases. However, eventually they hit the point where the task can’t possibly be done any faster, and response time reaches an asymptote and stops decreasing. Linear trend: Quadratic trend:
  • 46. Quadratic & Higher Degrees • Studies of practice and expertise (e.g., Logan, 1988) show that people learning to do a task—such as arithmetic—initially show a quick decrease in response time (dependent variable) as the amount of practice increases. However, eventually they hit the point where the task can’t possibly be done any faster, and response time reaches an asymptote and stops decreasing. Linear trend: Quadratic trend: NEGATIVE POSITIVE
  • 47. Quadratic & Higher Degrees • Could go up to even higher degrees (Time3, Time4…) • degree=3 if highest exponent is 3 • Degree minus 1 = Number of bends in the curve -100 -50 0 50 100 x^3 0 20 40 60 80 100 x^1 0 20 40 60 80 100 x^2 0 bends 1 bend 2 bends
  • 48. Quadratic & Higher Degrees • Maximum degree of polynomial: # of time points minus 1 • Example: 2 time points perfectly fit by a line (degree 1). Nothing left for a quadratic term to explain. • But, don’t want to overfit • Probably not the case that the real underlying (population) trajectory has 6 bends in it • What degree should we include? • Theoretical considerations • If comparing conditions, look at mean trajectory across conditions (Mirman et al., 2008)
  • 49. Week 11.1: Growth Curve Analysis ! Overview ! Reshaping Data ! Growth Curve Analysis ! Time as a Predictor Variable ! Quadratic & Higher Degrees ! Random Slopes ! Time-Variant & -Invariant Variables ! Breakpoints ! Lab
  • 50. Child 2 Child 1 Child 3 Child 4 Child 1 Assess- ment 1 Child 2 Assess- ment 2 Child 3 Assess- ment 1 Child 3 Assess- ment 2 Sampled CHILDREN Sampled TIME POINTS LEVEL 2 LEVEL 1 • So far, we assume the same growth rate for all kids • Almost certainly not true! • At level 2, we’re sampling kids both with different starting points (intercepts) and growth rates (slopes) Longitudinal Data: Random Slopes Growth Rate 1 Growth Rate 2
  • 51. Longitudinal Data: Random Slopes RANDOM INTERCEPTS MODEL Kids vary in starting point, but all acquire vocabulary at the same rate over this period WITH RANDOM SLOPES Allows rate of vocab acquisition to vary across kids (as well as intercept)
  • 52. • Let’s allow the MonthsInStudy effect to be different for each Child • model.Slope <- lmer(VocabWords ~ 1 + poly(MonthsInStudy,degree=2,raw=TRUE) + (1 + poly(MonthsInStudy,degree=2,raw=TRUE)|Child), data=vocab.p) Longitudinal Data: Random Slopes Child 2 Child 1 Child 3 Child 4 Child 1 Assess- ment 1 Child 2 Assess- ment 2 Child 3 Assess- ment 1 Child 3 Assess- ment 2 Sampled CHILDREN Sampled TIME POINTS LEVEL 2 LEVEL 1 Growth Rate 1 Growth Rate 2
  • 53. Longitudinal Data: Random Slopes Substantial variability in the MonthsInStudy slope SD of the slope across children is ~5 words Mean slope is 11 words/mo, but some kids might have a slope of 6 or 16
  • 54. Week 11.1: Growth Curve Analysis ! Overview ! Reshaping Data ! Growth Curve Analysis ! Time as a Predictor Variable ! Quadratic & Higher Degrees ! Random Slopes ! Time-Variant & -Invariant Variables ! Breakpoints ! Lab
  • 55. Time-Variant & -Invariant Variables • We may want to include other (experimental or observational) variables in a GCA model: • e.g., our reading intervention • MonthsInStudy + Reading • Effect of Reading invariant across time • Can only affect the intercept (parallel lines) • MonthsInStudy * Reading • Effect of Reading varies with time • Can affect intercept & slope
  • 56. Time-Variant & -Invariant Variables • Fixed-effect results with the interaction: e.g., Huttenlocher et al., 1991 Also results in faster vocab growth (amplifies + Time effect) Linear growth rate for “No” group: 8.4 words / month Linear growth rate for “Yes” group: 8.4 + 4.7 = 13.1 words / month Effect of reading at time 0 (intercept): ~6 words No effect on curvature (quadratic term)
  • 57. Time-Variant & -Invariant Variables • Can be either: • Time-Invariant Predictor: Same across all time points within a subject • e.g., our intervention, race/ethnicity • Level 2 variables • Time-Varying Predictor: Varies even within a subject, from one time point to another • e.g., hours of sleep, mood • Level-1 variable Child 2 Child 1 Child 1 Assess- ment 1 Child 2 Assess- ment 2 Sampled CHILDREN Sampled TIME POINTS LEVEL 2 LEVEL 1 • Since R automatically figures out what’s a level-1 vs. level-2 variable, we don’t have to do anything special for either kind of variable
  • 58. Week 11.1: Growth Curve Analysis ! Overview ! Reshaping Data ! Growth Curve Analysis ! Time as a Predictor Variable ! Quadratic & Higher Degrees ! Random Slopes ! Time-Variant & -Invariant Variables ! Breakpoints ! Lab
  • 59. ! Another possibility (in general) is a qualitative change in the trajectory at some point in the range of time observed ! e.g., age of majority, public policy changes, etc. ! Include a breakpoint—a categorical variable that represents whether or not you’re above the point at which the change happens ! mydata %>% mutate(Year2015OrLater= ifelse(Year >= 2015, 1, 0))-> mydata ! New variable is: ! 0 before 2015 ! 1 for 2015 onwards Breakpoints
  • 60. ! Another possibility (in general) is a qualitative change in the trajectory at some point in the range of time observed ! e.g., age of majority, public policy changes, etc. ! Include a breakpoint—a categorical variable that represents whether or not you’re above the point at which the change happens Breakpoints Main effect of breakpoint only – single shift downward (or upward) but same slope Main effect of breakpoint & an interaction – slope also changes
  • 61. ! Can apply this technique to any continuous variables, not just time ! e.g., above/below the poverty line ! As with higher-order polynomials, be wary of overfitting the data ! Most effective if we have an a priori reason to expect a breakpoint somewhere ! Or, use cross-validation to support a more exploratory analysis Breakpoints
  • 62. Week 11.1: Growth Curve Analysis ! Overview ! Reshaping Data ! Growth Curve Analysis ! Time as a Predictor Variable ! Quadratic & Higher Degrees ! Random Slopes ! Time-Variant & -Invariant Variables ! Breakpoints ! Lab