setwd(mypath)
dat <- read.table("APIM_exercise_data.txt", sep = "\t", header = F)
colnames(dat) <- c("momperc1", "momperc2", "kidach1", "kidach2")
apim_mod <- '
momperc2 ~ a1*momperc1 + p21*kidach1
kidach2 ~ a2*kidach1 + p12*momperc1
momperc1 ~~ kidach1
momperc2 ~~ kidach2
# MODEL CONSTRAINTS
a1a2 := a1 - a2
p12p21 := p12 - p21
a1p21 := a1 - p21
a2p12 := a2 - p12
a1p12 := a1 - p12
a2p21 := a2 - p21
'
apim_fit <- sem(apim_mod, data = dat)
summary(apim_fit, fit.measures = T, standardized = T)
## lavaan 0.6.15 ended normally after 36 iterations
##
## Estimator ML
## Optimization method NLMINB
## Number of model parameters 10
##
## Number of observations 170
##
## Model Test User Model:
##
## Test statistic 0.000
## Degrees of freedom 0
##
## Model Test Baseline Model:
##
## Test statistic 347.312
## Degrees of freedom 6
## P-value 0.000
##
## User Model versus Baseline Model:
##
## Comparative Fit Index (CFI) 1.000
## Tucker-Lewis Index (TLI) 1.000
##
## Loglikelihood and Information Criteria:
##
## Loglikelihood user model (H0) -1902.349
## Loglikelihood unrestricted model (H1) -1902.349
##
## Akaike (AIC) 3824.697
## Bayesian (BIC) 3856.055
## Sample-size adjusted Bayesian (SABIC) 3824.392
##
## Root Mean Square Error of Approximation:
##
## RMSEA 0.000
## 90 Percent confidence interval - lower 0.000
## 90 Percent confidence interval - upper 0.000
## P-value H_0: RMSEA <= 0.050 NA
## P-value H_0: RMSEA >= 0.080 NA
##
## Standardized Root Mean Square Residual:
##
## SRMR 0.000
##
## Parameter Estimates:
##
## Standard errors Standard
## Information Expected
## Information saturated (h1) model Structured
##
## Regressions:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## momperc2 ~
## momperc1 (a1) 0.569 0.058 9.887 0.000 0.569 0.622
## kidach1 (p21) 0.223 0.083 2.700 0.007 0.223 0.170
## kidach2 ~
## kidach1 (a2) 0.550 0.054 10.097 0.000 0.550 0.602
## momperc1 (p12) 0.154 0.038 4.040 0.000 0.154 0.241
##
## Covariances:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## momperc1 ~~
## kidach1 15.818 2.514 6.292 0.000 15.818 0.551
## .momperc2 ~~
## .kidach2 2.484 0.839 2.960 0.003 2.484 0.233
##
## Variances:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## .momperc2 16.133 1.750 9.220 0.000 16.133 0.468
## .kidach2 7.038 0.763 9.220 0.000 7.038 0.420
## momperc1 41.176 4.466 9.220 0.000 41.176 1.000
## kidach1 20.018 2.171 9.220 0.000 20.018 1.000
##
## Defined Parameters:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## a1a2 0.019 0.084 0.220 0.826 0.019 0.020
## p12p21 -0.069 0.095 -0.728 0.467 -0.069 0.071
## a1p21 0.346 0.124 2.793 0.005 0.346 0.452
## a2p12 0.397 0.082 4.849 0.000 0.397 0.361
## a1p12 0.415 0.061 6.796 0.000 0.415 0.381
## a2p21 0.327 0.088 3.736 0.000 0.327 0.432
© Copyright 2024
@Yi Feng
and
@Gregory R. Hancock.