Educational Statistics and Research Methods (ESRM) Program*
University of Arkansas
Published
October 9, 2024
Modified
October 11, 2024
1 Homework 2B
library(ESRM64503)library(kableExtra)library(tidyverse)library(DescTools) # Desc() allows you to quick screen datalibrary(lavaan) # Desc() allows you to quick screen data# options(digits = 3)head(dataMath)
id hsl cc use msc mas mse perf female
1 1 NA 9 44 55 39 NA 14 1
2 2 3 2 77 70 42 71 12 0
3 3 NA 12 64 52 31 NA NA 1
4 4 6 20 71 65 39 84 19 0
5 5 2 15 48 19 2 60 12 0
6 6 NA 15 61 62 42 87 18 0
dim(dataMath)
[1] 350 9
1.1 Homework 2B: Setup
1.2 Homework 2B: Model 1 - Correlation Model with MSE, HSL, and CC
lhs op rhs est.std se z pvalue ci.lower ci.upper
1 mse ~~ hsl 0.490 0.044 11.096 0.000 0.403 0.576
2 mse ~~ cc 0.252 0.054 4.646 0.000 0.146 0.358
3 hsl ~~ cc 0.156 0.055 2.860 0.004 0.049 0.263
For Mathematics Self-Efficacy (MSE) and High School Math Experience (HSL), there is a moderate but significantly positive correlation with r = 0.49 (SE = 0.044), p < .001
For Mathematics Self-Efficacy (MSE) and College Math Experience (CC), there is a strong and significantly positive correlation with r = 0.252 (SE = 0.054), p < .001
For High School Math Experience (HSL) and College Math Experience (CC), there is a weak and significantly positive correlation with r = 0.156 (SE = 0.055), p = .004
1.3 Homework 2B: Model 2 - constraining the correlation of HSL and CC to 0
lhs op rhs est.std se z pvalue ci.lower ci.upper
1 mse ~~ hsl 0.469 0.045 10.359 0 0.380 0.557
2 mse ~~ cc 0.190 0.054 3.512 0 0.084 0.296
3 hsl ~~ cc 0.000 0.000 NA NA 0.000 0.000
For Mathematics Self-Efficacy (MSE) and High School Math Experience (HSL), there is a moderate but significantly positive correlation with r = 0.469 (SE = 0.045), p < .001
For Mathematics Self-Efficacy (MSE) and College Math Experience (CC), there is a strong and significantly positive correlation with r = 0.19 (SE = 0.054), p < .001
For High School Math Experience (HSL) and College Math Experience (CC), there is a weak and significantly positive correlation with r = 0 (SE = 0), p = NA
Scaled Chi-Squared Difference Test (method = "satorra.bentler.2001")
lavaan->lavTestLRT():
lavaan NOTE: The "Chisq" column contains standard test statistics, not the
robust test that should be reported per model. A robust difference test is
a function of two standard (not robust) statistics.
Df AIC BIC Chisq Chisq diff Df diff Pr(>Chisq)
model01.fit 0 5445.7 5480.4 0.0000
model02.fit 1 5450.8 5481.7 7.1812 7.8104 1 0.005195 **
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
For Model 1, AIC = 5445.7 and BIC = 5480.4
For Model 2, AIC = 5450.8 and BIC = 5481.7
According to the criteria of lower AIC/BIC values indicating better model fit and the result of Likelihood ratio test (\chi^2(0, 1)= 7.8104, p < .001), we prefer model 1 as it has significantly better model fit than model 2.
---title: "Lecture 09: Path Analysis"subtitle: "Homework 2"author: "Jihong Zhang*, Ph.D"institute: | Educational Statistics and Research Methods (ESRM) Program* University of Arkansasdate: "2024-10-09"date-modified: "2024-10-11"sidebar: falseexecute: echo: true warning: falseoutput-location: defaultcode-annotations: belowhighlight-style: "nord"format: html: page-layout: full toc: true toc-depth: 2 toc-expand: true lightbox: true code-fold: false fig-align: centerfilters: - quarto - line-highlightbibliography: references.bib---# Homework 2B```{r}#| output-location: defaultlibrary(ESRM64503)library(kableExtra)library(tidyverse)library(DescTools) # Desc() allows you to quick screen datalibrary(lavaan) # Desc() allows you to quick screen data# options(digits = 3)head(dataMath)dim(dataMath)```## Homework 2B: Setup## Homework 2B: Model 1 - Correlation Model with MSE, HSL, and CC```{r}#| output-location: columnmodel01.syntax ="# Variances:mse ~~ mse hsl ~~ hsl cc ~~ cc# Covariance:mse ~~ hslmse ~~ cchsl ~~ cc# Means:mse ~ 1 hsl ~ 1 cc ~ 1 "## Estimation for model01model01.fit <-cfa(model01.syntax, data=dataMath, mimic="MPLUS", fixed.x =TRUE, estimator ="MLR") ## Print outputstandardizedsolution(model01.fit)## filter correlations among varaiblesoutput_mod1 <-standardizedsolution(model01.fit) |>filter(op =="~~", lhs != rhs)output_mod1```- For Mathematics Self-Efficacy (MSE) and High School Math Experience (HSL), there is a moderate but significantly positive correlation with r = `r round(output_mod1[1,4],3)` (SE = `r round(output_mod1[1,5],3)`), p < .001- For Mathematics Self-Efficacy (MSE) and College Math Experience (CC), there is a strong and significantly positive correlation with r = `r round(output_mod1[2,4],3)` (SE = `r round(output_mod1[2,5],3)`), p < .001- For High School Math Experience (HSL) and College Math Experience (CC), there is a weak and significantly positive correlation with r = `r round(output_mod1[3,4],3)` (SE = `r round(output_mod1[3,5],3)`), p = .004## Homework 2B: Model 2 - constraining the correlation of HSL and CC to 0```{r}model02.syntax ="# Variances:mse ~~ mse hsl ~~ hsl cc ~~ cc# Covariance:mse ~~ hslmse ~~ cchsl ~~ 0*cc# Means:mse ~ 1 hsl ~ 1 cc ~ 1 "model02.fit <-cfa(model02.syntax, data=dataMath, mimic="MPLUS", fixed.x =TRUE, estimator ="MLR") ## Print outputstandardizedsolution(model02.fit)output_mod2 <-standardizedsolution(model02.fit) |>filter(op =="~~", lhs != rhs)output_mod2```- For Mathematics Self-Efficacy (MSE) and High School Math Experience (HSL), there is a moderate but significantly positive correlation with r = `r round(output_mod2[1,4],3)` (SE = `r round(output_mod2[1,5],3)`), p < .001- For Mathematics Self-Efficacy (MSE) and College Math Experience (CC), there is a strong and significantly positive correlation with r = `r round(output_mod2[2,4],3)` (SE = `r round(output_mod2[2,5],3)`), p < .001- For High School Math Experience (HSL) and College Math Experience (CC), there is a weak and significantly positive correlation with r = `r round(output_mod2[3,4],3)` (SE = `r round(output_mod2[3,5],3)`), p = NA## Homework 2B: AIC and BIC```{r}#| eval: trueanova_output <-anova(model01.fit, model02.fit)anova_output```- For Model 1, AIC = `r round(anova_output$AIC[1],1)` and BIC = `r round(anova_output$BIC[1], 1)`- For Model 2, AIC = `r round(anova_output$AIC[2], 1)` and BIC = `r round(anova_output$BIC[2], 1)`- According to the criteria of lower AIC/BIC values indicating better model fit and the result of Likelihood ratio test ($\chi^2(0, 1)= 7.8104$, $p < .001$), we prefer model 1 as it has significantly better model fit than model 2.