DataCamp Hierarchical and Mixed Effects Models in R HIERARCHICAL AND MIXED EFFECTS MODELS IN R What is a hierarchical model? Richard Erickson Quantitative Ecologist
DataCamp Hierarchical and Mixed Effects Models in R Why do we use a hierarchical model? Data nested within itself Pool information across small sample sizes Repeated observations across groups or individuals
DataCamp Hierarchical and Mixed Effects Models in R Other names for hierarchical models Hierarchical models: Nested models, Multi-level models Regression framework: "Pool" information, "Random-effect" versus a "fixed- effect", "Mixed-effect" (linear mixed-effect model; LMM), Linear mixed-effect regression (lmer) Repeated sampling: "Repeated-measures", "Paired-tests"
DataCamp Hierarchical and Mixed Effects Models in R School test scores Meta-data: Student-level variables: Gain in math scores for individual Student ID: childid students from kindergarten to 1st Math test-score gain: mathgain grade Math kindergarten score: mathdind Part of a national-level assessment in Student's sex: sex US Student's minority status: minority Subset of data from West, Welch, and Galecki
DataCamp Hierarchical and Mixed Effects Models in R School test scores Classroom-level variables: School-level variables: Classroom id: classid School ID: schoolid Teacher's math training: mathprep School's household poverty level: Teacher's math test knowledge test housepov score: mathknow School's socioeconomic status: ses Teacher's years teaching: yearstea
DataCamp Hierarchical and Mixed Effects Models in R HIERARCHICAL AND MIXED EFFECTS MODELS IN R Let's practice!
DataCamp Hierarchical and Mixed Effects Models in R HIERARCHICAL AND MIXED EFFECTS MODELS IN R Parts of a regression Richard Erickson Quantitative Ecologist
DataCamp Hierarchical and Mixed Effects Models in R An intercept y = β + ϵ
DataCamp Hierarchical and Mixed Effects Models in R Multiple intercepts y = β + β x + β x + ϵ 0 2 2 3 3 y = β x + β x + β x + ϵ 1 1 2 2 3 3
DataCamp Hierarchical and Mixed Effects Models in R Linear models in R lm( formula, data) lm( y ~ x, data = myData) anova(lm( y ~ x, data = myData))
DataCamp Hierarchical and Mixed Effects Models in R A simple linear regression with slopes y ∼ β + β x + ϵ 0 1
DataCamp Hierarchical and Mixed Effects Models in R Multiple regression y ∼ β + β x + β x + … + ϵ 0 1 1 2 2
DataCamp Hierarchical and Mixed Effects Models in R Multiple regression caveats Independence of predictor variables "corrected for..." Simpson's paradox Only linear Interactions may be important
DataCamp Hierarchical and Mixed Effects Models in R Multiple regression in R tips lm( y ~ x -1 ) estimates an intercept for each x Numeric versus factors Scaling parameters and slopes lm(y ~ x1 + x2 + x1:x2) can be written as lm(y ~ x1 * x2)
DataCamp Hierarchical and Mixed Effects Models in R Refresher of running and plotting a linear regression in R regModel <- lm( response ~ predictor, data = regDemo) summary( regModel ) regModel regCoefPlot <- tidy(regModel) ggplot( regDemo, aes(x = predictor, y = response) ) + geom_point() + theme_minimal() + geom_abline( intercept = regCoefPlot$estimate[1], slope = regCoefPlot$estimate[2])
DataCamp Hierarchical and Mixed Effects Models in R HIERARCHICAL AND MIXED EFFECTS MODELS IN R Let's practice!
DataCamp Hierarchical and Mixed Effects Models in R HIERARCHICAL AND MIXED EFFECTS MODELS IN R Random-effects in regressions Richard Erickson Quantitative Ecologist
DataCamp Hierarchical and Mixed Effects Models in R
DataCamp Hierarchical and Mixed Effects Models in R
DataCamp Hierarchical and Mixed Effects Models in R Algebraic representation y ∼ β x + ϵ i β ∼ Normal( μ , σ ) i
DataCamp Hierarchical and Mixed Effects Models in R R syntax library(lme4) lmer( y ~ x + (1|randomGroup), data = myData) lmer( y ~ x + (randomSlope|randomGroup), data = myData)
DataCamp Hierarchical and Mixed Effects Models in R HIERARCHICAL AND MIXED EFFECTS MODELS IN R Let's practice!
DataCamp Hierarchical and Mixed Effects Models in R HIERARCHICAL AND MIXED EFFECTS MODELS IN R School data Richard Erickson Quantitative Ecologist
DataCamp Hierarchical and Mixed Effects Models in R Data questions 1. Does the sex of a student impact their knowledge gain? 2. Does the teacher's training impact the gain and does the teacher's math knowledge impact the gain?
DataCamp Hierarchical and Mixed Effects Models in R HIERARCHICAL AND MIXED EFFECTS MODELS IN R Let's practice!
Recommend
More recommend