Data Analysis for Psychology in R 3
Psychology, PPLS
University of Edinburgh
stuff beyond here definitely won’t be in any assessment for DAPR3
SEM models generally have:
It all gets estimated at once!
# measurement model
Y =~ y1 + y2 + y3 + ...
X =~ x1 + x2 + x3 + ...
# regressions
Y ~ X + Z
# covariances
X ~~ Z

“Nomological Net”
Do things correlate with other things we expect them to correlate with?
Good for assessing if our measure is measuring the thing we want it to measure!
# measurement model
F1 =~ y1 + y2 + y3 + ...
F2 =~ x1 + x2 + x3 + ...
F3 =~ w1 + w2 + w3 + ...
# latent variable covariances
F1 ~~ F2
F1 ~~ F3
F2 ~~ F3
Measurement Invariance
Do factor loadings differ between groups/timepoints/contexts?
model <- "F1 =~ y1 + y2 + y3 + ..."
m1 <- cfa(model, data, group = "mygroups")
m2 <- cfa(model, data, group = "mygroups",
group.equal = "loadings")
semTools::compareFit(m1,m2)
Mediation
How much of X -> Y is because of X -> M and M -> Y?
model <- "
Y ~ a*M + c*X
M ~ b*X
indirect := a*b
direct := c
"
sem(model, data)
⚠ mediation is almost always incredibly problematic. Many people will (possibly correctly) dismiss it altogether as useless because confounding is everywhere.
Cross-sectional observational mediation is even worse (“three correlations in a trenchcoat”1)
Latent Growth Curves
The same as lmer(Y ~ TimePoint + (1 + TimePoint | Person))
model <- "
int =~ 1*Time1 + 1*Time2 + 1*Time3 + ...
slope =~ 0*Time1 + 1*Time2 + 2*Time3 + ...
int ~~ slope
"
growth(model, data)

The idea of SEM originally is to build a model that reflects the theoretical data generating process
Too often, people force their data to a shape that fits with an off-the-shelf SEM structure
It’s far too easy to estimate SEM models and report ‘associations’ while remaining blind to the strict causal assumptions required to give those paths real-world meaning
to estimate the “effect of X on Y”, we need to isolate the flow of information from X to Y, along only the path(s) we are interested in.
most common interpretation of “effect of X on Y”: what happens to Y when X changes?
diagrams can help us figure out what to control for (and what not to control for)
can help you consider (and be transparent about) limitations
quite often…
ask a question that is at least implicitly causal
do analysis, controlling for some stuff (often without clearly discussing why)
report “associations”
draw implicitly causal conclusions
emphasise everything is just correlations so can’t make any causal conclusions, to maintain plausible deniability
Descriptive Qs
if so, we probably don’t want to control for other things.
Causal Qs
we want to control for the things that allow us to get an unbiased estimate of what would happen to an observation’s Y value if its X value changed.
Implicitly Causal Qs
Associational Qs
