|
1 | | -# Structural Equation Modeling |
| 1 | +# Structural Equation Modeling of Student Engagement |
2 | 2 |
|
3 | | -Project build in progress. |
| 3 | +[](https://github.com/mjeans/structural-equation-modeling/actions/workflows/validate.yml) |
| 4 | + |
| 5 | +An end-to-end R and `lavaan` case study connecting measurement quality to a structural model of student support, engagement, academic confidence, and later achievement. The project demonstrates confirmatory factor analysis, measurement invariance, full-information maximum likelihood, latent-variable mediation, model diagnostics, and careful interpretation. |
| 6 | + |
| 7 | +> All records are deterministic and synthetic. No student, school, district, or client data are included. |
| 8 | +
|
| 9 | + |
| 10 | + |
| 11 | +## Research question |
| 12 | + |
| 13 | +How are perceived support, student engagement, and academic confidence associated with later achievement after accounting for baseline performance and grade band—and is the measurement structure sufficiently comparable across middle- and high-school students to support group comparisons? |
| 14 | + |
| 15 | +The workflow separates that question into two stages: |
| 16 | + |
| 17 | +1. **Measurement:** Do 11 survey indicators represent three distinct latent constructs, and do the loadings and intercepts operate similarly across grade bands? |
| 18 | +2. **Structure:** Are support, engagement, confidence, and follow-up achievement connected through the prespecified direct and indirect pathways? |
| 19 | + |
| 20 | +## Verified reference results |
| 21 | + |
| 22 | +GitHub Actions regenerates the complete 2,400-record dataset and executes every model and test. The validated reference run produced: |
| 23 | + |
| 24 | +| Analysis | CFI | TLI | RMSEA | SRMR | |
| 25 | +|---|---:|---:|---:|---:| |
| 26 | +| Three-factor pooled CFA | 0.998 | 0.997 | 0.015 | 0.012 | |
| 27 | +| Structural equation model | 0.998 | 0.998 | 0.013 | 0.015 | |
| 28 | + |
| 29 | +The scalar-invariance step changed CFI and RMSEA by less than 0.001. The serial indirect association from support through engagement and confidence to follow-up achievement was 1.184 (`p < .001`). Diagnostics examined 17 residual variances, found no negative variances, and retained one modification index above 10 for transparent review rather than automatically respecifying the model. |
| 30 | + |
| 31 | +The excellent fit is expected because the synthetic data were generated from the prespecified structure. It demonstrates correct implementation and recovery under known conditions; it is not evidence that comparable fit should be expected in real data. |
| 32 | + |
| 33 | +## What the project demonstrates |
| 34 | + |
| 35 | +- Three-factor confirmatory factor analysis with robust maximum likelihood |
| 36 | +- Configural, metric, and scalar measurement-invariance testing |
| 37 | +- Model comparison using changes in CFI and RMSEA rather than chi-square alone |
| 38 | +- Full-information maximum likelihood for incomplete continuous indicators |
| 39 | +- Composite reliability and average variance extracted |
| 40 | +- A latent-variable structural model with serial and specific indirect effects |
| 41 | +- Baseline and grade-band covariate adjustment |
| 42 | +- Standardized path estimates, confidence intervals, and explained variance |
| 43 | +- Residual-variance and modification-index diagnostics |
| 44 | +- Deterministic synthetic data, automated tests, and GitHub Actions |
| 45 | +- Explicit separation of statistical association from causal interpretation |
| 46 | + |
| 47 | +## Measurement model |
| 48 | + |
| 49 | + |
| 50 | + |
| 51 | +The prespecified model includes: |
| 52 | + |
| 53 | +- **Support:** four indicators of relational and instructional support |
| 54 | +- **Engagement:** four indicators of behavioral and cognitive engagement |
| 55 | +- **Academic confidence:** three indicators of perceived academic capability |
| 56 | + |
| 57 | +The same factor structure is evaluated in middle- and high-school groups. Configural invariance tests the shared pattern, metric invariance constrains loadings, and scalar invariance additionally constrains intercepts. The decision rules flag a step when absolute CFI deterioration exceeds 0.010 or RMSEA increases by more than 0.015. |
| 58 | + |
| 59 | +## Structural model |
| 60 | + |
| 61 | +The final model estimates: |
| 62 | + |
| 63 | +- support → engagement |
| 64 | +- support and engagement → academic confidence |
| 65 | +- support, engagement, and confidence → follow-up achievement |
| 66 | +- baseline performance and grade band as observed covariates |
| 67 | +- support’s specific and serial indirect associations with achievement |
| 68 | + |
| 69 | +The serial indirect path is `support → engagement → confidence → follow-up achievement`. Bootstrap language is intentionally avoided because the reference workflow uses robust maximum-likelihood standard errors; the project reports model-based confidence intervals and labels that distinction clearly. |
| 70 | + |
| 71 | +## Repository map |
| 72 | + |
| 73 | +```text |
| 74 | +R/ Synthetic data generation and reusable SEM reporting helpers |
| 75 | +scripts/ Data, CFA/invariance, SEM, and diagnostic entry points |
| 76 | +config/ Prespecified measurement and structural models |
| 77 | +tests/ Reproducibility, fit, invariance, mediation, and solution checks |
| 78 | +docs/ Analysis plan, model card, data dictionary, and decision memo |
| 79 | +assets/ Measurement and structural model diagrams |
| 80 | +outputs/ Documentation for reproducibly generated result tables |
| 81 | +.github/ Continuous-integration workflow |
| 82 | +``` |
| 83 | + |
| 84 | +## Reproduce the analysis |
| 85 | + |
| 86 | +R and `lavaan` are the only requirements. |
| 87 | + |
| 88 | +```bash |
| 89 | +install.packages("lavaan") |
| 90 | +make all |
| 91 | +``` |
| 92 | + |
| 93 | +Or run the stages separately: |
| 94 | + |
| 95 | +```bash |
| 96 | +Rscript scripts/01_generate_data.R |
| 97 | +Rscript scripts/02_measurement_models.R |
| 98 | +Rscript scripts/03_structural_model.R |
| 99 | +Rscript scripts/04_diagnostics.R |
| 100 | +Rscript tests/test_pipeline.R |
| 101 | +``` |
| 102 | + |
| 103 | +Generated record-level data, fitted model objects, and result tables are ignored by Git. The scripts regenerate them deterministically, and continuous integration executes the entire workflow on every pull request. |
| 104 | + |
| 105 | +## Interpretation boundary |
| 106 | + |
| 107 | +The structural paths are conditional associations within a synthetic cross-sectional measurement design with a later observed outcome. Model fit does not prove the model is true, establish temporal ordering among the latent constructs, eliminate omitted-variable bias, or identify causal effects. A real application would require instrument validation, sampling and clustering review, preregistration where appropriate, sensitivity analyses, and replication in an independent cohort. |
| 108 | + |
| 109 | +See the [analysis plan](docs/analysis-plan.md), [model card](docs/model-card.md), [data dictionary](docs/data-dictionary.md), and [decision memo](docs/decision-memo.md). |
| 110 | + |
| 111 | +Built as a public portfolio demonstration by [Matthew Jeans, PhD](https://github.com/mjeans). |
0 commit comments