class: middle, title background-size: contain <br><br> # An Introduction to Structural Equation Modelling in R <br><br> **Dr. Calum Webb**<br> Sheffield Methods Institute, the University of Sheffield<br> [c.j.webb@sheffield.ac.uk](mailto:c.j.webb@sheffield.ac.uk)
--- class: middle .middle-left[ ## Why Structural Equation Modelling? * How can I express a more complex relationship between variables than "X causes Y"? * How can I combine several indicators of complex social science contexts (e.g. deprivation, poverty, anxiety, stress, concern, social capital) into a single, justifiable, indicator? * How can I assess whether my combined measures are reliable (generalisable beyond a specific sample or to other groups) and valid (a reasonably good and precise measure of what they purport to measure)? ] .pull-right[ <br> <img src="images/icons8-network.svg" width="60%" height="30%" style="display: block; margin: auto;" /> ] --- class: inverse, middle .pull-left-big[ ## During this training course, you will be playing the role of researchers exploring the relationship between family's monetary investment on their children, the degree of parental stress they report, and children's wellbeing and educational outcomes. * Load up RStudio and the [repository](https://github.com/cjrwebb/sem-pgrt) you should have downloaded in advance. ] .middle-right-small[ <br> <img src="images/icons8-view.svg" width="70%" height="30%" style="display: block; margin: auto;" /> ] --- class: inverse, middle .middle-left-big[ <br> # Part 1: Path analysis and graphical models It all started with some guinea pigs... ] .pull-right-small[ <img src="images/icons8-guinea_pig.svg" width="70%" height="30%" style="display: block; margin: auto;" /> ] --- background-color: white class: middle .middle-left[ ## Path analysis/graphical models **Structural Equation Modelling** is a family of techniques, rather than a single method. At its most simple, a structural equation model is a multivariate model (multiple outcome/dependent variables) made up of several regressions or correlations between variables. * Implies a causal relationship/pathway (useful to justify using some of the 'new science of causality' methods, Pearl, Glymour, & Jewell, 2016) * Can be cyclical, but usually *acyclic* (Lipsky & Greenland, 2022) ] .pull-right[ <div class="figure" style="text-align: center"> <img src="images/wright-model.png" alt="Sewell Wright's (1920) first published use of a causal graphical model" width="90%" /> <p class="caption">Sewell Wright's (1920) first published use of a causal graphical model</p> </div> ] --- background-color: white class: middle .middle-left[ ## Path analysis/graphical models ``` O ~ D + H + E O' ~ D + H' + E H ~ G + G'' H' ~ G' + G''' G ~ H'' + Chance G' ~ H'' + Chance G'' ~ H''' + Chance G''' ~ H''' + Chance Sire ~ D + E + H'' Dam ~ H''' + E + D ``` ] .pull-right[ <div class="figure" style="text-align: center"> <img src="images/wright-model.png" alt="Sewell Wright's (1920) first published use of a causal graphical model" width="90%" /> <p class="caption">Sewell Wright's (1920) first published use of a causal graphical model</p> </div> ] --- class: inverse, middle .middle-left-big[ <br> # Part 1: Path analysis and graphical models: Practical Exploring the relationship between family income, family investment, parental stress, and children's outcomes using lavaan in R. ] .pull-right-small[ <img src="images/icons8-guinea_pig.svg" width="70%" height="30%" style="display: block; margin: auto;" /> ] --- class: inverse, middle .middle-left-big[ <br> # Part 1: Path Analysis Summary * Diagrams of the structured relationships can be converted into a structured set of equations to express more complicated relationships between variables * In lavaan syntax, a regression is defined using the ~ operator * The indirect effect of variables via other variables (mediators) can be estimated by taking the product of the paths between the variables * Paths can be labelled in lavaan syntax using the pattern label\* * Derived parameters, e.g. the product of two paths or the sum of indirect and direct paths, can be defined using the := operator * Binary categorical or ordinal outcomes can be predicted using a probit link using the "ordered =" argument in lavaan::sem() ] .pull-right-small[ <img src="images/icons8-guinea_pig.svg" width="70%" height="30%" style="display: block; margin: auto;" /> ] --- class: inverse, middle .middle-left-big[ <br> # Part 2: Latent variables and confirmatory factor analysis It's the 1500s and you are an astronomer... ] .pull-right-small[ <img src="images/icons8-constellation.svg" width="90%" height="30%" style="display: block; margin: auto;" /> ] ??? In the 16th century, the quality of observations of stars in astronomy would tend to be based on judgements about the quality of the equipment used, as well as the quality of the person doing the measurement (was the astronomer who took the measurements a good mate of yours?) However, Henry Gellibrand later realised in 1635 that you could gain more information by throwing information away: by combining multiple measurements and taking their average, you could minimize the impact of any given measurement's error on the actual estimate. Latent factors are designed to minimise the impact of "error" on any specific way of measuring an abstract concept. --- class: middle .middle-left[ ## What is a latent factor? Often in quantitative social science research we are trying to measure **underlying constructs**, for example: attitudes, beliefs, stati, constructions of identity, and so on. We will typically **operationalise** these constructs/concepts into variables, e.g. poverty is income less than 60% of the median household income. We might call these 'indicators' of concepts. But any one of these indicators will have some "error" or some "mixture" of other concepts, e.g. fear for safety may indicate both perceptions of risk and levels of anxiety. Latent factors are constructed based on the **commonality** across multiple indicators. The underlying latent factor is said to simultaneously predict values across all indicators. The commonality is kept, the 'error' or variance capturing other constructs is separated. ] .pull-right[ <img src="images/icons8-venn_diagram.svg" width="90%" style="display: block; margin: auto;" /> ] --- class: middle .middle-left[ ## Anatomy of a latent variable Features of latent variables include: * **A set of indicator/manifest variables**: in general, a latent factor should only be constructed from a minimum of three manifest or indicator variables. * **Factor loadings**: the extent to which the latent factor linearly predicts the indicator/manifest variables. On a standardised scale, this can be interpreted like a correlation, the higher the factor loading, the more precisely the indicator measures the underlying factor. * **Model fit**: the extent to which modelling the data as one or a set of latent factors can reproduce the underlying variance/covariance structure of the data. Better model fit means the number of factors and their assignment is an appropriate fit to the data, and this can be the case even if factor loadings are poor. ] .pull-right[ <img src="images/icons8-venn_diagram.svg" width="90%" style="display: block; margin: auto;" /> ] --- class: middle .middle-left[ <br> ## Two flavour of factor analysis * **Exploratory Factor Analysis (EFA)** employs the use of various criterion and algorithms to atheoretically assign manifest variables to factors. *Not covered in this course*, but what we learn about factor loadings and model fit is applicable. * **Confirmatory Factor Analysis (CFA)** is the application of *a priori* theory to the factor structure across manifest variables to assess the extent to which a single or multiple factors 'load onto' these indicators. Factor analysis **is not** principal components analysis (PCA) (Mazziotta and Pareto, 2021). While they share similarities, in PCA, the composite index is *caused by* changes in the indicators, in latent variables the latent construct *causes* changes in the indicators. ] .pull-right[ <img src="images/icons8-venn_diagram.svg" width="90%" style="display: block; margin: auto;" /> ] ??? When might you want to use PCA over Factor Analysis? For example, poor air quality might be suitable for PCA whereas for a latent factor it may be interpreted more as poor environmental management. In many cases the practical applications are the same, but the choice of indicators may differ substantially. A good example: if one your indicators increases, your PCA index *must* increase. If your latent factor increases, then your manifest indicators increase *on average*. --- class: middle .middle-left[ <br> ## Confirmatory factor analysis in lavaan syntax ``` # Unstandardised lv =~ mv1 + mv2 + mv3 + mv4 + mv5 ``` ``` # Standardised lv =~ NA*mv1 + mv2 + mv3 + mv4 + mv5 lv ~~ 1*lv ``` ] .pull-right[ <img src="images/icons8-venn_diagram.svg" width="90%" style="display: block; margin: auto;" /> ] --- class: inverse, middle .middle-left-big[ <br> # Part 2: Confirmatory Factor Analysis: Practical Constructing a latent factor measuring parental stress. ] .pull-right-small[ <img src="images/icons8-constellation.svg" width="70%" height="30%" style="display: block; margin: auto;" /> ] --- class: inverse, middle .middle-left-big[ <br> # Part 2: Latent Variables Summary * Latent variables can be constructed to leverage the commonality across several indicators of a concept/construct to derive a variable that removes some of the measurement error found in any one indicator. * In lavaan syntax, a latent variable is defined using the =~ operator * Latent variables can be standardised using the special NA\* label in combination with the ~~1\*LV specification, or using the std.lv = TRUE argument * Latent variables are assessed using (usually standardised) factor loadings, which tell us how precise our indicators are for measuring that specific underlying factor and how much commonality they share with it, and model fit, which tells us how well our factor solution (how many factors and which variables they are loaded on) fits the data. * Ordinal or binary variables can be included as factor indicators in the same way as usual. ] .pull-right-small[ <img src="images/icons8-constellation.svg" width="70%" height="30%" style="display: block; margin: auto;" /> ] --- class: inverse, middle .middle-left-big[ <br> # Part 3: Reliability & Validity of Factors You're a doctor, what indicators that you observe do you associate with a latent, unobservable illness? ] .pull-right-small[ <img src="images/icons8-bandage.svg" width="90%" height="30%" style="display: block; margin: auto;" /> ] ??? Imagine you're a dermatologist — a skin doctor — and you need to assess whether a patient has "medical condition A". "Medical condition A" is a latent construct or, at least, in diagnosis it is. It is unobservable in a patient observation. Instead, you have a number of indicators from your medical training and your medical textbooks: we can imagine these as variables. The redness of the skin; the degree of bruising; the presence of swelling; an increase in dark freckles or moles; pallidness of skin surrounding lesions. Adelekun, et al. (2020) found that only up to 18% of images documenting conditions in medical textbooks showed the presentation of the condition on darker skin tones. The indicators of many doctors, such as the ones listed above - in the mental latent factor of the skin condition - may not be suitable indicators for diagnosing a condition among a large swathe of the population. --- class: middle .middle-left[ ## What is reliability? **Reliability**, in the most general sense, refers to the extent to which we can perform the same actions and get the same, or very similar, results. Ask the same questions, get the same answers. Model the same latent factor, get the same results. In latent variables: * Do our questions relate to one another? Are they consistent with the construct? * If we are measuring an unchanging trait/concept, if we ask the same person/people the same questions at a different time, would they give similar answers? Would our underlying factor look similar as time changes? * How sensitive is our latent factor's composition to our specific sample and any choices we made in our research process? * How generalisable is our latent factor's construction across different groups? ] .pull-right[ <img src="images/icons8-diversity.svg" width="70%" style="display: block; margin: auto;" /> ] --- class: middle .middle-left[ ## What is validity? **Validity** generally refers to the extent to which our description of something *truly* describes what we are trying to describe. Is this really parental stress, or could it be something else? In latent variables: * Do others agree that our choice of manifest variables represent (in the majority) the underlying concept/construct? * Is our latent variable highly correlated with other latent variables based on different manifest variables intended to measure the same concept/construct? * Is our latent variable sufficiently distinct from related concepts? * Is our latent variable unrelated to, or inversely related to, things it should be unrelated to? ] .pull-right[ <img src="images/icons8-diversity.svg" width="70%" style="display: block; margin: auto;" /> ] --- class: middle .pull-left[ # Reliability * Model fit and assessment of factor loadings * Testing/validation or exploration/confirmation subsetting of data. * Multi-group invariance testing ] .pull-right[ # Validity * .grey[Consensual method indicators research (Walker, 1987)] * Concurrent validity through factor correlation * Convergent validity through factor correlation * Discriminant validity using Average Variance Extracted ] --- class: inverse, middle .middle-left-big[ <br> # Part 3: Reliability & Validity of Factors Practical How reliable and valid is our parental stress latent variable? ] .pull-right-small[ <img src="images/icons8-bandage.svg" width="90%" height="30%" style="display: block; margin: auto;" /> ] --- class: inverse, middle .middle-left-big[ <br> # Part 3: Reliability & Validity of Factors Summary * Reliability and validity testing is an oft neglected (outside of psychology) endeavor, but can lead to some really rich and critical research insights. SEM is well-suited for reliability and validity testing using latent factors. * Reliability and validity testing requires a range of different models and statistics, and usually involves manipulating labels to be 'fixed' or 'freed': * Exploration/validation subsetting of data avoids the garden of forking paths. * Multigroup invariance testing: configural, metric, scalar, and strict invariance for identifying what elements of our factors precisely lack comparability across groups. * Average Variance Extracted, calculated manually or using semTools, and factor correlations to explore concurrent, convergent, and discriminant validity. ] .pull-right-small[ <img src="images/icons8-bandage.svg" width="90%" height="30%" style="display: block; margin: auto;" /> ] --- class: middle .middle-left[ ## What else can be done in Structural Equation Modelling? * **Latent growth modelling** for measuring associations between linear and non-linear change over time * **Cross-lagged panel models, random intercepts cross lagged panel models, and latent curve models with structured residuals** for exploring differences in relationships between variance in traits, trends, time * **Bayesian Structural Equation Modelling** using `blavaan` * **Multilevel Structural Equation Modelling** using `lavaan` * *Most* things can be done in `lavaan` (free), but the really cutting-edge and niche things require Mplus (ehich can be run in `R` using the `Mplusautomation` package) ] .pull-right[ <img src="images/icons8-toolbox.svg" width="60%" style="display: block; margin: auto;" /> ] --- class: middle ### References Adelekun, A., Onyekaba, G., & Lipoff, J. B. (2021). Skin color in dermatology textbooks: an updated evaluation and analysis. Journal of the American Academy of Dermatology, 84(1), 194-196. Lipsky, A. M., & Greenland, S. (2022). Causal directed acyclic graphs. JAMA, 327(11), 1083-1084. Mazziotta and Pareto, 2021, “On the construction of composite indices by principal components analysis”, Rivista Italiana di Economia Demografia e Statistica, 70(1), 103-109. Pearl, J., Glymour, M., & Jewell, N. P. (2016). Causal inference in statistics: A primer. John Wiley & Sons. Walker, R. (1987). Consensual approaches to the definition of poverty: towards an alternative methodology. Journal of Social Policy, 16(2), 213-226. --- class: middle ### Further reading El-Sheikh, A. A., Abonazel, M. R., & Gamil, N. (2017). A review of software packages for structural equation modeling: A comparative study. Applied Mathematics and Physics, 5(3), 85-94. Gana, K., & Broc, G. (2019). Structural equation modeling with lavaan. John Wiley & Sons. Hoyle, R. H. (Ed.). (2023). Handbook of structural equation modelling 2nd ed. Guilford press. Kenny, D. A. (2015). Measuring model fit. https://davidakenny.net/cm/fit.htm Rosseel, Y., The Lavaan Project. (2023). Tutorial. lavaan.org: https://lavaan.ugent.be/tutorial/ Van de Schoot, R., Lugtig, P., & Hox, J. (2012). A checklist for testing measurement invariance. European journal of developmental psychology, 9(4), 486-492. **** Merkle, E. C., & Rosseel, Y. (2015). blavaan: Bayesian structural equation models via parameter expansion. arXiv preprint arXiv:1511.05604. Duncan, T. E., & Duncan, S. C. (2009). The ABC’s of LGM: An introductory guide to latent variable growth curve modeling. Social and personality psychology compass, 3(6), 979-991. Little, T. D. (2013). Longitudinal structural equation modeling. Guilford press.