SlideShare une entreprise Scribd logo
1  sur  33
Télécharger pour lire hors ligne
Course Business
! Midterm assignment due on Canvas next
Monday at 1:30 PM
! Unsure if an article is suitable? Can run it by me
! Add-on packages to install for today:
! performance (may have gotten this last week)
! emmeans
! Lab materials on Canvas
Week 8.1: Post-Hoc Comparison
! Unbalanced Factors
! Weighted Coding
! Unweighted Coding
! Post-Hoc Comparisons
! Tukey Test
! Estimated Marginal Means
! Comparing Marginal Means
! Lab
Unbalanced Factors
• Sometimes, we may have differing
numbers of observations per level
• Possible reasons:
• Some categories naturally more common
• e.g., college majors
• Categories may be equally common in the
population, but we have sampling error
• e.g., ended up 60% female participants, 40% male
• Study was designed so that some conditions are
more common
• e.g., more “control” subjects than “intervention” subjects
• We wanted equal numbers of observations, but lost
some because of errors or exclusion criteria
• e.g., data loss due to computer problems
• Dropping subjects below a minimum level of performance
Week 8.1: Post-Hoc Comparison
! Unbalanced Factors
! Weighted Coding
! Unweighted Coding
! Post-Hoc Comparisons
! Tukey Test
! Estimated Marginal Means
! Comparing Marginal Means
! Lab
Weighted Coding
• “For the average student, does course size
predict probability of graduation?”
• Random sample of 200 Pitt undergrads
• 5 are student athletes and 195 are not
• How can we make the intercept reflect the
“average student”?
• We could try to apply effects coding to the
StudentAthlete variable by centering around the
mean and getting (0.5, -0.5), but…
Weighted Coding
• An intercept at 0 would no longer correspond to the
overall mean
• As a scale, this would be totally
unbalanced
• To fix balance, we need to assign
a heavier weight to Athlete
ATHLETE
(5)
NOT ATHLETE
(195)
.5 -.5
0
-.475
Zero is here
But “not athlete” is actually far more common
Weighted Coding
• Change codes so the mean is 0
• c(.975, -.025)
• contr.helmert.weighted() function in my
psycholing package will calculate this
ATHLETE
(5)
NOT ATHLETE
(195)
.975 -.025
0
Weighted Coding
• Weighted coding: Change the codes so that
the mean is 0 again
• Used when the imbalance reflects something real
• Like Type II sums of squares
• “For the average student, does course size
predict graduation rates?”
• Average student is not a student athlete, and our
answer to the question about an “average student”
should reflect this!
Week 8.1: Post-Hoc Comparison
! Unbalanced Factors
! Weighted Coding
! Unweighted Coding
! Post-Hoc Comparisons
! Tukey Test
! Estimated Marginal Means
! Comparing Marginal Means
! Lab
Unweighted Coding
• Last week we looked at aphasia.csv:
• Response times (RT) in a sentence verification task
• Effect of SubjectType (aphasia vs. control)
• Effect of SentenceType (active vs. passive)
• And their interaction
Unweighted Coding
• Oops! Our experiment loaded up the wrong image
for one of our Passive sentences (“Groceries”)
• It may have been sabotaged
• UsableItem column is No for this item
• First, can we remove this from our data?
• Some possibilities:
• aphasia %>% filter(UsableItem == 'Yes') -> aphasia
• aphasia %>% filter(UsableItem != 'No') -> aphasia2
• etc.
Unweighted Coding
• Oops! Our experiment loaded up the wrong image
for one of our Passive sentences (“Groceries”)
• Now, there’s an imbalance, but it’s an accident and
not meaningful
• In fact, we’d like to get rid of it!
Unweighted Coding
• Oops! Our experiment loaded up the wrong image
for one of our Passive sentences (“Groceries”)
• Now, there’s an imbalance, but it’s an accident and
not meaningful
• In fact, we’d like to get rid of it!
• Retain the (-0.5, 0.5) codes
• Weights the two conditions equally—because the
imbalance isn’t meaningful
• Like Type III sums of squares
• Probably what you want for factorial experiments
Unbalanced Factors: Summary
• Weighted coding: Change the codes so that the
mean is 0
• Use when the imbalance reflects something real
• Can be done with contr.helmert.weighted()
• Unweighted coding: Keep the codes as -0.5 and
0.5
• Use when the imbalance is an accident that we
want to eliminate
• With balanced factors, these are identical
Mean across each individual:
Mean of the two levels:
Mean of the
active sentences
Mean of the
passive sentences
Week 8.1: Post-Hoc Comparison
! Unbalanced Factors
! Weighted Coding
! Unweighted Coding
! Post-Hoc Comparisons
! Tukey Test
! Estimated Marginal Means
! Comparing Marginal Means
! Lab
Post-hoc Comparisons
• Maximal model for the aphasia data was:
• model.Maximal <- lmer(RT ~
1 + SentenceType * SubjectType +
(1 + SentenceType|Subject) +
(1 + SubjectType|Item),
data = aphasia)
• This didn’t converge:
• boundary (singular) fit: see ?isSingular
Probably
overparameterized
Post-hoc Comparisons
• Maximal model for the aphasia data was:
• model.Maximal <- lmer(RT ~
1 + SentenceType * SubjectType +
(1 + SentenceType|Subject) +
(1 + SubjectType|Item),
data = aphasia)
• So, let’s simplify:
• model2<- lmer(RT ~
1 + SentenceType * SubjectType +
(1 + SentenceType|Subject) +
(1|Item),
data = aphasia)
• Doesn’t seem to harm model fit—p > .20
• anova(model.Maximal, model2)
Post-hoc Comparisons
Intercept: RT for healthy
controls, active sentences
Significant RT difference for
passive sentences (among
healthy controls)
Not a significant RT
difference for aphasics
(among active
sentences)
Significant special effect of
aphasia + passive sentence
• With treatment coding, we get
estimates of simple-effects:
Post-hoc Comparisons
• The estimates from a model are enough to fully
describe differences among conditions
• With simple effects:
ACTIVE,
CONTROL
RT ≈ 1716 ms
PASSIVE,
CONTROL
RT ≈ 2269 ms
SubjectType
SentenceType
Active Passive
Aphasia
Control
Passive
simple
effect
+553 ms
Post-hoc Comparisons
• The estimates from a model are enough to fully
describe differences among conditions
• With simple effects:
ACTIVE,
APHASIA
RT ≈ 1801 ms
ACTIVE,
CONTROL
RT ≈ 1716 ms
PASSIVE,
CONTROL
RT ≈ 2269 ms
SubjectType
SentenceType
Active Passive
Aphasia
Control
Passive
simple
effect
+553 ms
Aphasia
simple
effect
+85
ms
Post-hoc Comparisons
• The estimates from a model are enough to fully
describe differences among conditions
• With simple effects:
ACTIVE,
APHASIA
RT ≈ 1801 ms
PASSIVE,
APHASIA
RT ≈ 2542 ms
ACTIVE,
CONTROL
RT ≈ 1716 ms
PASSIVE,
CONTROL
RT ≈ 2269 ms
SubjectType
SentenceType
Active Passive
Aphasia
Control
Passive
simple
effect
+553 ms
Aphasia
simple
effect
+85
ms
+553 ms
+85
ms
Interaction
effect
+188
m
s
Post-hoc Comparisons
• But, sometimes we want to compare individual
combinations (e.g., people w/ aphasia seeing
active vs passive sentences)
• i.e., individual cells
ACTIVE,
APHASIA
RT ≈ 1801 ms
PASSIVE,
APHASIA
RT ≈ 2542 ms
ACTIVE,
CONTROL
RT ≈ 1716 ms
PASSIVE,
CONTROL
RT ≈ 2269 ms
SubjectType
SentenceType
Active Passive
Aphasia
Control
?
Week 8.1: Post-Hoc Comparison
! Unbalanced Factors
! Weighted Coding
! Unweighted Coding
! Post-Hoc Comparisons
! Tukey Test
! Estimated Marginal Means
! Comparing Marginal Means
! Lab
Post-hoc Comparisons: Tukey Test
• But, sometimes we want to compare individual
combinations (e.g., people w/ aphasia seeing
active vs passive sentences)
• i.e., individual cells
• emmeans(Model.Maximal,pairwise~SentenceType*SubjectType)
• Requires emmeans package to be loaded
• library(emmeans)
• Uses Tukey
test to correct
for multiple
comparisons
so overall
α still = .05
• Which two cells don’t significantly differ?
Name of the model not the
original dataframe
Comparisons of each pair of cells
The independent variables
(for now, all of them)
Week 8.1: Post-Hoc Comparison
! Unbalanced Factors
! Weighted Coding
! Unweighted Coding
! Post-Hoc Comparisons
! Tukey Test
! Estimated Marginal Means
! Comparing Marginal Means
! Lab
Estimated Marginal Means
• emmeans also returns estimated means and std.
errors for each cell of the design
• EMMs represent what the means of the different
groups would look like if they didn’t differ in other
(fixed or random) variables
Estimated Marginal Means
• As an example, let’s add SentenceLength as a
covariate
• Task was to read the sentence & judge whether it matches a
picture, so length of sentence would plausibly affect time
needed to do this
• Not perfectly balanced across conditions
Estimated Marginal Means
• New model & estimated marginal means:
• model.Length <- lmer(RT ~ 1 + SentenceType *
SubjectType + SentenceLength + (SentenceType|Subject)
+ (1|Item), data=aphasia)
• emmeans(model.Length,
pairwise~SentenceType*SubjectType + SentenceLength)
Our raw data (where the
average sentence length
differs slightly across
conditions)
What we’d
expect if the
sentences were
all of equal
length
Estimated Marginal Means
• EMMs are a hypothetical
• What the means of the different
groups would look like if they didn’t
differ in this covariate
• Like unweighted coding in the
case of missingness
• Based on our statistical model, so if our
model is wrong (e.g., we picked the wrong
covariate), the adjusted means will be too
• Unlike the raw sample means
• Need to use some caution in interpreting them
• Be clear what you are reporting
Estimated Marginal Means
• Also possible to test whether each of these
estimated cell means significantly differs from 0
• ls_means(model.Length)
• Silly in case of RTs, but could be relevant for some other
DVs (e.g., preference)
Week 8.1: Post-Hoc Comparison
! Unbalanced Factors
! Weighted Coding
! Unweighted Coding
! Post-Hoc Comparisons
! Tukey Test
! Estimated Marginal Means
! Comparing Marginal Means
! Lab
Comparing Marginal Means
• emmeans can also test marginal means:
• emmeans(model2,pairwise~SubjectType)
• Effect of one variable averaging over the other
• e.g., aphasic participants (averaging over all sentence
types) vs. controls (averaging over all sentence types)
• These are what main effects are testing
Now, include just one variable (for which
we want marginal means)
Week 8.1: Post-Hoc Comparison
! Unbalanced Factors
! Weighted Coding
! Unweighted Coding
! Post-Hoc Comparisons
! Tukey Test
! Estimated Marginal Means
! Comparing Marginal Means
! Lab

Contenu connexe

Tendances

Mixed Effects Models - Descriptive Statistics
Mixed Effects Models - Descriptive StatisticsMixed Effects Models - Descriptive Statistics
Mixed Effects Models - Descriptive StatisticsScott Fraundorf
 
Mixed Effects Models - Orthogonal Contrasts
Mixed Effects Models - Orthogonal ContrastsMixed Effects Models - Orthogonal Contrasts
Mixed Effects Models - Orthogonal ContrastsScott Fraundorf
 
Mixed Effects Models - Crossed Random Effects
Mixed Effects Models - Crossed Random EffectsMixed Effects Models - Crossed Random Effects
Mixed Effects Models - Crossed Random EffectsScott Fraundorf
 
Mixed Effects Models - Fixed Effects
Mixed Effects Models - Fixed EffectsMixed Effects Models - Fixed Effects
Mixed Effects Models - Fixed EffectsScott Fraundorf
 
Mixed Effects Models - Data Processing
Mixed Effects Models - Data ProcessingMixed Effects Models - Data Processing
Mixed Effects Models - Data ProcessingScott Fraundorf
 
Mixed Effects Models - Autocorrelation
Mixed Effects Models - AutocorrelationMixed Effects Models - Autocorrelation
Mixed Effects Models - AutocorrelationScott Fraundorf
 
Mixed Effects Models - Effect Size
Mixed Effects Models - Effect SizeMixed Effects Models - Effect Size
Mixed Effects Models - Effect SizeScott 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
 
Reporting an independent sample t test
Reporting an independent sample t testReporting an independent sample t test
Reporting an independent sample t testKen Plummer
 
Reporting chi square goodness of fit test of independence in apa
Reporting chi square goodness of fit test of independence in apaReporting chi square goodness of fit test of independence in apa
Reporting chi square goodness of fit test of independence in apaKen Plummer
 
Reporting a non parametric Friedman test in APA
Reporting a non parametric Friedman test in APAReporting a non parametric Friedman test in APA
Reporting a non parametric Friedman test in APAKen Plummer
 
Reporting Mann Whitney U Test in APA
Reporting Mann Whitney U Test in APAReporting Mann Whitney U Test in APA
Reporting Mann Whitney U Test in APAKen Plummer
 
Reporting a paired sample t -test
Reporting a paired sample t -testReporting a paired sample t -test
Reporting a paired sample t -testAmit Sharma
 
Multivariate data analysis regression, cluster and factor analysis on spss
Multivariate data analysis   regression, cluster and factor analysis on spssMultivariate data analysis   regression, cluster and factor analysis on spss
Multivariate data analysis regression, cluster and factor analysis on spssAditya Banerjee
 
Moderation and Mediation | Dissertation Webinar
Moderation and Mediation | Dissertation WebinarModeration and Mediation | Dissertation Webinar
Moderation and Mediation | Dissertation WebinarStatistics Solutions
 
Reporting an independent sample t- test
Reporting an independent sample t- testReporting an independent sample t- test
Reporting an independent sample t- testAmit Sharma
 
Reporting phi coefficient test in APA?
Reporting phi coefficient test in APA?Reporting phi coefficient test in APA?
Reporting phi coefficient test in APA?Ken Plummer
 
Reporting pearson correlation in apa
Reporting pearson correlation in apaReporting pearson correlation in apa
Reporting pearson correlation in apaKen Plummer
 

Tendances (20)

Mixed Effects Models - Descriptive Statistics
Mixed Effects Models - Descriptive StatisticsMixed Effects Models - Descriptive Statistics
Mixed Effects Models - Descriptive Statistics
 
Mixed Effects Models - Orthogonal Contrasts
Mixed Effects Models - Orthogonal ContrastsMixed Effects Models - Orthogonal Contrasts
Mixed Effects Models - Orthogonal Contrasts
 
Mixed Effects Models - Crossed Random Effects
Mixed Effects Models - Crossed Random EffectsMixed Effects Models - Crossed Random Effects
Mixed Effects Models - Crossed Random Effects
 
Mixed Effects Models - Fixed Effects
Mixed Effects Models - Fixed EffectsMixed Effects Models - Fixed Effects
Mixed Effects Models - Fixed Effects
 
Mixed Effects Models - Data Processing
Mixed Effects Models - Data ProcessingMixed Effects Models - Data Processing
Mixed Effects Models - Data Processing
 
Mixed Effects Models - Autocorrelation
Mixed Effects Models - AutocorrelationMixed Effects Models - Autocorrelation
Mixed Effects Models - Autocorrelation
 
Mixed Effects Models - Effect Size
Mixed Effects Models - Effect SizeMixed Effects Models - Effect Size
Mixed Effects Models - Effect Size
 
Mixed Effects Models - Signal Detection Theory
Mixed Effects Models - Signal Detection TheoryMixed Effects Models - Signal Detection Theory
Mixed Effects Models - Signal Detection Theory
 
Correlation (1)
Correlation (1)Correlation (1)
Correlation (1)
 
Key ideas, terms and concepts in SEM
Key ideas, terms and concepts in SEMKey ideas, terms and concepts in SEM
Key ideas, terms and concepts in SEM
 
Reporting an independent sample t test
Reporting an independent sample t testReporting an independent sample t test
Reporting an independent sample t test
 
Reporting chi square goodness of fit test of independence in apa
Reporting chi square goodness of fit test of independence in apaReporting chi square goodness of fit test of independence in apa
Reporting chi square goodness of fit test of independence in apa
 
Reporting a non parametric Friedman test in APA
Reporting a non parametric Friedman test in APAReporting a non parametric Friedman test in APA
Reporting a non parametric Friedman test in APA
 
Reporting Mann Whitney U Test in APA
Reporting Mann Whitney U Test in APAReporting Mann Whitney U Test in APA
Reporting Mann Whitney U Test in APA
 
Reporting a paired sample t -test
Reporting a paired sample t -testReporting a paired sample t -test
Reporting a paired sample t -test
 
Multivariate data analysis regression, cluster and factor analysis on spss
Multivariate data analysis   regression, cluster and factor analysis on spssMultivariate data analysis   regression, cluster and factor analysis on spss
Multivariate data analysis regression, cluster and factor analysis on spss
 
Moderation and Mediation | Dissertation Webinar
Moderation and Mediation | Dissertation WebinarModeration and Mediation | Dissertation Webinar
Moderation and Mediation | Dissertation Webinar
 
Reporting an independent sample t- test
Reporting an independent sample t- testReporting an independent sample t- test
Reporting an independent sample t- test
 
Reporting phi coefficient test in APA?
Reporting phi coefficient test in APA?Reporting phi coefficient test in APA?
Reporting phi coefficient test in APA?
 
Reporting pearson correlation in apa
Reporting pearson correlation in apaReporting pearson correlation in apa
Reporting pearson correlation in apa
 

Similaire à Mixed Effects Models - Post-Hoc Comparisons

Topic 5 (multiple regression)
Topic 5 (multiple regression)Topic 5 (multiple regression)
Topic 5 (multiple regression)Ryan Herzog
 
NLP_KASHK:Evaluating Language Model
NLP_KASHK:Evaluating Language ModelNLP_KASHK:Evaluating Language Model
NLP_KASHK:Evaluating Language ModelHemantha Kulathilake
 
LecccccccccccccProgrammingLecture-09.pdf
LecccccccccccccProgrammingLecture-09.pdfLecccccccccccccProgrammingLecture-09.pdf
LecccccccccccccProgrammingLecture-09.pdfAmirMohamedNabilSale
 
Topic 5 (multiple regression)
Topic 5 (multiple regression)Topic 5 (multiple regression)
Topic 5 (multiple regression)Ryan Herzog
 
Topic 2 - More on Hypothesis Testing
Topic 2 - More on Hypothesis TestingTopic 2 - More on Hypothesis Testing
Topic 2 - More on Hypothesis TestingRyan Herzog
 
probability.pptx
probability.pptxprobability.pptx
probability.pptxbisan3
 
regression.pptx
regression.pptxregression.pptx
regression.pptxaneeshs28
 
Mixed Effects Models - Missing Data
Mixed Effects Models - Missing DataMixed Effects Models - Missing Data
Mixed Effects Models - Missing DataScott Fraundorf
 
powerpoint 1-19.pdf
powerpoint 1-19.pdfpowerpoint 1-19.pdf
powerpoint 1-19.pdfJuanPicasso7
 
Introduction to Machine Learning
Introduction to Machine LearningIntroduction to Machine Learning
Introduction to Machine LearningShimi Bandiel
 
Thermal Expansion Lab ProjectThe data listed in Table 1 be
Thermal Expansion Lab ProjectThe data listed in Table 1 beThermal Expansion Lab ProjectThe data listed in Table 1 be
Thermal Expansion Lab ProjectThe data listed in Table 1 beGrazynaBroyles24
 
Formulating a Hypothesis
Formulating a HypothesisFormulating a Hypothesis
Formulating a Hypothesisbjkim0228
 
Dimd_m_004 DL.pdf
Dimd_m_004 DL.pdfDimd_m_004 DL.pdf
Dimd_m_004 DL.pdfjuan631
 
Lab report walk through
Lab report walk throughLab report walk through
Lab report walk throughserenaasya
 
Artificial Unintelligence:Why and How Automated Essay Scoring Doesn’t Work (m...
Artificial Unintelligence:Why and How Automated Essay Scoring Doesn’t Work (m...Artificial Unintelligence:Why and How Automated Essay Scoring Doesn’t Work (m...
Artificial Unintelligence:Why and How Automated Essay Scoring Doesn’t Work (m...Les Perelman
 
Mixed Effects Models - Growth Curve Analysis
Mixed Effects Models - Growth Curve AnalysisMixed Effects Models - Growth Curve Analysis
Mixed Effects Models - Growth Curve AnalysisScott Fraundorf
 

Similaire à Mixed Effects Models - Post-Hoc Comparisons (20)

Topic 5 (multiple regression)
Topic 5 (multiple regression)Topic 5 (multiple regression)
Topic 5 (multiple regression)
 
NLP_KASHK:Evaluating Language Model
NLP_KASHK:Evaluating Language ModelNLP_KASHK:Evaluating Language Model
NLP_KASHK:Evaluating Language Model
 
LecccccccccccccProgrammingLecture-09.pdf
LecccccccccccccProgrammingLecture-09.pdfLecccccccccccccProgrammingLecture-09.pdf
LecccccccccccccProgrammingLecture-09.pdf
 
Topic 5 (multiple regression)
Topic 5 (multiple regression)Topic 5 (multiple regression)
Topic 5 (multiple regression)
 
Topic 2 - More on Hypothesis Testing
Topic 2 - More on Hypothesis TestingTopic 2 - More on Hypothesis Testing
Topic 2 - More on Hypothesis Testing
 
probability.pptx
probability.pptxprobability.pptx
probability.pptx
 
Chapter37
Chapter37Chapter37
Chapter37
 
Inferential Statistics
Inferential StatisticsInferential Statistics
Inferential Statistics
 
regression.pptx
regression.pptxregression.pptx
regression.pptx
 
Mixed Effects Models - Missing Data
Mixed Effects Models - Missing DataMixed Effects Models - Missing Data
Mixed Effects Models - Missing Data
 
powerpoint 1-19.pdf
powerpoint 1-19.pdfpowerpoint 1-19.pdf
powerpoint 1-19.pdf
 
5954987.ppt
5954987.ppt5954987.ppt
5954987.ppt
 
Introduction to Machine Learning
Introduction to Machine LearningIntroduction to Machine Learning
Introduction to Machine Learning
 
Thermal Expansion Lab ProjectThe data listed in Table 1 be
Thermal Expansion Lab ProjectThe data listed in Table 1 beThermal Expansion Lab ProjectThe data listed in Table 1 be
Thermal Expansion Lab ProjectThe data listed in Table 1 be
 
Formulating a Hypothesis
Formulating a HypothesisFormulating a Hypothesis
Formulating a Hypothesis
 
Dimd_m_004 DL.pdf
Dimd_m_004 DL.pdfDimd_m_004 DL.pdf
Dimd_m_004 DL.pdf
 
Spss
SpssSpss
Spss
 
Lab report walk through
Lab report walk throughLab report walk through
Lab report walk through
 
Artificial Unintelligence:Why and How Automated Essay Scoring Doesn’t Work (m...
Artificial Unintelligence:Why and How Automated Essay Scoring Doesn’t Work (m...Artificial Unintelligence:Why and How Automated Essay Scoring Doesn’t Work (m...
Artificial Unintelligence:Why and How Automated Essay Scoring Doesn’t Work (m...
 
Mixed Effects Models - Growth Curve Analysis
Mixed Effects Models - Growth Curve AnalysisMixed Effects Models - Growth Curve Analysis
Mixed Effects Models - Growth Curve Analysis
 

Dernier

Philosophy of Education and Educational Philosophy
Philosophy of Education  and Educational PhilosophyPhilosophy of Education  and Educational Philosophy
Philosophy of Education and Educational PhilosophyShuvankar Madhu
 
P4C x ELT = P4ELT: Its Theoretical Background (Kanazawa, 2024 March).pdf
P4C x ELT = P4ELT: Its Theoretical Background (Kanazawa, 2024 March).pdfP4C x ELT = P4ELT: Its Theoretical Background (Kanazawa, 2024 March).pdf
P4C x ELT = P4ELT: Its Theoretical Background (Kanazawa, 2024 March).pdfYu Kanazawa / Osaka University
 
Ultra structure and life cycle of Plasmodium.pptx
Ultra structure and life cycle of Plasmodium.pptxUltra structure and life cycle of Plasmodium.pptx
Ultra structure and life cycle of Plasmodium.pptxDr. Asif Anas
 
CHUYÊN ĐỀ DẠY THÊM TIẾNG ANH LỚP 11 - GLOBAL SUCCESS - NĂM HỌC 2023-2024 - HK...
CHUYÊN ĐỀ DẠY THÊM TIẾNG ANH LỚP 11 - GLOBAL SUCCESS - NĂM HỌC 2023-2024 - HK...CHUYÊN ĐỀ DẠY THÊM TIẾNG ANH LỚP 11 - GLOBAL SUCCESS - NĂM HỌC 2023-2024 - HK...
CHUYÊN ĐỀ DẠY THÊM TIẾNG ANH LỚP 11 - GLOBAL SUCCESS - NĂM HỌC 2023-2024 - HK...Nguyen Thanh Tu Collection
 
How to Add Existing Field in One2Many Tree View in Odoo 17
How to Add Existing Field in One2Many Tree View in Odoo 17How to Add Existing Field in One2Many Tree View in Odoo 17
How to Add Existing Field in One2Many Tree View in Odoo 17Celine George
 
Easter in the USA presentation by Chloe.
Easter in the USA presentation by Chloe.Easter in the USA presentation by Chloe.
Easter in the USA presentation by Chloe.EnglishCEIPdeSigeiro
 
Education and training program in the hospital APR.pptx
Education and training program in the hospital APR.pptxEducation and training program in the hospital APR.pptx
Education and training program in the hospital APR.pptxraviapr7
 
M-2- General Reactions of amino acids.pptx
M-2- General Reactions of amino acids.pptxM-2- General Reactions of amino acids.pptx
M-2- General Reactions of amino acids.pptxDr. Santhosh Kumar. N
 
2024.03.23 What do successful readers do - Sandy Millin for PARK.pptx
2024.03.23 What do successful readers do - Sandy Millin for PARK.pptx2024.03.23 What do successful readers do - Sandy Millin for PARK.pptx
2024.03.23 What do successful readers do - Sandy Millin for PARK.pptxSandy Millin
 
Prescribed medication order and communication skills.pptx
Prescribed medication order and communication skills.pptxPrescribed medication order and communication skills.pptx
Prescribed medication order and communication skills.pptxraviapr7
 
5 charts on South Africa as a source country for international student recrui...
5 charts on South Africa as a source country for international student recrui...5 charts on South Africa as a source country for international student recrui...
5 charts on South Africa as a source country for international student recrui...CaraSkikne1
 
How to Manage Cross-Selling in Odoo 17 Sales
How to Manage Cross-Selling in Odoo 17 SalesHow to Manage Cross-Selling in Odoo 17 Sales
How to Manage Cross-Selling in Odoo 17 SalesCeline George
 
How to Add a New Field in Existing Kanban View in Odoo 17
How to Add a New Field in Existing Kanban View in Odoo 17How to Add a New Field in Existing Kanban View in Odoo 17
How to Add a New Field in Existing Kanban View in Odoo 17Celine George
 
Clinical Pharmacy Introduction to Clinical Pharmacy, Concept of clinical pptx
Clinical Pharmacy  Introduction to Clinical Pharmacy, Concept of clinical pptxClinical Pharmacy  Introduction to Clinical Pharmacy, Concept of clinical pptx
Clinical Pharmacy Introduction to Clinical Pharmacy, Concept of clinical pptxraviapr7
 
How to Make a Field read-only in Odoo 17
How to Make a Field read-only in Odoo 17How to Make a Field read-only in Odoo 17
How to Make a Field read-only in Odoo 17Celine George
 
CAULIFLOWER BREEDING 1 Parmar pptx
CAULIFLOWER BREEDING 1 Parmar pptxCAULIFLOWER BREEDING 1 Parmar pptx
CAULIFLOWER BREEDING 1 Parmar pptxSaurabhParmar42
 
Patient Counselling. Definition of patient counseling; steps involved in pati...
Patient Counselling. Definition of patient counseling; steps involved in pati...Patient Counselling. Definition of patient counseling; steps involved in pati...
Patient Counselling. Definition of patient counseling; steps involved in pati...raviapr7
 
How to Use api.constrains ( ) in Odoo 17
How to Use api.constrains ( ) in Odoo 17How to Use api.constrains ( ) in Odoo 17
How to Use api.constrains ( ) in Odoo 17Celine George
 
Quality Assurance_GOOD LABORATORY PRACTICE
Quality Assurance_GOOD LABORATORY PRACTICEQuality Assurance_GOOD LABORATORY PRACTICE
Quality Assurance_GOOD LABORATORY PRACTICESayali Powar
 

Dernier (20)

Philosophy of Education and Educational Philosophy
Philosophy of Education  and Educational PhilosophyPhilosophy of Education  and Educational Philosophy
Philosophy of Education and Educational Philosophy
 
P4C x ELT = P4ELT: Its Theoretical Background (Kanazawa, 2024 March).pdf
P4C x ELT = P4ELT: Its Theoretical Background (Kanazawa, 2024 March).pdfP4C x ELT = P4ELT: Its Theoretical Background (Kanazawa, 2024 March).pdf
P4C x ELT = P4ELT: Its Theoretical Background (Kanazawa, 2024 March).pdf
 
Ultra structure and life cycle of Plasmodium.pptx
Ultra structure and life cycle of Plasmodium.pptxUltra structure and life cycle of Plasmodium.pptx
Ultra structure and life cycle of Plasmodium.pptx
 
CHUYÊN ĐỀ DẠY THÊM TIẾNG ANH LỚP 11 - GLOBAL SUCCESS - NĂM HỌC 2023-2024 - HK...
CHUYÊN ĐỀ DẠY THÊM TIẾNG ANH LỚP 11 - GLOBAL SUCCESS - NĂM HỌC 2023-2024 - HK...CHUYÊN ĐỀ DẠY THÊM TIẾNG ANH LỚP 11 - GLOBAL SUCCESS - NĂM HỌC 2023-2024 - HK...
CHUYÊN ĐỀ DẠY THÊM TIẾNG ANH LỚP 11 - GLOBAL SUCCESS - NĂM HỌC 2023-2024 - HK...
 
How to Add Existing Field in One2Many Tree View in Odoo 17
How to Add Existing Field in One2Many Tree View in Odoo 17How to Add Existing Field in One2Many Tree View in Odoo 17
How to Add Existing Field in One2Many Tree View in Odoo 17
 
Easter in the USA presentation by Chloe.
Easter in the USA presentation by Chloe.Easter in the USA presentation by Chloe.
Easter in the USA presentation by Chloe.
 
Education and training program in the hospital APR.pptx
Education and training program in the hospital APR.pptxEducation and training program in the hospital APR.pptx
Education and training program in the hospital APR.pptx
 
M-2- General Reactions of amino acids.pptx
M-2- General Reactions of amino acids.pptxM-2- General Reactions of amino acids.pptx
M-2- General Reactions of amino acids.pptx
 
2024.03.23 What do successful readers do - Sandy Millin for PARK.pptx
2024.03.23 What do successful readers do - Sandy Millin for PARK.pptx2024.03.23 What do successful readers do - Sandy Millin for PARK.pptx
2024.03.23 What do successful readers do - Sandy Millin for PARK.pptx
 
Personal Resilience in Project Management 2 - TV Edit 1a.pdf
Personal Resilience in Project Management 2 - TV Edit 1a.pdfPersonal Resilience in Project Management 2 - TV Edit 1a.pdf
Personal Resilience in Project Management 2 - TV Edit 1a.pdf
 
Prescribed medication order and communication skills.pptx
Prescribed medication order and communication skills.pptxPrescribed medication order and communication skills.pptx
Prescribed medication order and communication skills.pptx
 
5 charts on South Africa as a source country for international student recrui...
5 charts on South Africa as a source country for international student recrui...5 charts on South Africa as a source country for international student recrui...
5 charts on South Africa as a source country for international student recrui...
 
How to Manage Cross-Selling in Odoo 17 Sales
How to Manage Cross-Selling in Odoo 17 SalesHow to Manage Cross-Selling in Odoo 17 Sales
How to Manage Cross-Selling in Odoo 17 Sales
 
How to Add a New Field in Existing Kanban View in Odoo 17
How to Add a New Field in Existing Kanban View in Odoo 17How to Add a New Field in Existing Kanban View in Odoo 17
How to Add a New Field in Existing Kanban View in Odoo 17
 
Clinical Pharmacy Introduction to Clinical Pharmacy, Concept of clinical pptx
Clinical Pharmacy  Introduction to Clinical Pharmacy, Concept of clinical pptxClinical Pharmacy  Introduction to Clinical Pharmacy, Concept of clinical pptx
Clinical Pharmacy Introduction to Clinical Pharmacy, Concept of clinical pptx
 
How to Make a Field read-only in Odoo 17
How to Make a Field read-only in Odoo 17How to Make a Field read-only in Odoo 17
How to Make a Field read-only in Odoo 17
 
CAULIFLOWER BREEDING 1 Parmar pptx
CAULIFLOWER BREEDING 1 Parmar pptxCAULIFLOWER BREEDING 1 Parmar pptx
CAULIFLOWER BREEDING 1 Parmar pptx
 
Patient Counselling. Definition of patient counseling; steps involved in pati...
Patient Counselling. Definition of patient counseling; steps involved in pati...Patient Counselling. Definition of patient counseling; steps involved in pati...
Patient Counselling. Definition of patient counseling; steps involved in pati...
 
How to Use api.constrains ( ) in Odoo 17
How to Use api.constrains ( ) in Odoo 17How to Use api.constrains ( ) in Odoo 17
How to Use api.constrains ( ) in Odoo 17
 
Quality Assurance_GOOD LABORATORY PRACTICE
Quality Assurance_GOOD LABORATORY PRACTICEQuality Assurance_GOOD LABORATORY PRACTICE
Quality Assurance_GOOD LABORATORY PRACTICE
 

Mixed Effects Models - Post-Hoc Comparisons

  • 1. Course Business ! Midterm assignment due on Canvas next Monday at 1:30 PM ! Unsure if an article is suitable? Can run it by me ! Add-on packages to install for today: ! performance (may have gotten this last week) ! emmeans ! Lab materials on Canvas
  • 2. Week 8.1: Post-Hoc Comparison ! Unbalanced Factors ! Weighted Coding ! Unweighted Coding ! Post-Hoc Comparisons ! Tukey Test ! Estimated Marginal Means ! Comparing Marginal Means ! Lab
  • 3. Unbalanced Factors • Sometimes, we may have differing numbers of observations per level • Possible reasons: • Some categories naturally more common • e.g., college majors • Categories may be equally common in the population, but we have sampling error • e.g., ended up 60% female participants, 40% male • Study was designed so that some conditions are more common • e.g., more “control” subjects than “intervention” subjects • We wanted equal numbers of observations, but lost some because of errors or exclusion criteria • e.g., data loss due to computer problems • Dropping subjects below a minimum level of performance
  • 4. Week 8.1: Post-Hoc Comparison ! Unbalanced Factors ! Weighted Coding ! Unweighted Coding ! Post-Hoc Comparisons ! Tukey Test ! Estimated Marginal Means ! Comparing Marginal Means ! Lab
  • 5. Weighted Coding • “For the average student, does course size predict probability of graduation?” • Random sample of 200 Pitt undergrads • 5 are student athletes and 195 are not • How can we make the intercept reflect the “average student”? • We could try to apply effects coding to the StudentAthlete variable by centering around the mean and getting (0.5, -0.5), but…
  • 6. Weighted Coding • An intercept at 0 would no longer correspond to the overall mean • As a scale, this would be totally unbalanced • To fix balance, we need to assign a heavier weight to Athlete ATHLETE (5) NOT ATHLETE (195) .5 -.5 0 -.475 Zero is here But “not athlete” is actually far more common
  • 7. Weighted Coding • Change codes so the mean is 0 • c(.975, -.025) • contr.helmert.weighted() function in my psycholing package will calculate this ATHLETE (5) NOT ATHLETE (195) .975 -.025 0
  • 8. Weighted Coding • Weighted coding: Change the codes so that the mean is 0 again • Used when the imbalance reflects something real • Like Type II sums of squares • “For the average student, does course size predict graduation rates?” • Average student is not a student athlete, and our answer to the question about an “average student” should reflect this!
  • 9. Week 8.1: Post-Hoc Comparison ! Unbalanced Factors ! Weighted Coding ! Unweighted Coding ! Post-Hoc Comparisons ! Tukey Test ! Estimated Marginal Means ! Comparing Marginal Means ! Lab
  • 10. Unweighted Coding • Last week we looked at aphasia.csv: • Response times (RT) in a sentence verification task • Effect of SubjectType (aphasia vs. control) • Effect of SentenceType (active vs. passive) • And their interaction
  • 11. Unweighted Coding • Oops! Our experiment loaded up the wrong image for one of our Passive sentences (“Groceries”) • It may have been sabotaged • UsableItem column is No for this item • First, can we remove this from our data? • Some possibilities: • aphasia %>% filter(UsableItem == 'Yes') -> aphasia • aphasia %>% filter(UsableItem != 'No') -> aphasia2 • etc.
  • 12. Unweighted Coding • Oops! Our experiment loaded up the wrong image for one of our Passive sentences (“Groceries”) • Now, there’s an imbalance, but it’s an accident and not meaningful • In fact, we’d like to get rid of it!
  • 13. Unweighted Coding • Oops! Our experiment loaded up the wrong image for one of our Passive sentences (“Groceries”) • Now, there’s an imbalance, but it’s an accident and not meaningful • In fact, we’d like to get rid of it! • Retain the (-0.5, 0.5) codes • Weights the two conditions equally—because the imbalance isn’t meaningful • Like Type III sums of squares • Probably what you want for factorial experiments
  • 14. Unbalanced Factors: Summary • Weighted coding: Change the codes so that the mean is 0 • Use when the imbalance reflects something real • Can be done with contr.helmert.weighted() • Unweighted coding: Keep the codes as -0.5 and 0.5 • Use when the imbalance is an accident that we want to eliminate • With balanced factors, these are identical Mean across each individual: Mean of the two levels: Mean of the active sentences Mean of the passive sentences
  • 15. Week 8.1: Post-Hoc Comparison ! Unbalanced Factors ! Weighted Coding ! Unweighted Coding ! Post-Hoc Comparisons ! Tukey Test ! Estimated Marginal Means ! Comparing Marginal Means ! Lab
  • 16. Post-hoc Comparisons • Maximal model for the aphasia data was: • model.Maximal <- lmer(RT ~ 1 + SentenceType * SubjectType + (1 + SentenceType|Subject) + (1 + SubjectType|Item), data = aphasia) • This didn’t converge: • boundary (singular) fit: see ?isSingular Probably overparameterized
  • 17. Post-hoc Comparisons • Maximal model for the aphasia data was: • model.Maximal <- lmer(RT ~ 1 + SentenceType * SubjectType + (1 + SentenceType|Subject) + (1 + SubjectType|Item), data = aphasia) • So, let’s simplify: • model2<- lmer(RT ~ 1 + SentenceType * SubjectType + (1 + SentenceType|Subject) + (1|Item), data = aphasia) • Doesn’t seem to harm model fit—p > .20 • anova(model.Maximal, model2)
  • 18. Post-hoc Comparisons Intercept: RT for healthy controls, active sentences Significant RT difference for passive sentences (among healthy controls) Not a significant RT difference for aphasics (among active sentences) Significant special effect of aphasia + passive sentence • With treatment coding, we get estimates of simple-effects:
  • 19. Post-hoc Comparisons • The estimates from a model are enough to fully describe differences among conditions • With simple effects: ACTIVE, CONTROL RT ≈ 1716 ms PASSIVE, CONTROL RT ≈ 2269 ms SubjectType SentenceType Active Passive Aphasia Control Passive simple effect +553 ms
  • 20. Post-hoc Comparisons • The estimates from a model are enough to fully describe differences among conditions • With simple effects: ACTIVE, APHASIA RT ≈ 1801 ms ACTIVE, CONTROL RT ≈ 1716 ms PASSIVE, CONTROL RT ≈ 2269 ms SubjectType SentenceType Active Passive Aphasia Control Passive simple effect +553 ms Aphasia simple effect +85 ms
  • 21. Post-hoc Comparisons • The estimates from a model are enough to fully describe differences among conditions • With simple effects: ACTIVE, APHASIA RT ≈ 1801 ms PASSIVE, APHASIA RT ≈ 2542 ms ACTIVE, CONTROL RT ≈ 1716 ms PASSIVE, CONTROL RT ≈ 2269 ms SubjectType SentenceType Active Passive Aphasia Control Passive simple effect +553 ms Aphasia simple effect +85 ms +553 ms +85 ms Interaction effect +188 m s
  • 22. Post-hoc Comparisons • But, sometimes we want to compare individual combinations (e.g., people w/ aphasia seeing active vs passive sentences) • i.e., individual cells ACTIVE, APHASIA RT ≈ 1801 ms PASSIVE, APHASIA RT ≈ 2542 ms ACTIVE, CONTROL RT ≈ 1716 ms PASSIVE, CONTROL RT ≈ 2269 ms SubjectType SentenceType Active Passive Aphasia Control ?
  • 23. Week 8.1: Post-Hoc Comparison ! Unbalanced Factors ! Weighted Coding ! Unweighted Coding ! Post-Hoc Comparisons ! Tukey Test ! Estimated Marginal Means ! Comparing Marginal Means ! Lab
  • 24. Post-hoc Comparisons: Tukey Test • But, sometimes we want to compare individual combinations (e.g., people w/ aphasia seeing active vs passive sentences) • i.e., individual cells • emmeans(Model.Maximal,pairwise~SentenceType*SubjectType) • Requires emmeans package to be loaded • library(emmeans) • Uses Tukey test to correct for multiple comparisons so overall α still = .05 • Which two cells don’t significantly differ? Name of the model not the original dataframe Comparisons of each pair of cells The independent variables (for now, all of them)
  • 25. Week 8.1: Post-Hoc Comparison ! Unbalanced Factors ! Weighted Coding ! Unweighted Coding ! Post-Hoc Comparisons ! Tukey Test ! Estimated Marginal Means ! Comparing Marginal Means ! Lab
  • 26. Estimated Marginal Means • emmeans also returns estimated means and std. errors for each cell of the design • EMMs represent what the means of the different groups would look like if they didn’t differ in other (fixed or random) variables
  • 27. Estimated Marginal Means • As an example, let’s add SentenceLength as a covariate • Task was to read the sentence & judge whether it matches a picture, so length of sentence would plausibly affect time needed to do this • Not perfectly balanced across conditions
  • 28. Estimated Marginal Means • New model & estimated marginal means: • model.Length <- lmer(RT ~ 1 + SentenceType * SubjectType + SentenceLength + (SentenceType|Subject) + (1|Item), data=aphasia) • emmeans(model.Length, pairwise~SentenceType*SubjectType + SentenceLength) Our raw data (where the average sentence length differs slightly across conditions) What we’d expect if the sentences were all of equal length
  • 29. Estimated Marginal Means • EMMs are a hypothetical • What the means of the different groups would look like if they didn’t differ in this covariate • Like unweighted coding in the case of missingness • Based on our statistical model, so if our model is wrong (e.g., we picked the wrong covariate), the adjusted means will be too • Unlike the raw sample means • Need to use some caution in interpreting them • Be clear what you are reporting
  • 30. Estimated Marginal Means • Also possible to test whether each of these estimated cell means significantly differs from 0 • ls_means(model.Length) • Silly in case of RTs, but could be relevant for some other DVs (e.g., preference)
  • 31. Week 8.1: Post-Hoc Comparison ! Unbalanced Factors ! Weighted Coding ! Unweighted Coding ! Post-Hoc Comparisons ! Tukey Test ! Estimated Marginal Means ! Comparing Marginal Means ! Lab
  • 32. Comparing Marginal Means • emmeans can also test marginal means: • emmeans(model2,pairwise~SubjectType) • Effect of one variable averaging over the other • e.g., aphasic participants (averaging over all sentence types) vs. controls (averaging over all sentence types) • These are what main effects are testing Now, include just one variable (for which we want marginal means)
  • 33. Week 8.1: Post-Hoc Comparison ! Unbalanced Factors ! Weighted Coding ! Unweighted Coding ! Post-Hoc Comparisons ! Tukey Test ! Estimated Marginal Means ! Comparing Marginal Means ! Lab