For introduction to RI-CLPM see: (Hamaker, Kuiper, and Grasman 2015)
Download Hamaker2015.pdf
For extensions of the RI-CLPM see: (Mulder and Hamaker 2020)
Download Mulder2020.pdf
Below you can find the code for installing and loading the required package lavaan
(Rosseel 2012), as well as for reading in the data for the Random Intercept Cross-Lagged Panel Model (RI-CLPM) and its 3 extensions. You can specify the path to the data yourself, or through a menu by using the file.choose()
-function. You can download the simulated example datasets here.
Download the liss dataset here:
Download lisscd_riclpm_testdata.Rdata
# If necessary, install the 'Lavaan' package.
# install.packages('lavaan', dependencies = T)
# Load the required packages.
rm(list=ls())
require(lavaan)
# Load in the data.
## Traditional RI-CLPM
dat <- read.table("data/RICLPM.dat",
col.names = c("x1", "x2", "x3", "x4", "x5", "y1", "y2", "y3", "y4", "y5"))
## Extension 1
datZ <- read.table("data/RICLPM-Z.dat",
col.names = c("x1", "x2", "x3", "x4", "x5", "y1", "y2", "y3", "y4", "y5", "z2", "z1"))
## Extension 2
datMG <- read.table("data/RICLPM-MG.dat",
col.names = c("x1", "x2", "x3", "x4", "x5", "y1", "y2", "y3", "y4", "y5", "G"))
## Extension 3
datMI <- read.table("data/RICLPM-MI.dat",
col.names = c("x11", "x12", "x13",
"x21", "x22", "x23",
"x31", "x32", "x33",
"x41", "x42", "x43",
"x51", "x52", "x53",
"y11", "y12", "y13",
"y21", "y22", "y23",
"y31", "y32", "y33",
"y41", "y42", "y43",
"y51", "y52", "y53"))
load('data/lisscd_riclpm_testdata.Rdata')
# Een _ gevolgd door een cijfer geeft de survey wave aan. Een . gevolgd door een cijfer geeft de alter aan. Dus educalter_1.4 in de wide file betekent de opleiding van alter 4 in surveywave 1. Waarom deze volgorde en niet andersom? Nu kan je makkelijk van wide naar long omzetten en viceversa.
#data liss wide
datalw <- lisscdn_mlsem_wide
#select only respondents with no missing on dependent variable in the last 5 waves.
datalw <- datalw[complete.cases(cbind(datalw$eu_7,datalw$eu_8,datalw$eu_9,datalw$eu_10,datalw$eu_11)),]
To estimate the bias corrected means over time. Do we need/want to add the covariances between the latent factors?? We also assume local independence; the educational level of the confidants are independent given the ‘mean’ educational level of the CDN. Following a SNA perspective this is actually quite unlikely.
myModel <- '
#####################
# MEASUREMENT MODEL #
#####################
# Factor models for x at 5 waves (constrained).
FX1 =~ a*x11 + b*x12 + c*x13
FX2 =~ a*x21 + b*x22 + c*x23
FX3 =~ a*x31 + b*x32 + c*x33
FX4 =~ a*x41 + b*x42 + c*x43
FX5 =~ a*x51 + b*x52 + c*x53
# Factor models for y at 5 waves (constrained).
FY1 =~ d*y11 + e*y12 + f*y13
FY2 =~ d*y21 + e*y22 + f*y23
FY3 =~ d*y31 + e*y32 + f*y33
FY4 =~ d*y41 + e*y42 + f*y43
FY5 =~ d*y51 + e*y52 + f*y53
# Constrained intercepts over time (this is necessary for strong factorial
# invariance; without these contraints we have week factorial invariance).
x11 + x21 + x31 + x41 + x51 ~ g*1
x12 + x22 + x32 + x42 + x52 ~ h*1
x13 + x23 + x33 + x43 + x53 ~ i*1
y11 + y21 + y31 + y41 + y51 ~ j*1
y12 + y22 + y32 + y42 + y52 ~ k*1
y13 + y23 + y33 + y43 + y53 ~ l*1
# Free latent means from t = 2 onward (only do this in combination with the
# constraints on the intercepts; without these, this would not be specified).
# I DONT UNDERSTAND THIS. IF YOU HAVE CONSTRAINED INTERCEPTS AND CONSTRAINED FACTOR LOADINGS YOU WILL GET SIMILAR MEANS??!!
# NO THIS IS NOT HOW IT WORKS IN SEM. IF YOU INCLUDE INTERCEPTS ONLY DEVIATIONS FROM THIS INTERCEPT PREDICT THE FACTOR LOADINGS.
# YOU ALSO SEE THIS IN THE RESULTS. INCLUDING INTERCEPTS LEADS TO SIMILAR MEANS ACROSS FX. CONSTRAINING ALLOWS FOR CHANGING MEANS.
FX2 + FX3 + FX4 + FX5 + FY2 + FY3 + FY4 + FY5 ~ 1
'
RICLPM5.ext3.fit <- cfa(myModel, data = datMI, missing = 'ML')
# WHY WOULD WE WANT TO INCLUDE ALL VARIANCES AND COVARIANCES BETWEEN FACTORS??
summary(RICLPM5.ext3.fit, standardized = T)
#> lavaan 0.6-7 ended normally after 122 iterations
#>
#> Estimator ML
#> Optimization method NLMINB
#> Number of free parameters 143
#> Number of equality constraints 40
#>
#> Number of observations 1189
#> Number of missing patterns 1
#>
#> Model Test User Model:
#>
#> Test statistic 368.981
#> Degrees of freedom 392
#> P-value (Chi-square) 0.792
#>
#> Parameter Estimates:
#>
#> Standard errors Standard
#> Information Observed
#> Observed information based on Hessian
#>
#> Latent Variables:
#> Estimate Std.Err z-value P(>|z|) Std.lv Std.all
#> FX1 =~
#> x11 (a) 1.000 0.293 0.390
#> x12 (b) 0.842 0.098 8.577 0.000 0.247 0.316
#> x13 (c) 0.778 0.091 8.571 0.000 0.228 0.308
#> FX2 =~
#> x21 (a) 1.000 0.219 0.301
#> x22 (b) 0.842 0.098 8.577 0.000 0.184 0.248
#> x23 (c) 0.778 0.091 8.571 0.000 0.170 0.238
#> FX3 =~
#> x31 (a) 1.000 0.247 0.349
#> x32 (b) 0.842 0.098 8.577 0.000 0.208 0.291
#> x33 (c) 0.778 0.091 8.571 0.000 0.192 0.253
#> FX4 =~
#> x41 (a) 1.000 0.267 0.354
#> x42 (b) 0.842 0.098 8.577 0.000 0.225 0.302
#> x43 (c) 0.778 0.091 8.571 0.000 0.208 0.276
#> FX5 =~
#> x51 (a) 1.000 0.236 0.319
#> x52 (b) 0.842 0.098 8.577 0.000 0.199 0.265
#> x53 (c) 0.778 0.091 8.571 0.000 0.184 0.250
#> FY1 =~
#> y11 (d) 1.000 0.291 0.373
#> y12 (e) 1.125 0.082 13.746 0.000 0.327 0.417
#> y13 (f) 1.130 0.080 14.163 0.000 0.329 0.425
#> FY2 =~
#> y21 (d) 1.000 0.316 0.410
#> y22 (e) 1.125 0.082 13.746 0.000 0.356 0.477
#> y23 (f) 1.130 0.080 14.163 0.000 0.357 0.442
#> FY3 =~
#> y31 (d) 1.000 0.267 0.353
#> y32 (e) 1.125 0.082 13.746 0.000 0.301 0.382
#> y33 (f) 1.130 0.080 14.163 0.000 0.302 0.380
#> FY4 =~
#> y41 (d) 1.000 0.295 0.376
#> y42 (e) 1.125 0.082 13.746 0.000 0.332 0.429
#> y43 (f) 1.130 0.080 14.163 0.000 0.334 0.434
#> FY5 =~
#> y51 (d) 1.000 0.310 0.398
#> y52 (e) 1.125 0.082 13.746 0.000 0.349 0.440
#> y53 (f) 1.130 0.080 14.163 0.000 0.350 0.453
#>
#> Covariances:
#> Estimate Std.Err z-value P(>|z|) Std.lv Std.all
#> FX1 ~~
#> FX2 0.034 0.009 3.684 0.000 0.532 0.532
#> FX3 0.019 0.008 2.321 0.020 0.269 0.269
#> FX4 0.019 0.009 2.182 0.029 0.249 0.249
#> FX5 0.008 0.008 1.007 0.314 0.122 0.122
#> FY1 0.007 0.008 0.959 0.338 0.086 0.086
#> FY2 0.019 0.008 2.361 0.018 0.201 0.201
#> FY3 0.013 0.008 1.769 0.077 0.171 0.171
#> FY4 0.024 0.008 3.017 0.003 0.275 0.275
#> FY5 0.006 0.008 0.811 0.417 0.070 0.070
#> FX2 ~~
#> FX3 0.026 0.008 3.159 0.002 0.483 0.483
#> FX4 0.020 0.008 2.482 0.013 0.350 0.350
#> FX5 0.012 0.008 1.502 0.133 0.234 0.234
#> FY1 -0.000 0.007 -0.014 0.989 -0.002 -0.002
#> FY2 0.006 0.007 0.898 0.369 0.093 0.093
#> FY3 0.021 0.007 2.955 0.003 0.360 0.360
#> FY4 0.024 0.007 3.323 0.001 0.375 0.375
#> FY5 0.019 0.007 2.577 0.010 0.279 0.279
#> FX3 ~~
#> FX4 0.037 0.009 3.914 0.000 0.558 0.558
#> FX5 0.021 0.009 2.430 0.015 0.358 0.358
#> FY1 0.016 0.007 2.226 0.026 0.223 0.223
#> FY2 0.001 0.007 0.160 0.873 0.015 0.015
#> FY3 0.015 0.007 2.102 0.036 0.226 0.226
#> FY4 0.009 0.007 1.327 0.185 0.130 0.130
#> FY5 0.019 0.007 2.558 0.011 0.248 0.248
#> FX4 ~~
#> FX5 0.025 0.009 2.828 0.005 0.399 0.399
#> FY1 0.020 0.008 2.649 0.008 0.258 0.258
#> FY2 0.009 0.008 1.248 0.212 0.112 0.112
#> FY3 0.017 0.007 2.254 0.024 0.233 0.233
#> FY4 0.014 0.008 1.872 0.061 0.178 0.178
#> FY5 0.019 0.008 2.404 0.016 0.225 0.225
#> FX5 ~~
#> FY1 0.013 0.007 1.807 0.071 0.192 0.192
#> FY2 0.003 0.007 0.427 0.669 0.042 0.042
#> FY3 0.021 0.007 2.849 0.004 0.328 0.328
#> FY4 0.014 0.007 1.893 0.058 0.200 0.200
#> FY5 0.019 0.007 2.501 0.012 0.255 0.255
#> FY1 ~~
#> FY2 0.036 0.008 4.795 0.000 0.394 0.394
#> FY3 0.024 0.007 3.456 0.001 0.309 0.309
#> FY4 0.026 0.007 3.733 0.000 0.306 0.306
#> FY5 0.020 0.007 2.890 0.004 0.224 0.224
#> FY2 ~~
#> FY3 0.052 0.008 6.152 0.000 0.611 0.611
#> FY4 0.046 0.008 5.832 0.000 0.488 0.488
#> FY5 0.029 0.008 3.875 0.000 0.299 0.299
#> FY3 ~~
#> FY4 0.052 0.008 6.408 0.000 0.657 0.657
#> FY5 0.039 0.008 5.078 0.000 0.469 0.469
#> FY4 ~~
#> FY5 0.050 0.008 5.924 0.000 0.543 0.543
#>
#> Intercepts:
#> Estimate Std.Err z-value P(>|z|) Std.lv Std.all
#> .x11 (g) 0.272 0.018 15.091 0.000 0.272 0.362
#> .x21 (g) 0.272 0.018 15.091 0.000 0.272 0.375
#> .x31 (g) 0.272 0.018 15.091 0.000 0.272 0.384
#> .x41 (g) 0.272 0.018 15.091 0.000 0.272 0.360
#> .x51 (g) 0.272 0.018 15.091 0.000 0.272 0.368
#> .x12 (h) 0.253 0.017 15.141 0.000 0.253 0.324
#> .x22 (h) 0.253 0.017 15.141 0.000 0.253 0.340
#> .x32 (h) 0.253 0.017 15.141 0.000 0.253 0.353
#> .x42 (h) 0.253 0.017 15.141 0.000 0.253 0.339
#> .x52 (h) 0.253 0.017 15.141 0.000 0.253 0.337
#> .x13 (i) 0.268 0.016 16.836 0.000 0.268 0.363
#> .x23 (i) 0.268 0.016 16.836 0.000 0.268 0.376
#> .x33 (i) 0.268 0.016 16.836 0.000 0.268 0.353
#> .x43 (i) 0.268 0.016 16.836 0.000 0.268 0.356
#> .x53 (i) 0.268 0.016 16.836 0.000 0.268 0.365
#> .y11 (j) 0.324 0.016 20.302 0.000 0.324 0.416
#> .y21 (j) 0.324 0.016 20.302 0.000 0.324 0.421
#> .y31 (j) 0.324 0.016 20.302 0.000 0.324 0.428
#> .y41 (j) 0.324 0.016 20.302 0.000 0.324 0.413
#> .y51 (j) 0.324 0.016 20.302 0.000 0.324 0.417
#> .y12 (k) 0.331 0.017 19.180 0.000 0.331 0.422
#> .y22 (k) 0.331 0.017 19.180 0.000 0.331 0.445
#> .y32 (k) 0.331 0.017 19.180 0.000 0.331 0.421
#> .y42 (k) 0.331 0.017 19.180 0.000 0.331 0.427
#> .y52 (k) 0.331 0.017 19.180 0.000 0.331 0.418
#> .y13 (l) 0.325 0.017 18.799 0.000 0.325 0.421
#> .y23 (l) 0.325 0.017 18.799 0.000 0.325 0.402
#> .y33 (l) 0.325 0.017 18.799 0.000 0.325 0.409
#> .y43 (l) 0.325 0.017 18.799 0.000 0.325 0.422
#> .y53 (l) 0.325 0.017 18.799 0.000 0.325 0.420
#> FX2 -0.077 0.021 -3.731 0.000 -0.354 -0.354
#> FX3 -0.074 0.022 -3.425 0.001 -0.298 -0.298
#> FX4 -0.158 0.023 -6.781 0.000 -0.591 -0.591
#> FX5 -0.180 0.024 -7.577 0.000 -0.762 -0.762
#> FY2 0.034 0.018 1.898 0.058 0.109 0.109
#> FY3 0.016 0.018 0.897 0.370 0.062 0.062
#> FY4 0.048 0.019 2.595 0.009 0.163 0.163
#> FY5 0.053 0.019 2.771 0.006 0.170 0.170
#> FX1 0.000 0.000 0.000
#> FY1 0.000 0.000 0.000
#>
#> Variances:
#> Estimate Std.Err z-value P(>|z|) Std.lv Std.all
#> .x11 0.478 0.026 18.514 0.000 0.478 0.848
#> .x12 0.549 0.026 21.013 0.000 0.549 0.900
#> .x13 0.494 0.023 21.379 0.000 0.494 0.905
#> .x21 0.480 0.024 20.148 0.000 0.480 0.909
#> .x22 0.519 0.024 22.042 0.000 0.519 0.939
#> .x23 0.480 0.022 22.252 0.000 0.480 0.943
#> .x31 0.440 0.023 19.102 0.000 0.440 0.878
#> .x32 0.469 0.022 21.244 0.000 0.469 0.915
#> .x33 0.539 0.024 22.545 0.000 0.539 0.936
#> .x41 0.499 0.025 19.750 0.000 0.499 0.875
#> .x42 0.506 0.024 21.230 0.000 0.506 0.909
#> .x43 0.524 0.024 21.600 0.000 0.524 0.924
#> .x51 0.491 0.025 19.541 0.000 0.491 0.898
#> .x52 0.523 0.024 21.840 0.000 0.523 0.930
#> .x53 0.505 0.023 21.978 0.000 0.505 0.937
#> .y11 0.522 0.025 21.148 0.000 0.522 0.861
#> .y12 0.509 0.025 19.959 0.000 0.509 0.826
#> .y13 0.488 0.025 19.419 0.000 0.488 0.819
#> .y21 0.494 0.024 20.897 0.000 0.494 0.832
#> .y22 0.428 0.023 18.918 0.000 0.428 0.772
#> .y23 0.525 0.026 20.092 0.000 0.525 0.804
#> .y31 0.502 0.023 21.595 0.000 0.502 0.875
#> .y32 0.528 0.026 20.638 0.000 0.528 0.854
#> .y33 0.541 0.026 21.060 0.000 0.541 0.856
#> .y41 0.529 0.025 21.372 0.000 0.529 0.858
#> .y42 0.490 0.024 20.125 0.000 0.490 0.816
#> .y43 0.480 0.024 20.203 0.000 0.480 0.812
#> .y51 0.509 0.024 20.851 0.000 0.509 0.841
#> .y52 0.506 0.026 19.822 0.000 0.506 0.806
#> .y53 0.475 0.025 19.220 0.000 0.475 0.795
#> FX1 0.086 0.017 4.897 0.000 1.000 1.000
#> FX2 0.048 0.014 3.477 0.001 1.000 1.000
#> FX3 0.061 0.015 4.120 0.000 1.000 1.000
#> FX4 0.071 0.016 4.582 0.000 1.000 1.000
#> FX5 0.056 0.015 3.730 0.000 1.000 1.000
#> FY1 0.085 0.013 6.728 0.000 1.000 1.000
#> FY2 0.100 0.014 7.314 0.000 1.000 1.000
#> FY3 0.071 0.012 6.060 0.000 1.000 1.000
#> FY4 0.087 0.013 6.732 0.000 1.000 1.000
#> FY5 0.096 0.014 7.063 0.000 1.000 1.000
# 2. extract the predicted values of the cfa and add them to new dataframe data_wide2
datMIb <- data.frame(datMI, predict(RICLPM5.ext3.fit))
aggregated means
datalw$Meducalter_7 <- rowMeans(cbind(datalw$educalter_7.1, datalw$educalter_7.2, datalw$educalter_7.3,
datalw$educalter_7.4, datalw$educalter_7.5), na.rm = T)
summary(datalw$Meducalter_7)
#> Min. 1st Qu. Median Mean 3rd Qu. Max. NA's
#> 4.00 10.50 12.00 12.14 13.75 16.00 390
datalw$Meducalter_8 <- rowMeans(cbind(datalw$educalter_8.1, datalw$educalter_8.2, datalw$educalter_8.3,
datalw$educalter_8.4, datalw$educalter_8.5), na.rm = T)
datalw$Meducalter_9 <- rowMeans(cbind(datalw$educalter_9.1, datalw$educalter_9.2, datalw$educalter_9.3,
datalw$educalter_9.4, datalw$educalter_9.5), na.rm = T)
datalw$Meducalter_10 <- rowMeans(cbind(datalw$educalter_10.1, datalw$educalter_10.2, datalw$educalter_10.3,
datalw$educalter_10.4, datalw$educalter_10.5), na.rm = T)
datalw$Meducalter_11 <- rowMeans(cbind(datalw$educalter_11.1, datalw$educalter_11.2, datalw$educalter_11.3,
datalw$educalter_11.4, datalw$educalter_11.5), na.rm = T)
bias corrected means
myModel <- '
#alters are identical thus equal loadings, variances and intercepts at each time point.
#constrained loadings
Feducalter_7 =~ 1*educalter_7.1 + 1*educalter_7.2 + 1*educalter_7.3 + 1*educalter_7.4 + 1*educalter_7.5
Feducalter_8 =~ 1*educalter_8.1 + 1*educalter_8.2 + 1*educalter_8.3 + 1*educalter_8.4 + 1*educalter_8.5
Feducalter_9 =~ 1*educalter_9.1 + 1*educalter_9.2 + 1*educalter_9.3 + 1*educalter_9.4 + 1*educalter_9.5
Feducalter_10 =~ 1*educalter_10.1 + 1*educalter_10.2 + 1*educalter_10.3 + 1*educalter_10.4 + 1*educalter_10.5
Feducalter_11 =~ 1*educalter_11.1 + 1*educalter_11.2 + 1*educalter_11.3 + 1*educalter_11.4 + 1*educalter_11.5
Feducalter_7 ~~ Feducalter_7
Feducalter_8 ~~ Feducalter_8
Feducalter_9 ~~ Feducalter_9
Feducalter_10 ~~ Feducalter_10
Feducalter_11 ~~ Feducalter_11
#constrained variances
educalter_7.1 ~~ e*educalter_7.1
educalter_7.2 ~~ e*educalter_7.2
educalter_7.3 ~~ e*educalter_7.3
educalter_7.4 ~~ e*educalter_7.4
educalter_7.5 ~~ e*educalter_7.5
educalter_8.1 ~~ f*educalter_8.1
educalter_8.2 ~~ f*educalter_8.2
educalter_8.3 ~~ f*educalter_8.3
educalter_8.4 ~~ f*educalter_8.4
educalter_8.5 ~~ f*educalter_8.5
educalter_9.1 ~~ g*educalter_9.1
educalter_9.2 ~~ g*educalter_9.2
educalter_9.3 ~~ g*educalter_9.3
educalter_9.4 ~~ g*educalter_9.4
educalter_9.5 ~~ g*educalter_9.5
educalter_10.1 ~~ h*educalter_10.1
educalter_10.2 ~~ h*educalter_10.2
educalter_10.3 ~~ h*educalter_10.3
educalter_10.4 ~~ h*educalter_10.4
educalter_10.5 ~~ h*educalter_10.5
educalter_11.1 ~~ i*educalter_11.1
educalter_11.2 ~~ i*educalter_11.2
educalter_11.3 ~~ i*educalter_11.3
educalter_11.4 ~~ i*educalter_11.4
educalter_11.5 ~~ i*educalter_11.5
#constrained intercepts / we want structural changes to be picked up by the factor
educalter_7.1 ~ j*1
educalter_7.2 ~ j*1
educalter_7.3 ~ j*1
educalter_7.4 ~ j*1
educalter_7.5 ~ j*1
educalter_8.1 ~ j*1
educalter_8.2 ~ j*1
educalter_8.3 ~ j*1
educalter_8.4 ~ j*1
educalter_8.5 ~ j*1
educalter_9.1 ~ j*1
educalter_9.2 ~ j*1
educalter_9.3 ~ j*1
educalter_9.4 ~ j*1
educalter_9.5 ~ j*1
educalter_10.1 ~ j*1
educalter_10.2 ~ j*1
educalter_10.3 ~ j*1
educalter_10.4 ~ j*1
educalter_10.5 ~ j*1
educalter_11.1 ~ j*1
educalter_11.2 ~ j*1
educalter_11.3 ~ j*1
educalter_11.4 ~ j*1
educalter_11.5 ~ j*1
# Free latent means from t = 2 onward. WHAT DID THIJMEN DO IN HIS STUDY??
Feducalter_8 ~ 1
Feducalter_9 ~ 1
Feducalter_10 ~ 1
Feducalter_11 ~ 1
'
fit <- lavaan(myModel, data = datalw, missing = 'ML', fixed.x=FALSE, meanstructure = T)
summary(fit, standardized = T)
#> lavaan 0.6-7 ended normally after 34 iterations
#>
#> Estimator ML
#> Optimization method NLMINB
#> Number of free parameters 59
#> Number of equality constraints 44
#>
#> Used Total
#> Number of observations 2493 2575
#> Number of missing patterns 1611
#>
#> Model Test User Model:
#>
#> Test statistic 10192.287
#> Degrees of freedom 335
#> P-value (Chi-square) 0.000
#>
#> Parameter Estimates:
#>
#> Standard errors Standard
#> Information Observed
#> Observed information based on Hessian
#>
#> Latent Variables:
#> Estimate Std.Err z-value P(>|z|) Std.lv Std.all
#> Feducalter_7 =~
#> educalter_7.1 1.000 1.501 0.542
#> educalter_7.2 1.000 1.501 0.542
#> educalter_7.3 1.000 1.501 0.542
#> educalter_7.4 1.000 1.501 0.542
#> educalter_7.5 1.000 1.501 0.542
#> Feducalter_8 =~
#> educalter_8.1 1.000 1.457 0.535
#> educalter_8.2 1.000 1.457 0.535
#> educalter_8.3 1.000 1.457 0.535
#> educalter_8.4 1.000 1.457 0.535
#> educalter_8.5 1.000 1.457 0.535
#> Feducalter_9 =~
#> educalter_9.1 1.000 1.468 0.543
#> educalter_9.2 1.000 1.468 0.543
#> educalter_9.3 1.000 1.468 0.543
#> educalter_9.4 1.000 1.468 0.543
#> educalter_9.5 1.000 1.468 0.543
#> Feducalter_10 =~
#> educalter_10.1 1.000 1.473 0.539
#> educalter_10.2 1.000 1.473 0.539
#> educalter_10.3 1.000 1.473 0.539
#> educalter_10.4 1.000 1.473 0.539
#> educalter_10.5 1.000 1.473 0.539
#> Feducalter_11 =~
#> educalter_11.1 1.000 1.453 0.534
#> educalter_11.2 1.000 1.453 0.534
#> educalter_11.3 1.000 1.453 0.534
#> educalter_11.4 1.000 1.453 0.534
#> educalter_11.5 1.000 1.453 0.534
#>
#> Intercepts:
#> Estimate Std.Err z-value P(>|z|) Std.lv Std.all
#> .edcltr_7.1 (j) 12.168 0.043 280.218 0.000 12.168 4.397
#> .edcltr_7.2 (j) 12.168 0.043 280.218 0.000 12.168 4.397
#> .edcltr_7.3 (j) 12.168 0.043 280.218 0.000 12.168 4.397
#> .edcltr_7.4 (j) 12.168 0.043 280.218 0.000 12.168 4.397
#> .edcltr_7.5 (j) 12.168 0.043 280.218 0.000 12.168 4.397
#> .edcltr_8.1 (j) 12.168 0.043 280.218 0.000 12.168 4.469
#> .edcltr_8.2 (j) 12.168 0.043 280.218 0.000 12.168 4.469
#> .edcltr_8.3 (j) 12.168 0.043 280.218 0.000 12.168 4.469
#> .edcltr_8.4 (j) 12.168 0.043 280.218 0.000 12.168 4.469
#> .edcltr_8.5 (j) 12.168 0.043 280.218 0.000 12.168 4.469
#> .edcltr_9.1 (j) 12.168 0.043 280.218 0.000 12.168 4.498
#> .edcltr_9.2 (j) 12.168 0.043 280.218 0.000 12.168 4.498
#> .edcltr_9.3 (j) 12.168 0.043 280.218 0.000 12.168 4.498
#> .edcltr_9.4 (j) 12.168 0.043 280.218 0.000 12.168 4.498
#> .edcltr_9.5 (j) 12.168 0.043 280.218 0.000 12.168 4.498
#> .edclt_10.1 (j) 12.168 0.043 280.218 0.000 12.168 4.450
#> .edclt_10.2 (j) 12.168 0.043 280.218 0.000 12.168 4.450
#> .edclt_10.3 (j) 12.168 0.043 280.218 0.000 12.168 4.450
#> .edclt_10.4 (j) 12.168 0.043 280.218 0.000 12.168 4.450
#> .edclt_10.5 (j) 12.168 0.043 280.218 0.000 12.168 4.450
#> .edclt_11.1 (j) 12.168 0.043 280.218 0.000 12.168 4.475
#> .edclt_11.2 (j) 12.168 0.043 280.218 0.000 12.168 4.475
#> .edclt_11.3 (j) 12.168 0.043 280.218 0.000 12.168 4.475
#> .edclt_11.4 (j) 12.168 0.043 280.218 0.000 12.168 4.475
#> .edclt_11.5 (j) 12.168 0.043 280.218 0.000 12.168 4.475
#> Feducltr_8 0.103 0.062 1.665 0.096 0.070 0.070
#> Feducltr_9 0.168 0.061 2.739 0.006 0.114 0.114
#> Fedcltr_10 0.263 0.062 4.245 0.000 0.179 0.179
#> Fedcltr_11 0.216 0.062 3.461 0.001 0.149 0.149
#> Feducltr_7 0.000 0.000 0.000
#>
#> Variances:
#> Estimate Std.Err z-value P(>|z|) Std.lv Std.all
#> Feducltr_7 2.252 0.125 17.950 0.000 1.000 1.000
#> Feducltr_8 2.122 0.124 17.108 0.000 1.000 1.000
#> Feducltr_9 2.154 0.122 17.710 0.000 1.000 1.000
#> Fedcltr_10 2.169 0.127 17.094 0.000 1.000 1.000
#> Fedcltr_11 2.111 0.128 16.450 0.000 1.000 1.000
#> .edcltr_7.1 (e) 5.408 0.107 50.635 0.000 5.408 0.706
#> .edcltr_7.2 (e) 5.408 0.107 50.635 0.000 5.408 0.706
#> .edcltr_7.3 (e) 5.408 0.107 50.635 0.000 5.408 0.706
#> .edcltr_7.4 (e) 5.408 0.107 50.635 0.000 5.408 0.706
#> .edcltr_7.5 (e) 5.408 0.107 50.635 0.000 5.408 0.706
#> .edcltr_8.1 (f) 5.292 0.108 48.925 0.000 5.292 0.714
#> .edcltr_8.2 (f) 5.292 0.108 48.925 0.000 5.292 0.714
#> .edcltr_8.3 (f) 5.292 0.108 48.925 0.000 5.292 0.714
#> .edcltr_8.4 (f) 5.292 0.108 48.925 0.000 5.292 0.714
#> .edcltr_8.5 (f) 5.292 0.108 48.925 0.000 5.292 0.714
#> .edcltr_9.1 (g) 5.163 0.104 49.724 0.000 5.163 0.706
#> .edcltr_9.2 (g) 5.163 0.104 49.724 0.000 5.163 0.706
#> .edcltr_9.3 (g) 5.163 0.104 49.724 0.000 5.163 0.706
#> .edcltr_9.4 (g) 5.163 0.104 49.724 0.000 5.163 0.706
#> .edcltr_9.5 (g) 5.163 0.104 49.724 0.000 5.163 0.706
#> .edclt_10.1 (h) 5.308 0.109 48.626 0.000 5.308 0.710
#> .edclt_10.2 (h) 5.308 0.109 48.626 0.000 5.308 0.710
#> .edclt_10.3 (h) 5.308 0.109 48.626 0.000 5.308 0.710
#> .edclt_10.4 (h) 5.308 0.109 48.626 0.000 5.308 0.710
#> .edclt_10.5 (h) 5.308 0.109 48.626 0.000 5.308 0.710
#> .edclt_11.1 (i) 5.281 0.112 47.063 0.000 5.281 0.714
#> .edclt_11.2 (i) 5.281 0.112 47.063 0.000 5.281 0.714
#> .edclt_11.3 (i) 5.281 0.112 47.063 0.000 5.281 0.714
#> .edclt_11.4 (i) 5.281 0.112 47.063 0.000 5.281 0.714
#> .edclt_11.5 (i) 5.281 0.112 47.063 0.000 5.281 0.714
# 2. extract the predicted values of the cfa and add them to new dataframe data_wide2
datalwb <- data.frame(datalw, predict(fit))
some descriptives
summary(datalwb[, c(79:88)])
#> Meducalter_7 Meducalter_8 Meducalter_9 Meducalter_10 Meducalter_11 Feducalter_7
#> Min. : 4.00 Min. : 4.00 Min. : 4.00 Min. : 4.00 Min. : 4.00 Min. :-5.5179
#> 1st Qu.:10.50 1st Qu.:10.50 1st Qu.:10.50 1st Qu.:10.50 1st Qu.:10.50 1st Qu.:-0.6444
#> Median :12.00 Median :12.00 Median :12.12 Median :12.33 Median :12.30 Median : 0.0000
#> Mean :12.14 Mean :12.23 Mean :12.29 Mean :12.38 Mean :12.34 Mean : 0.0000
#> 3rd Qu.:13.75 3rd Qu.:13.83 3rd Qu.:14.00 3rd Qu.:14.10 3rd Qu.:14.10 3rd Qu.: 0.7646
#> Max. :16.00 Max. :16.00 Max. :16.00 Max. :16.00 Max. :16.00 Max. : 2.5885
#> NA's :390 NA's :505 NA's :480 NA's :507 NA's :582 NA's :82
#> Feducalter_8 Feducalter_9 Feducalter_10 Feducalter_11
#> Min. :-3.6859 Min. :-3.8445 Min. :-4.0375 Min. :-3.9922
#> 1st Qu.:-0.5473 1st Qu.:-0.5197 1st Qu.:-0.4423 1st Qu.:-0.4647
#> Median : 0.1027 Median : 0.1680 Median : 0.2630 Median : 0.2163
#> Mean : 0.1027 Mean : 0.1680 Mean : 0.2630 Mean : 0.2163
#> 3rd Qu.: 0.7739 3rd Qu.: 0.8871 3rd Qu.: 0.9807 3rd Qu.: 0.8265
#> Max. : 2.5909 Max. : 2.6446 Max. : 2.6592 Max. : 2.6261
#> NA's :82 NA's :82 NA's :82 NA's :82
cor(datalwb[, c(79:88)], use = "pairwise.complete.obs")
#> Meducalter_7 Meducalter_8 Meducalter_9 Meducalter_10 Meducalter_11 Feducalter_7
#> Meducalter_7 1.0000000 0.6907944 0.7141508 0.6756302 0.6640801 0.9634812
#> Meducalter_8 0.6907944 1.0000000 0.7402949 0.7019350 0.6671828 0.6371311
#> Meducalter_9 0.7141508 0.7402949 1.0000000 0.7293267 0.7112851 0.6656154
#> Meducalter_10 0.6756302 0.7019350 0.7293267 1.0000000 0.7396820 0.6308042
#> Meducalter_11 0.6640801 0.6671828 0.7112851 0.7396820 1.0000000 0.6235384
#> Feducalter_7 0.9634812 0.6371311 0.6656154 0.6308042 0.6235384 1.0000000
#> Feducalter_8 0.6358454 0.9622939 0.6953644 0.6587963 0.6302273 0.6304442
#> Feducalter_9 0.6589070 0.6828941 0.9632233 0.6772381 0.6584166 0.6545687
#> Feducalter_10 0.6193559 0.6556651 0.6776771 0.9599566 0.6900632 0.6152511
#> Feducalter_11 0.5943153 0.6107763 0.6424748 0.6772533 0.9584287 0.5913715
#> Feducalter_8 Feducalter_9 Feducalter_10 Feducalter_11
#> Meducalter_7 0.6358454 0.6589070 0.6193559 0.5943153
#> Meducalter_8 0.9622939 0.6828941 0.6556651 0.6107763
#> Meducalter_9 0.6953644 0.9632233 0.6776771 0.6424748
#> Meducalter_10 0.6587963 0.6772381 0.9599566 0.6772533
#> Meducalter_11 0.6302273 0.6584166 0.6900632 0.9584287
#> Feducalter_7 0.6304442 0.6545687 0.6152511 0.5913715
#> Feducalter_8 1.0000000 0.6821636 0.6546583 0.6159324
#> Feducalter_9 0.6821636 1.0000000 0.6765447 0.6396061
#> Feducalter_10 0.6546583 0.6765447 1.0000000 0.6781407
#> Feducalter_11 0.6159324 0.6396061 0.6781407 1.0000000
Let us start with some descriptives.
summary(datalw$eu_10)
summary(datalw$eu_11)
summary(datalw$educalter_10.1)
summary(datalw$educalter_11.1)
var(cbind(datalw$eu_10, datalw$eu_11, datalw$educalter_10.1, datalw$educalter_11.1), na.rm = F, use = "pairwise.complete.obs")
#> Min. 1st Qu. Median Mean 3rd Qu. Max.
#> 0.000 0.000 1.000 1.419 2.000 4.000
#> Min. 1st Qu. Median Mean 3rd Qu. Max.
#> 0.000 0.000 2.000 1.512 2.000 4.000
#> Min. 1st Qu. Median Mean 3rd Qu. Max. NA's
#> 4.0 10.0 11.5 12.4 15.0 16.0 562
#> Min. 1st Qu. Median Mean 3rd Qu. Max. NA's
#> 4.0 10.0 11.5 12.4 15.0 16.0 629
#> [,1] [,2] [,3] [,4]
#> [1,] 1.3709664 0.9892388 0.6068081 0.5765388
#> [2,] 0.9892388 1.4511906 0.6030401 0.6450207
#> [3,] 0.6068081 0.6030401 7.2749276 4.5197169
#> [4,] 0.5765388 0.6450207 4.5197169 7.1008853
myModel <- "
# Estimate the lagged effects
eu_11 + educalter_11.1 ~ eu_10 + educalter_10.1
# Estimate the covariance at the first wave.
eu_10 ~~ educalter_10.1 # Covariance
# Estimate the covariances between the residuals
eu_11 ~~ educalter_11.1
# Estimate the variance
eu_10 ~~ eu_10
educalter_10.1 ~~ educalter_10.1
# Estimate the residual variance
eu_11 ~~ eu_11
educalter_11.1 ~~ educalter_11.1
# intercepts
eu_10 ~ 1
eu_11 ~ 1
educalter_10.1 ~ 1
educalter_11.1 ~ 1
"
fit <- lavaan(myModel, data = datalw, missing = "ML", meanstructure = T)
summary(fit, standardized = T)
#> lavaan 0.6-7 ended normally after 42 iterations
#>
#> Estimator ML
#> Optimization method NLMINB
#> Number of free parameters 14
#>
#> Number of observations 2575
#> Number of missing patterns 4
#>
#> Model Test User Model:
#>
#> Test statistic 0.000
#> Degrees of freedom 0
#>
#> Parameter Estimates:
#>
#> Standard errors Standard
#> Information Observed
#> Observed information based on Hessian
#>
#> Regressions:
#> Estimate Std.Err z-value P(>|z|) Std.lv Std.all
#> eu_11 ~
#> eu_10 0.711 0.015 48.197 0.000 0.711 0.691
#> educalter_10.1 0.025 0.007 3.588 0.000 0.025 0.057
#> educalter_11.1 ~
#> eu_10 0.158 0.041 3.839 0.000 0.158 0.069
#> educalter_10.1 0.624 0.018 34.300 0.000 0.624 0.630
#>
#> Covariances:
#> Estimate Std.Err z-value P(>|z|) Std.lv Std.all
#> eu_10 ~~
#> educalter_10.1 0.597 0.070 8.585 0.000 0.597 0.189
#> .eu_11 ~~
#> .educalter_11.1 0.128 0.041 3.087 0.002 0.128 0.073
#>
#> Intercepts:
#> Estimate Std.Err z-value P(>|z|) Std.lv Std.all
#> eu_10 1.419 0.023 61.511 0.000 1.419 1.212
#> .eu_11 0.192 0.087 2.215 0.027 0.192 0.159
#> educalter_10.1 12.328 0.059 209.800 0.000 12.328 4.569
#> .educalter_11.1 4.446 0.227 19.574 0.000 4.446 1.662
#>
#> Variances:
#> Estimate Std.Err z-value P(>|z|) Std.lv Std.all
#> eu_10 1.370 0.038 35.882 0.000 1.370 1.000
#> educalter_10.1 7.280 0.228 31.992 0.000 7.280 1.000
#> .eu_11 0.733 0.020 35.832 0.000 0.733 0.505
#> .educalter_11.1 4.165 0.139 29.881 0.000 4.165 0.582
myModel <- "
# Create within-person centered variables
weducalter_10.1 =~ 1*educalter_10.1
weducalter_11.1 =~ 1*educalter_11.1
weu_10 =~ 1*eu_10
weu_11 =~ 1*eu_11
# Estimate the lagged effects
weu_11 + weducalter_11.1 ~ weu_10 + weducalter_10.1
# Estimate the covariance at the first wave.
weu_10 ~~ weducalter_10.1 # Covariance
# Estimate the covariances between the residuals
weu_11 ~~ weducalter_11.1
# Estimate the variance
weu_10 ~~ weu_10
weducalter_10.1 ~~ weducalter_10.1
# Estimate the residual variance
weu_11 ~~ weu_11
weducalter_11.1 ~~ weducalter_11.1
"
fit <- lavaan(myModel, data = datalw, missing = "ML", meanstructure = T, int.ov.free = T)
summary(fit, standardized = T)
#> lavaan 0.6-7 ended normally after 42 iterations
#>
#> Estimator ML
#> Optimization method NLMINB
#> Number of free parameters 14
#>
#> Number of observations 2575
#> Number of missing patterns 4
#>
#> Model Test User Model:
#>
#> Test statistic 0.000
#> Degrees of freedom 0
#>
#> Parameter Estimates:
#>
#> Standard errors Standard
#> Information Observed
#> Observed information based on Hessian
#>
#> Latent Variables:
#> Estimate Std.Err z-value P(>|z|) Std.lv Std.all
#> weducalter_10.1 =~
#> educalter_10.1 1.000 2.698 1.000
#> weducalter_11.1 =~
#> educalter_11.1 1.000 2.675 1.000
#> weu_10 =~
#> eu_10 1.000 1.171 1.000
#> weu_11 =~
#> eu_11 1.000 1.204 1.000
#>
#> Regressions:
#> Estimate Std.Err z-value P(>|z|) Std.lv Std.all
#> weu_11 ~
#> weu_10 0.711 0.015 48.197 0.000 0.691 0.691
#> weducaltr_10.1 0.025 0.007 3.588 0.000 0.057 0.057
#> weducalter_11.1 ~
#> weu_10 0.158 0.041 3.839 0.000 0.069 0.069
#> weducaltr_10.1 0.624 0.018 34.300 0.000 0.630 0.630
#>
#> Covariances:
#> Estimate Std.Err z-value P(>|z|) Std.lv Std.all
#> weducalter_10.1 ~~
#> weu_10 0.597 0.070 8.585 0.000 0.189 0.189
#> .weducalter_11.1 ~~
#> .weu_11 0.128 0.041 3.087 0.002 0.073 0.073
#>
#> Intercepts:
#> Estimate Std.Err z-value P(>|z|) Std.lv Std.all
#> .educalter_10.1 12.328 0.059 209.800 0.000 12.328 4.569
#> .educalter_11.1 12.367 0.059 210.200 0.000 12.367 4.624
#> .eu_10 1.419 0.023 61.511 0.000 1.419 1.212
#> .eu_11 1.512 0.024 63.713 0.000 1.512 1.256
#> weducaltr_10.1 0.000 0.000 0.000
#> .weducaltr_11.1 0.000 0.000 0.000
#> weu_10 0.000 0.000 0.000
#> .weu_11 0.000 0.000 0.000
#>
#> Variances:
#> Estimate Std.Err z-value P(>|z|) Std.lv Std.all
#> weu_10 1.370 0.038 35.882 0.000 1.000 1.000
#> weducaltr_10.1 7.280 0.228 31.992 0.000 1.000 1.000
#> .weu_11 0.733 0.020 35.832 0.000 0.505 0.505
#> .weducaltr_11.1 4.165 0.139 29.881 0.000 0.582 0.582
#> .educalter_10.1 0.000 0.000 0.000
#> .educalter_11.1 0.000 0.000 0.000
#> .eu_10 0.000 0.000 0.000
#> .eu_11 0.000 0.000 0.000
myModel <- '
# Estimate the lagged effects (constrained)
eu_8 ~ a*eu_7 + b*educalter_7.1
eu_9 ~ a*eu_8 + b*educalter_8.1
eu_10 ~ a*eu_9 + b*educalter_9.1
eu_11 ~ a*eu_10 + b*educalter_10.1
educalter_8.1 ~ c*eu_7 + d*educalter_7.1
educalter_9.1 ~ c*eu_8 + d*educalter_8.1
educalter_10.1 ~ c*eu_9 + d*educalter_9.1
educalter_11.1 ~ c*eu_10 + d*educalter_10.1
# Estimate the covariance at the first wave.
eu_7 ~~ educalter_7.1 # Covariance
# Estimate the covariances between the residuals
eu_8 ~~ educalter_8.1
eu_9 ~~ educalter_9.1
eu_10 ~~ educalter_10.1
eu_11 ~~ educalter_11.1
# Estimate the variance
eu_7 ~~ eu_7
educalter_7.1 ~~ educalter_7.1
# Estimate the residual variance
eu_8 ~~ eu_8
educalter_8.1 ~~ educalter_8.1
eu_9 ~~ eu_9
educalter_9.1 ~~ educalter_9.1
eu_10 ~~ eu_10
educalter_10.1 ~~ educalter_10.1
eu_11 ~~ eu_11
educalter_11.1 ~~ educalter_11.1
# intercepts
eu_7 ~ 1
eu_8 ~ 1
eu_9 ~ 1
eu_10 ~ 1
eu_11 ~ 1
educalter_7.1 ~ 1
educalter_8.1 ~ 1
educalter_9.1 ~ 1
educalter_10.1 ~ 1
educalter_11.1 ~ 1
'
fit <- lavaan(myModel, data = datalw, missing = 'ML')
summary(fit, standardized = T)
#> lavaan 0.6-7 ended normally after 41 iterations
#>
#> Estimator ML
#> Optimization method NLMINB
#> Number of free parameters 41
#> Number of equality constraints 12
#>
#> Number of observations 2575
#> Number of missing patterns 32
#>
#> Model Test User Model:
#>
#> Test statistic 2313.682
#> Degrees of freedom 36
#> P-value (Chi-square) 0.000
#>
#> Parameter Estimates:
#>
#> Standard errors Standard
#> Information Observed
#> Observed information based on Hessian
#>
#> Regressions:
#> Estimate Std.Err z-value P(>|z|) Std.lv Std.all
#> eu_8 ~
#> eu_7 (a) 0.697 0.007 95.940 0.000 0.697 0.685
#> edcltr_7.1 (b) 0.023 0.003 6.613 0.000 0.023 0.051
#> eu_9 ~
#> eu_8 (a) 0.697 0.007 95.940 0.000 0.697 0.697
#> edcltr_8.1 (b) 0.023 0.003 6.613 0.000 0.023 0.052
#> eu_10 ~
#> eu_9 (a) 0.697 0.007 95.940 0.000 0.697 0.687
#> edcltr_9.1 (b) 0.023 0.003 6.613 0.000 0.023 0.050
#> eu_11 ~
#> eu_10 (a) 0.697 0.007 95.940 0.000 0.697 0.692
#> edclt_10.1 (b) 0.023 0.003 6.613 0.000 0.023 0.050
#> educalter_8.1 ~
#> eu_7 (c) 0.197 0.019 10.186 0.000 0.197 0.084
#> edcltr_7.1 (d) 0.622 0.009 71.419 0.000 0.622 0.614
#> educalter_9.1 ~
#> eu_8 (c) 0.197 0.019 10.186 0.000 0.197 0.087
#> edcltr_8.1 (d) 0.622 0.009 71.419 0.000 0.622 0.634
#> educalter_10.1 ~
#> eu_9 (c) 0.197 0.019 10.186 0.000 0.197 0.086
#> edcltr_9.1 (d) 0.622 0.009 71.419 0.000 0.622 0.616
#> educalter_11.1 ~
#> eu_10 (c) 0.197 0.019 10.186 0.000 0.197 0.088
#> edclt_10.1 (d) 0.622 0.009 71.419 0.000 0.622 0.627
#>
#> Covariances:
#> Estimate Std.Err z-value P(>|z|) Std.lv Std.all
#> eu_7 ~~
#> educalter_7.1 0.592 0.067 8.865 0.000 0.592 0.191
#> .eu_8 ~~
#> .educalter_8.1 0.046 0.040 1.164 0.245 0.046 0.026
#> .eu_9 ~~
#> .educalter_9.1 0.094 0.038 2.505 0.012 0.094 0.056
#> .eu_10 ~~
#> .educalter_10.1 0.049 0.040 1.231 0.218 0.049 0.028
#> .eu_11 ~~
#> .educalter_11.1 0.124 0.041 3.045 0.002 0.124 0.072
#>
#> Intercepts:
#> Estimate Std.Err z-value P(>|z|) Std.lv Std.all
#> eu_7 1.263 0.023 55.406 0.000 1.263 1.092
#> .eu_8 0.172 0.044 3.938 0.000 0.172 0.146
#> .eu_9 0.072 0.044 1.640 0.101 0.072 0.061
#> .eu_10 0.258 0.044 5.859 0.000 0.258 0.216
#> .eu_11 0.246 0.044 5.562 0.000 0.246 0.205
#> educalter_7.1 12.119 0.057 213.349 0.000 12.119 4.521
#> .educalter_8.1 4.479 0.114 39.383 0.000 4.479 1.649
#> .educalter_9.1 4.322 0.114 37.764 0.000 4.322 1.622
#> .educalter_10.1 4.455 0.114 38.979 0.000 4.455 1.658
#> .educalter_11.1 4.436 0.115 38.547 0.000 4.436 1.664
#>
#> Variances:
#> Estimate Std.Err z-value P(>|z|) Std.lv Std.all
#> eu_7 1.338 0.037 35.882 0.000 1.338 1.000
#> educalter_7.1 7.187 0.219 32.884 0.000 7.187 1.000
#> .eu_8 0.714 0.020 35.844 0.000 0.714 0.515
#> .educalter_8.1 4.403 0.142 31.075 0.000 4.403 0.597
#> .eu_9 0.689 0.019 35.855 0.000 0.689 0.498
#> .educalter_9.1 4.054 0.131 30.941 0.000 4.054 0.571
#> .eu_10 0.729 0.020 35.840 0.000 0.729 0.511
#> .educalter_10.1 4.267 0.138 30.874 0.000 4.267 0.591
#> .eu_11 0.733 0.020 35.847 0.000 0.733 0.506
#> .educalter_11.1 4.108 0.136 30.244 0.000 4.108 0.578
myModel <- '
# Estimate the lagged effects (constrained)
eu_8 ~ a*eu_7 + b*educalter_7.1
eu_9 ~ a*eu_8 + b*educalter_8.1
eu_10 ~ a*eu_9 + b*educalter_9.1
eu_11 ~ a*eu_10 + b*educalter_10.1
educalter_8.1 ~ c*eu_7 + d*educalter_7.1
educalter_9.1 ~ c*eu_8 + d*educalter_8.1
educalter_10.1 ~ c*eu_9 + d*educalter_9.1
educalter_11.1 ~ c*eu_10 + d*educalter_10.1
# Estimate the covariance at the first wave.
eu_7 ~~ educalter_7.1 # Covariance
# Estimate the covariances between the residuals
eu_8 ~~ educalter_8.1
eu_9 ~~ educalter_9.1
eu_10 ~~ educalter_10.1
eu_11 ~~ educalter_11.1
# Estimate the variance
eu_7 ~~ eu_7
educalter_7.1 ~~ educalter_7.1
# Estimate the residual variance
eu_8 ~~ eu_8
educalter_8.1 ~~ educalter_8.1
eu_9 ~~ eu_9
educalter_9.1 ~~ educalter_9.1
eu_10 ~~ eu_10
educalter_10.1 ~~ educalter_10.1
eu_11 ~~ eu_11
educalter_11.1 ~~ educalter_11.1
# intercepts
eu_7 ~ 1
eu_8 ~ 1
eu_9 ~ 1
eu_10 ~ 1
eu_11 ~ 1
educalter_7.1 ~ 1
educalter_8.1 ~ 1
educalter_9.1 ~ 1
educalter_10.1 ~ 1
educalter_11.1 ~ 1
'
fit <- lavaan(myModel, data = datalw, missing = 'ML', meanstructure = T, int.ov.free = T)
summary(fit, standardized = T)
#> lavaan 0.6-7 ended normally after 41 iterations
#>
#> Estimator ML
#> Optimization method NLMINB
#> Number of free parameters 41
#> Number of equality constraints 12
#>
#> Number of observations 2575
#> Number of missing patterns 32
#>
#> Model Test User Model:
#>
#> Test statistic 2313.682
#> Degrees of freedom 36
#> P-value (Chi-square) 0.000
#>
#> Parameter Estimates:
#>
#> Standard errors Standard
#> Information Observed
#> Observed information based on Hessian
#>
#> Regressions:
#> Estimate Std.Err z-value P(>|z|) Std.lv Std.all
#> eu_8 ~
#> eu_7 (a) 0.697 0.007 95.940 0.000 0.697 0.685
#> edcltr_7.1 (b) 0.023 0.003 6.613 0.000 0.023 0.051
#> eu_9 ~
#> eu_8 (a) 0.697 0.007 95.940 0.000 0.697 0.697
#> edcltr_8.1 (b) 0.023 0.003 6.613 0.000 0.023 0.052
#> eu_10 ~
#> eu_9 (a) 0.697 0.007 95.940 0.000 0.697 0.687
#> edcltr_9.1 (b) 0.023 0.003 6.613 0.000 0.023 0.050
#> eu_11 ~
#> eu_10 (a) 0.697 0.007 95.940 0.000 0.697 0.692
#> edclt_10.1 (b) 0.023 0.003 6.613 0.000 0.023 0.050
#> educalter_8.1 ~
#> eu_7 (c) 0.197 0.019 10.186 0.000 0.197 0.084
#> edcltr_7.1 (d) 0.622 0.009 71.419 0.000 0.622 0.614
#> educalter_9.1 ~
#> eu_8 (c) 0.197 0.019 10.186 0.000 0.197 0.087
#> edcltr_8.1 (d) 0.622 0.009 71.419 0.000 0.622 0.634
#> educalter_10.1 ~
#> eu_9 (c) 0.197 0.019 10.186 0.000 0.197 0.086
#> edcltr_9.1 (d) 0.622 0.009 71.419 0.000 0.622 0.616
#> educalter_11.1 ~
#> eu_10 (c) 0.197 0.019 10.186 0.000 0.197 0.088
#> edclt_10.1 (d) 0.622 0.009 71.419 0.000 0.622 0.627
#>
#> Covariances:
#> Estimate Std.Err z-value P(>|z|) Std.lv Std.all
#> eu_7 ~~
#> educalter_7.1 0.592 0.067 8.865 0.000 0.592 0.191
#> .eu_8 ~~
#> .educalter_8.1 0.046 0.040 1.164 0.245 0.046 0.026
#> .eu_9 ~~
#> .educalter_9.1 0.094 0.038 2.505 0.012 0.094 0.056
#> .eu_10 ~~
#> .educalter_10.1 0.049 0.040 1.231 0.218 0.049 0.028
#> .eu_11 ~~
#> .educalter_11.1 0.124 0.041 3.045 0.002 0.124 0.072
#>
#> Intercepts:
#> Estimate Std.Err z-value P(>|z|) Std.lv Std.all
#> eu_7 1.263 0.023 55.406 0.000 1.263 1.092
#> .eu_8 0.172 0.044 3.938 0.000 0.172 0.146
#> .eu_9 0.072 0.044 1.640 0.101 0.072 0.061
#> .eu_10 0.258 0.044 5.859 0.000 0.258 0.216
#> .eu_11 0.246 0.044 5.562 0.000 0.246 0.205
#> educalter_7.1 12.119 0.057 213.349 0.000 12.119 4.521
#> .educalter_8.1 4.479 0.114 39.383 0.000 4.479 1.649
#> .educalter_9.1 4.322 0.114 37.764 0.000 4.322 1.622
#> .educalter_10.1 4.455 0.114 38.979 0.000 4.455 1.658
#> .educalter_11.1 4.436 0.115 38.547 0.000 4.436 1.664
#>
#> Variances:
#> Estimate Std.Err z-value P(>|z|) Std.lv Std.all
#> eu_7 1.338 0.037 35.882 0.000 1.338 1.000
#> educalter_7.1 7.187 0.219 32.884 0.000 7.187 1.000
#> .eu_8 0.714 0.020 35.844 0.000 0.714 0.515
#> .educalter_8.1 4.403 0.142 31.075 0.000 4.403 0.597
#> .eu_9 0.689 0.019 35.855 0.000 0.689 0.498
#> .educalter_9.1 4.054 0.131 30.941 0.000 4.054 0.571
#> .eu_10 0.729 0.020 35.840 0.000 0.729 0.511
#> .educalter_10.1 4.267 0.138 30.874 0.000 4.267 0.591
#> .eu_11 0.733 0.020 35.847 0.000 0.733 0.506
#> .educalter_11.1 4.108 0.136 30.244 0.000 4.108 0.578
myModel <- '
# Estimate the lagged effects (constrained)
eu_8 ~ a*eu_7 + b*educalter_7.1
eu_9 ~ a*eu_8 + b*educalter_8.1
eu_10 ~ a*eu_9 + b*educalter_9.1
eu_11 ~ a*eu_10 + b*educalter_10.1
educalter_8.1 ~ c*eu_7 + d*educalter_7.1
educalter_9.1 ~ c*eu_8 + d*educalter_8.1
educalter_10.1 ~ c*eu_9 + d*educalter_9.1
educalter_11.1 ~ c*eu_10 + d*educalter_10.1
# Estimate the covariance at the first wave.
eu_7 ~~ educalter_7.1 # Covariance
# Estimate the covariances between the residuals
eu_8 ~~ educalter_8.1
eu_9 ~~ educalter_9.1
eu_10 ~~ educalter_10.1
eu_11 ~~ educalter_11.1
# Estimate the variance
eu_7 ~~ eu_7
educalter_7.1 ~~ educalter_7.1
# Estimate the residual variance
eu_8 ~~ eu_8
educalter_8.1 ~~ educalter_8.1
eu_9 ~~ eu_9
educalter_9.1 ~~ educalter_9.1
eu_10 ~~ eu_10
educalter_10.1 ~~ educalter_10.1
eu_11 ~~ eu_11
educalter_11.1 ~~ educalter_11.1
# intercepts
eu_7 ~ 1
eu_8 ~ 1
eu_9 ~ 1
eu_10 ~ 1
eu_11 ~ 1
educalter_7.1 ~ 1
educalter_8.1 ~ 1
educalter_9.1 ~ 1
educalter_10.1 ~ 1
educalter_11.1 ~ 1
'
fit <- lavaan(myModel, data = datalw, missing = 'ML', meanstructure = T, int.ov.free = T)
summary(fit, standardized = T)
#> lavaan 0.6-7 ended normally after 41 iterations
#>
#> Estimator ML
#> Optimization method NLMINB
#> Number of free parameters 41
#> Number of equality constraints 12
#>
#> Number of observations 2575
#> Number of missing patterns 32
#>
#> Model Test User Model:
#>
#> Test statistic 2313.682
#> Degrees of freedom 36
#> P-value (Chi-square) 0.000
#>
#> Parameter Estimates:
#>
#> Standard errors Standard
#> Information Observed
#> Observed information based on Hessian
#>
#> Regressions:
#> Estimate Std.Err z-value P(>|z|) Std.lv Std.all
#> eu_8 ~
#> eu_7 (a) 0.697 0.007 95.940 0.000 0.697 0.685
#> edcltr_7.1 (b) 0.023 0.003 6.613 0.000 0.023 0.051
#> eu_9 ~
#> eu_8 (a) 0.697 0.007 95.940 0.000 0.697 0.697
#> edcltr_8.1 (b) 0.023 0.003 6.613 0.000 0.023 0.052
#> eu_10 ~
#> eu_9 (a) 0.697 0.007 95.940 0.000 0.697 0.687
#> edcltr_9.1 (b) 0.023 0.003 6.613 0.000 0.023 0.050
#> eu_11 ~
#> eu_10 (a) 0.697 0.007 95.940 0.000 0.697 0.692
#> edclt_10.1 (b) 0.023 0.003 6.613 0.000 0.023 0.050
#> educalter_8.1 ~
#> eu_7 (c) 0.197 0.019 10.186 0.000 0.197 0.084
#> edcltr_7.1 (d) 0.622 0.009 71.419 0.000 0.622 0.614
#> educalter_9.1 ~
#> eu_8 (c) 0.197 0.019 10.186 0.000 0.197 0.087
#> edcltr_8.1 (d) 0.622 0.009 71.419 0.000 0.622 0.634
#> educalter_10.1 ~
#> eu_9 (c) 0.197 0.019 10.186 0.000 0.197 0.086
#> edcltr_9.1 (d) 0.622 0.009 71.419 0.000 0.622 0.616
#> educalter_11.1 ~
#> eu_10 (c) 0.197 0.019 10.186 0.000 0.197 0.088
#> edclt_10.1 (d) 0.622 0.009 71.419 0.000 0.622 0.627
#>
#> Covariances:
#> Estimate Std.Err z-value P(>|z|) Std.lv Std.all
#> eu_7 ~~
#> educalter_7.1 0.592 0.067 8.865 0.000 0.592 0.191
#> .eu_8 ~~
#> .educalter_8.1 0.046 0.040 1.164 0.245 0.046 0.026
#> .eu_9 ~~
#> .educalter_9.1 0.094 0.038 2.505 0.012 0.094 0.056
#> .eu_10 ~~
#> .educalter_10.1 0.049 0.040 1.231 0.218 0.049 0.028
#> .eu_11 ~~
#> .educalter_11.1 0.124 0.041 3.045 0.002 0.124 0.072
#>
#> Intercepts:
#> Estimate Std.Err z-value P(>|z|) Std.lv Std.all
#> eu_7 1.263 0.023 55.406 0.000 1.263 1.092
#> .eu_8 0.172 0.044 3.938 0.000 0.172 0.146
#> .eu_9 0.072 0.044 1.640 0.101 0.072 0.061
#> .eu_10 0.258 0.044 5.859 0.000 0.258 0.216
#> .eu_11 0.246 0.044 5.562 0.000 0.246 0.205
#> educalter_7.1 12.119 0.057 213.349 0.000 12.119 4.521
#> .educalter_8.1 4.479 0.114 39.383 0.000 4.479 1.649
#> .educalter_9.1 4.322 0.114 37.764 0.000 4.322 1.622
#> .educalter_10.1 4.455 0.114 38.979 0.000 4.455 1.658
#> .educalter_11.1 4.436 0.115 38.547 0.000 4.436 1.664
#>
#> Variances:
#> Estimate Std.Err z-value P(>|z|) Std.lv Std.all
#> eu_7 1.338 0.037 35.882 0.000 1.338 1.000
#> educalter_7.1 7.187 0.219 32.884 0.000 7.187 1.000
#> .eu_8 0.714 0.020 35.844 0.000 0.714 0.515
#> .educalter_8.1 4.403 0.142 31.075 0.000 4.403 0.597
#> .eu_9 0.689 0.019 35.855 0.000 0.689 0.498
#> .educalter_9.1 4.054 0.131 30.941 0.000 4.054 0.571
#> .eu_10 0.729 0.020 35.840 0.000 0.729 0.511
#> .educalter_10.1 4.267 0.138 30.874 0.000 4.267 0.591
#> .eu_11 0.733 0.020 35.847 0.000 0.733 0.506
#> .educalter_11.1 4.108 0.136 30.244 0.000 4.108 0.578
myModel <- '
# Create between components (random intercepts)
RIx =~ 1*educalter_7.1 + 1*educalter_8.1 + 1*educalter_9.1 + 1*educalter_10.1 + 1*educalter_11.1
RIy =~ 1*eu_7 + 1*eu_8 + 1*eu_9 + 1*eu_10 + 1*eu_11
# Create within-person centered variables
weducalter_7.1 =~ 1*educalter_7.1
weducalter_8.1 =~ 1*educalter_8.1
weducalter_9.1 =~ 1*educalter_9.1
weducalter_10.1 =~ 1*educalter_10.1
weducalter_11.1 =~ 1*educalter_11.1
weu_7 =~ 1*eu_7
weu_8 =~ 1*eu_8
weu_9 =~ 1*eu_9
weu_10 =~ 1*eu_10
weu_11 =~ 1*eu_11
# Estimate the lagged effects (constrained)
weu_8 ~ a*weu_7 + b*weducalter_7.1
weu_9 ~ a*weu_8 + b*weducalter_8.1
weu_10 ~ a*weu_9 + b*weducalter_9.1
weu_11 ~ a*weu_10 + b*weducalter_10.1
weducalter_8.1 ~ c*weu_7 + d*weducalter_7.1
weducalter_9.1 ~ c*weu_8 + d*weducalter_8.1
weducalter_10.1 ~ c*weu_9 + d*weducalter_9.1
weducalter_11.1 ~ c*weu_10 + d*weducalter_10.1
# Estimate the covariance at the first wave. WITHIN
weu_7 ~~ weducalter_7.1 # Covariance
# Estimate the covariances between the residuals. WITHIN
weu_8 ~~ weducalter_8.1
weu_9 ~~ weducalter_9.1
weu_10 ~~ weducalter_10.1
weu_11 ~~ weducalter_11.1
# Estimate the variance and covariance of the random intercepts. BETWEEN
RIx ~~ RIx
RIy ~~ RIy
RIx ~~ RIy
# Estimate the variance. WITHIN
weu_7 ~~ weu_7
weducalter_7.1 ~~ weducalter_7.1
# Estimate the residual variance. WITHIN
weu_8 ~~ weu_8
weducalter_8.1 ~~ weducalter_8.1
weu_9 ~~ weu_9
weducalter_9.1 ~~ weducalter_9.1
weu_10 ~~ weu_10
weducalter_10.1 ~~ weducalter_10.1
weu_11 ~~ weu_11
weducalter_11.1 ~~ weducalter_11.1
'
fit <- lavaan(myModel, data = datalw, missing = 'ML', meanstructure = T, int.ov.free = T)
summary(fit, standardized = T)
#> lavaan 0.6-7 ended normally after 74 iterations
#>
#> Estimator ML
#> Optimization method NLMINB
#> Number of free parameters 44
#> Number of equality constraints 12
#>
#> Number of observations 2575
#> Number of missing patterns 32
#>
#> Model Test User Model:
#>
#> Test statistic 52.852
#> Degrees of freedom 33
#> P-value (Chi-square) 0.016
#>
#> Parameter Estimates:
#>
#> Standard errors Standard
#> Information Observed
#> Observed information based on Hessian
#>
#> Latent Variables:
#> Estimate Std.Err z-value P(>|z|) Std.lv Std.all
#> RIx =~
#> educalter_7.1 1.000 2.074 0.766
#> educalter_8.1 1.000 2.074 0.776
#> educalter_9.1 1.000 2.074 0.786
#> educalter_10.1 1.000 2.074 0.774
#> educalter_11.1 1.000 2.074 0.780
#> RIy =~
#> eu_7 1.000 0.954 0.814
#> eu_8 1.000 0.954 0.809
#> eu_9 1.000 0.954 0.811
#> eu_10 1.000 0.954 0.805
#> eu_11 1.000 0.954 0.800
#> weducalter_7.1 =~
#> educalter_7.1 1.000 1.741 0.643
#> weducalter_8.1 =~
#> educalter_8.1 1.000 1.685 0.630
#> weducalter_9.1 =~
#> educalter_9.1 1.000 1.633 0.619
#> weducalter_10.1 =~
#> educalter_10.1 1.000 1.695 0.633
#> weducalter_11.1 =~
#> educalter_11.1 1.000 1.664 0.626
#> weu_7 =~
#> eu_7 1.000 0.681 0.581
#> weu_8 =~
#> eu_8 1.000 0.694 0.588
#> weu_9 =~
#> eu_9 1.000 0.689 0.585
#> weu_10 =~
#> eu_10 1.000 0.703 0.593
#> weu_11 =~
#> eu_11 1.000 0.716 0.600
#>
#> Regressions:
#> Estimate Std.Err z-value P(>|z|) Std.lv Std.all
#> weu_8 ~
#> weu_7 (a) 0.135 0.015 8.836 0.000 0.133 0.133
#> wdcltr_7.1 (b) 0.002 0.006 0.318 0.751 0.005 0.005
#> weu_9 ~
#> weu_8 (a) 0.135 0.015 8.836 0.000 0.136 0.136
#> wdcltr_8.1 (b) 0.002 0.006 0.318 0.751 0.005 0.005
#> weu_10 ~
#> weu_9 (a) 0.135 0.015 8.836 0.000 0.133 0.133
#> wdcltr_9.1 (b) 0.002 0.006 0.318 0.751 0.004 0.004
#> weu_11 ~
#> weu_10 (a) 0.135 0.015 8.836 0.000 0.133 0.133
#> wdclt_10.1 (b) 0.002 0.006 0.318 0.751 0.004 0.004
#> weducalter_8.1 ~
#> weu_7 (c) 0.065 0.036 1.797 0.072 0.026 0.026
#> wdcltr_7.1 (d) 0.048 0.018 2.693 0.007 0.049 0.049
#> weducalter_9.1 ~
#> weu_8 (c) 0.065 0.036 1.797 0.072 0.028 0.028
#> wdcltr_8.1 (d) 0.048 0.018 2.693 0.007 0.049 0.049
#> weducalter_10.1 ~
#> weu_9 (c) 0.065 0.036 1.797 0.072 0.026 0.026
#> wdcltr_9.1 (d) 0.048 0.018 2.693 0.007 0.046 0.046
#> weducalter_11.1 ~
#> weu_10 (c) 0.065 0.036 1.797 0.072 0.027 0.027
#> wdclt_10.1 (d) 0.048 0.018 2.693 0.007 0.049 0.049
#>
#> Covariances:
#> Estimate Std.Err z-value P(>|z|) Std.lv Std.all
#> weducalter_7.1 ~~
#> weu_7 -0.020 0.033 -0.592 0.554 -0.017 -0.017
#> .weducalter_8.1 ~~
#> .weu_8 0.045 0.033 1.349 0.177 0.039 0.039
#> .weducalter_9.1 ~~
#> .weu_9 0.024 0.032 0.755 0.450 0.021 0.021
#> .weducalter_10.1 ~~
#> .weu_10 0.018 0.034 0.523 0.601 0.015 0.015
#> .weducalter_11.1 ~~
#> .weu_11 0.054 0.033 1.629 0.103 0.046 0.046
#> RIx ~~
#> RIy 0.595 0.048 12.355 0.000 0.301 0.301
#>
#> Intercepts:
#> Estimate Std.Err z-value P(>|z|) Std.lv Std.all
#> .educalter_7.1 12.097 0.057 213.217 0.000 12.097 4.467
#> .educalter_8.1 12.254 0.057 216.078 0.000 12.254 4.586
#> .educalter_9.1 12.218 0.056 219.048 0.000 12.218 4.628
#> .educalter_10.1 12.293 0.057 215.753 0.000 12.293 4.589
#> .educalter_11.1 12.339 0.057 216.172 0.000 12.339 4.640
#> .eu_7 1.263 0.023 54.687 0.000 1.263 1.078
#> .eu_8 1.325 0.023 57.015 0.000 1.325 1.124
#> .eu_9 1.272 0.023 54.873 0.000 1.272 1.081
#> .eu_10 1.419 0.023 60.791 0.000 1.419 1.198
#> .eu_11 1.512 0.023 64.360 0.000 1.512 1.268
#> RIx 0.000 0.000 0.000
#> RIy 0.000 0.000 0.000
#> weducalter_7.1 0.000 0.000 0.000
#> .weducalter_8.1 0.000 0.000 0.000
#> .weducalter_9.1 0.000 0.000 0.000
#> .weducaltr_10.1 0.000 0.000 0.000
#> .weducaltr_11.1 0.000 0.000 0.000
#> weu_7 0.000 0.000 0.000
#> .weu_8 0.000 0.000 0.000
#> .weu_9 0.000 0.000 0.000
#> .weu_10 0.000 0.000 0.000
#> .weu_11 0.000 0.000 0.000
#>
#> Variances:
#> Estimate Std.Err z-value P(>|z|) Std.lv Std.all
#> RIx 4.302 0.148 29.067 0.000 1.000 1.000
#> RIy 0.909 0.029 31.345 0.000 1.000 1.000
#> weu_7 0.464 0.017 27.552 0.000 1.000 1.000
#> weducalter_7.1 3.030 0.119 25.541 0.000 1.000 1.000
#> .weu_8 0.473 0.017 28.236 0.000 0.982 0.982
#> .weducalter_8.1 2.829 0.117 24.208 0.000 0.997 0.997
#> .weu_9 0.465 0.016 28.595 0.000 0.981 0.981
#> .weducalter_9.1 2.658 0.110 24.230 0.000 0.997 0.997
#> .weu_10 0.485 0.017 28.654 0.000 0.982 0.982
#> .weducaltr_10.1 2.866 0.117 24.408 0.000 0.997 0.997
#> .weu_11 0.503 0.017 30.141 0.000 0.982 0.982
#> .weducaltr_11.1 2.761 0.111 24.828 0.000 0.997 0.997
#> .educalter_7.1 0.000 0.000 0.000
#> .educalter_8.1 0.000 0.000 0.000
#> .educalter_9.1 0.000 0.000 0.000
#> .educalter_10.1 0.000 0.000 0.000
#> .educalter_11.1 0.000 0.000 0.000
#> .eu_7 0.000 0.000 0.000
#> .eu_8 0.000 0.000 0.000
#> .eu_9 0.000 0.000 0.000
#> .eu_10 0.000 0.000 0.000
#> .eu_11 0.000 0.000 0.000
myModel <- '
# Estimate the lagged effects (constrained)
eu_8 ~ a*eu_7 + b*educalter_7.1
eu_9 ~ a*eu_8 + b*educalter_8.1
eu_10 ~ a*eu_9 + b*educalter_9.1
eu_11 ~ a*eu_10 + b*educalter_10.1
educalter_8.1 ~ c*eu_7 + d*educalter_7.1
educalter_9.1 ~ c*eu_8 + d*educalter_8.1
educalter_10.1 ~ c*eu_9 + d*educalter_9.1
educalter_11.1 ~ c*eu_10 + d*educalter_10.1
# Estimate the covariance at the first wave.
eu_7 ~~ educalter_7.1 # Covariance
# Estimate the covariances between the residuals
eu_8 ~~ educalter_8.1
eu_9 ~~ educalter_9.1
eu_10 ~~ educalter_10.1
eu_11 ~~ educalter_11.1
# Estimate the variance
eu_7 ~~ eu_7
educalter_7.1 ~~ educalter_7.1
# Estimate the residual variance
eu_8 ~~ eu_8
educalter_8.1 ~~ educalter_8.1
eu_9 ~~ eu_9
educalter_9.1 ~~ educalter_9.1
eu_10 ~~ eu_10
educalter_10.1 ~~ educalter_10.1
eu_11 ~~ eu_11
educalter_11.1 ~~ educalter_11.1
# intercepts
eu_7 ~ 1
eu_8 ~ 1
eu_9 ~ 1
eu_10 ~ 1
eu_11 ~ 1
educalter_7.1 ~ 1
educalter_8.1 ~ 1
educalter_9.1 ~ 1
educalter_10.1 ~ 1
educalter_11.1 ~ 1
'
fit <- lavaan(myModel, data = datalw, missing = 'ML', meanstructure = T, int.ov.free = T)
summary(fit, standardized = T)
#> lavaan 0.6-7 ended normally after 41 iterations
#>
#> Estimator ML
#> Optimization method NLMINB
#> Number of free parameters 41
#> Number of equality constraints 12
#>
#> Number of observations 2575
#> Number of missing patterns 32
#>
#> Model Test User Model:
#>
#> Test statistic 2313.682
#> Degrees of freedom 36
#> P-value (Chi-square) 0.000
#>
#> Parameter Estimates:
#>
#> Standard errors Standard
#> Information Observed
#> Observed information based on Hessian
#>
#> Regressions:
#> Estimate Std.Err z-value P(>|z|) Std.lv Std.all
#> eu_8 ~
#> eu_7 (a) 0.697 0.007 95.940 0.000 0.697 0.685
#> edcltr_7.1 (b) 0.023 0.003 6.613 0.000 0.023 0.051
#> eu_9 ~
#> eu_8 (a) 0.697 0.007 95.940 0.000 0.697 0.697
#> edcltr_8.1 (b) 0.023 0.003 6.613 0.000 0.023 0.052
#> eu_10 ~
#> eu_9 (a) 0.697 0.007 95.940 0.000 0.697 0.687
#> edcltr_9.1 (b) 0.023 0.003 6.613 0.000 0.023 0.050
#> eu_11 ~
#> eu_10 (a) 0.697 0.007 95.940 0.000 0.697 0.692
#> edclt_10.1 (b) 0.023 0.003 6.613 0.000 0.023 0.050
#> educalter_8.1 ~
#> eu_7 (c) 0.197 0.019 10.186 0.000 0.197 0.084
#> edcltr_7.1 (d) 0.622 0.009 71.419 0.000 0.622 0.614
#> educalter_9.1 ~
#> eu_8 (c) 0.197 0.019 10.186 0.000 0.197 0.087
#> edcltr_8.1 (d) 0.622 0.009 71.419 0.000 0.622 0.634
#> educalter_10.1 ~
#> eu_9 (c) 0.197 0.019 10.186 0.000 0.197 0.086
#> edcltr_9.1 (d) 0.622 0.009 71.419 0.000 0.622 0.616
#> educalter_11.1 ~
#> eu_10 (c) 0.197 0.019 10.186 0.000 0.197 0.088
#> edclt_10.1 (d) 0.622 0.009 71.419 0.000 0.622 0.627
#>
#> Covariances:
#> Estimate Std.Err z-value P(>|z|) Std.lv Std.all
#> eu_7 ~~
#> educalter_7.1 0.592 0.067 8.865 0.000 0.592 0.191
#> .eu_8 ~~
#> .educalter_8.1 0.046 0.040 1.164 0.245 0.046 0.026
#> .eu_9 ~~
#> .educalter_9.1 0.094 0.038 2.505 0.012 0.094 0.056
#> .eu_10 ~~
#> .educalter_10.1 0.049 0.040 1.231 0.218 0.049 0.028
#> .eu_11 ~~
#> .educalter_11.1 0.124 0.041 3.045 0.002 0.124 0.072
#>
#> Intercepts:
#> Estimate Std.Err z-value P(>|z|) Std.lv Std.all
#> eu_7 1.263 0.023 55.406 0.000 1.263 1.092
#> .eu_8 0.172 0.044 3.938 0.000 0.172 0.146
#> .eu_9 0.072 0.044 1.640 0.101 0.072 0.061
#> .eu_10 0.258 0.044 5.859 0.000 0.258 0.216
#> .eu_11 0.246 0.044 5.562 0.000 0.246 0.205
#> educalter_7.1 12.119 0.057 213.349 0.000 12.119 4.521
#> .educalter_8.1 4.479 0.114 39.383 0.000 4.479 1.649
#> .educalter_9.1 4.322 0.114 37.764 0.000 4.322 1.622
#> .educalter_10.1 4.455 0.114 38.979 0.000 4.455 1.658
#> .educalter_11.1 4.436 0.115 38.547 0.000 4.436 1.664
#>
#> Variances:
#> Estimate Std.Err z-value P(>|z|) Std.lv Std.all
#> eu_7 1.338 0.037 35.882 0.000 1.338 1.000
#> educalter_7.1 7.187 0.219 32.884 0.000 7.187 1.000
#> .eu_8 0.714 0.020 35.844 0.000 0.714 0.515
#> .educalter_8.1 4.403 0.142 31.075 0.000 4.403 0.597
#> .eu_9 0.689 0.019 35.855 0.000 0.689 0.498
#> .educalter_9.1 4.054 0.131 30.941 0.000 4.054 0.571
#> .eu_10 0.729 0.020 35.840 0.000 0.729 0.511
#> .educalter_10.1 4.267 0.138 30.874 0.000 4.267 0.591
#> .eu_11 0.733 0.020 35.847 0.000 0.733 0.506
#> .educalter_11.1 4.108 0.136 30.244 0.000 4.108 0.578
myModel <- '
# Create LATENT variables
Feducalter_7 =~ 1*educalter_7.1 + 1*educalter_7.2 + 1*educalter_7.3 + 1*educalter_7.4 + 1*educalter_7.5
Feducalter_8 =~ 1*educalter_8.1 + 1*educalter_8.2 + 1*educalter_8.3 + 1*educalter_8.4 + 1*educalter_8.5
Feducalter_9 =~ 1*educalter_9.1 + 1*educalter_9.2 + 1*educalter_9.3 + 1*educalter_9.4 + 1*educalter_9.5
Feducalter_10 =~ 1*educalter_10.1 + 1*educalter_10.2 + 1*educalter_10.3 + 1*educalter_10.4 + 1*educalter_10.5
Feducalter_11 =~ 1*educalter_11.1 + 1*educalter_11.2 + 1*educalter_11.3 + 1*educalter_11.4 + 1*educalter_11.5
# Free latent means from t = 2 onward. WHAT DID THIJMEN DO IN HIS STUDY?? aND DOES THIS MATTER?
Feducalter_8 ~ 1
Feducalter_9 ~ 1
Feducalter_10 ~ 1
Feducalter_11 ~ 1
# Estimate the lagged effects (constrained)
eu_8 ~ a*eu_7 + b*Feducalter_7
eu_9 ~ a*eu_8 + b*Feducalter_8
eu_10 ~ a*eu_9 + b*Feducalter_9
eu_11 ~ a*eu_10 + b*Feducalter_10
Feducalter_8 ~ c*eu_7 + d*Feducalter_7
Feducalter_9 ~ c*eu_8 + d*Feducalter_8
Feducalter_10 ~ c*eu_9 + d*Feducalter_9
Feducalter_11 ~ c*eu_10 + d*Feducalter_10
# Estimate the covariance at the first wave.
eu_7 ~~ Feducalter_7 # Covariance
# Estimate the covariances between the residuals
eu_8 ~~ Feducalter_8
eu_9 ~~ Feducalter_9
eu_10 ~~ Feducalter_10
eu_11 ~~ Feducalter_11
# Estimate the variance
educalter_7.1 ~~ e*educalter_7.1
educalter_7.2 ~~ e*educalter_7.2
educalter_7.3 ~~ e*educalter_7.3
educalter_7.4 ~~ e*educalter_7.4
educalter_7.5 ~~ e*educalter_7.5
educalter_8.1 ~~ f*educalter_8.1
educalter_8.2 ~~ f*educalter_8.2
educalter_8.3 ~~ f*educalter_8.3
educalter_8.4 ~~ f*educalter_8.4
educalter_8.5 ~~ f*educalter_8.5
educalter_9.1 ~~ g*educalter_9.1
educalter_9.2 ~~ g*educalter_9.2
educalter_9.3 ~~ g*educalter_9.3
educalter_9.4 ~~ g*educalter_9.4
educalter_9.5 ~~ g*educalter_9.5
educalter_10.1 ~~ h*educalter_10.1
educalter_10.2 ~~ h*educalter_10.2
educalter_10.3 ~~ h*educalter_10.3
educalter_10.4 ~~ h*educalter_10.4
educalter_10.5 ~~ h*educalter_10.5
educalter_11.1 ~~ i*educalter_11.1
educalter_11.2 ~~ i*educalter_11.2
educalter_11.3 ~~ i*educalter_11.3
educalter_11.4 ~~ i*educalter_11.4
educalter_11.5 ~~ i*educalter_11.5
# Estimate the (residual) variance
eu_7 ~~ eu_7
eu_8 ~~ eu_8
eu_9 ~~ eu_9
eu_10 ~~ eu_10
eu_11 ~~ eu_11
Feducalter_7 ~~ Feducalter_7
Feducalter_8 ~~ Feducalter_8
Feducalter_9 ~~ Feducalter_9
Feducalter_10 ~~ Feducalter_10
Feducalter_11 ~~ Feducalter_11
# intercepts
eu_7 ~ 1
eu_8 ~ 1
eu_9 ~ 1
eu_10 ~ 1
eu_11 ~ 1
#constrained intercepts
educalter_7.1 ~ j*1
educalter_7.2 ~ j*1
educalter_7.3 ~ j*1
educalter_7.4 ~ j*1
educalter_7.5 ~ j*1
educalter_8.1 ~ j*1
educalter_8.2 ~ j*1
educalter_8.3 ~ j*1
educalter_8.4 ~ j*1
educalter_8.5 ~ j*1
educalter_9.1 ~ j*1
educalter_9.2 ~ j*1
educalter_9.3 ~ j*1
educalter_9.4 ~ j*1
educalter_9.5 ~ j*1
educalter_10.1 ~ j*1
educalter_10.2 ~ j*1
educalter_10.3 ~ j*1
educalter_10.4 ~ j*1
educalter_10.5 ~ j*1
educalter_11.1 ~ j*1
educalter_11.2 ~ j*1
educalter_11.3 ~ j*1
educalter_11.4 ~ j*1
educalter_11.5 ~ j*1
'
fit <- lavaan(myModel, data = datalw, missing = 'ML', meanstructure = T, int.ov.free = T)
summary(fit, standardized = T)
#> lavaan 0.6-7 ended normally after 93 iterations
#>
#> Estimator ML
#> Optimization method NLMINB
#> Number of free parameters 90
#> Number of equality constraints 56
#>
#> Number of observations 2575
#> Number of missing patterns 1612
#>
#> Model Test User Model:
#>
#> Test statistic 4684.862
#> Degrees of freedom 461
#> P-value (Chi-square) 0.000
#>
#> Parameter Estimates:
#>
#> Standard errors Standard
#> Information Observed
#> Observed information based on Hessian
#>
#> Latent Variables:
#> Estimate Std.Err z-value P(>|z|) Std.lv Std.all
#> Feducalter_7 =~
#> educalter_7.1 1.000 1.628 0.580
#> educalter_7.2 1.000 1.628 0.580
#> educalter_7.3 1.000 1.628 0.580
#> educalter_7.4 1.000 1.628 0.580
#> educalter_7.5 1.000 1.628 0.580
#> Feducalter_8 =~
#> educalter_8.1 1.000 1.620 0.594
#> educalter_8.2 1.000 1.620 0.594
#> educalter_8.3 1.000 1.620 0.594
#> educalter_8.4 1.000 1.620 0.594
#> educalter_8.5 1.000 1.620 0.594
#> Feducalter_9 =~
#> educalter_9.1 1.000 1.626 0.603
#> educalter_9.2 1.000 1.626 0.603
#> educalter_9.3 1.000 1.626 0.603
#> educalter_9.4 1.000 1.626 0.603
#> educalter_9.5 1.000 1.626 0.603
#> Feducalter_10 =~
#> educalter_10.1 1.000 1.690 0.613
#> educalter_10.2 1.000 1.690 0.613
#> educalter_10.3 1.000 1.690 0.613
#> educalter_10.4 1.000 1.690 0.613
#> educalter_10.5 1.000 1.690 0.613
#> Feducalter_11 =~
#> educalter_11.1 1.000 1.579 0.573
#> educalter_11.2 1.000 1.579 0.573
#> educalter_11.3 1.000 1.579 0.573
#> educalter_11.4 1.000 1.579 0.573
#> educalter_11.5 1.000 1.579 0.573
#>
#> Regressions:
#> Estimate Std.Err z-value P(>|z|) Std.lv Std.all
#> eu_8 ~
#> eu_7 (a) 0.677 0.008 88.754 0.000 0.677 0.664
#> Feducltr_7 (b) 0.072 0.007 10.963 0.000 0.118 0.100
#> eu_9 ~
#> eu_8 (a) 0.677 0.008 88.754 0.000 0.677 0.678
#> Feducltr_8 (b) 0.072 0.007 10.963 0.000 0.117 0.100
#> eu_10 ~
#> eu_9 (a) 0.677 0.008 88.754 0.000 0.677 0.668
#> Feducltr_9 (b) 0.072 0.007 10.963 0.000 0.118 0.099
#> eu_11 ~
#> eu_10 (a) 0.677 0.008 88.754 0.000 0.677 0.672
#> Fedcltr_10 (b) 0.072 0.007 10.963 0.000 0.122 0.102
#> Feducalter_8 ~
#> eu_7 (c) 0.018 0.010 1.848 0.065 0.011 0.013
#> Feducltr_7 (d) 1.022 0.007 155.294 0.000 1.027 1.027
#> Feducalter_9 ~
#> eu_8 (c) 0.018 0.010 1.848 0.065 0.011 0.013
#> Feducltr_8 (d) 1.022 0.007 155.294 0.000 1.018 1.018
#> Feducalter_10 ~
#> eu_9 (c) 0.018 0.010 1.848 0.065 0.011 0.012
#> Feducltr_9 (d) 1.022 0.007 155.294 0.000 0.983 0.983
#> Feducalter_11 ~
#> eu_10 (c) 0.018 0.010 1.848 0.065 0.011 0.014
#> Fedcltr_10 (d) 1.022 0.007 155.294 0.000 1.093 1.093
#>
#> Covariances:
#> Estimate Std.Err z-value P(>|z|) Std.lv Std.all
#> Feducalter_7 ~~
#> eu_7 0.573 0.046 12.554 0.000 0.352 0.304
#> .Feducalter_8 ~~
#> .eu_8 -0.046 0.024 -1.952 0.051 -0.114 -0.136
#> .Feducalter_9 ~~
#> .eu_9 -0.021 0.021 -1.020 0.308 -0.061 -0.074
#> .Feducalter_10 ~~
#> .eu_10 -0.022 0.021 -1.016 0.310 -0.080 -0.095
#> .Feducalter_11 ~~
#> .eu_11 -0.035 0.024 -1.463 0.143 -0.049 -0.058
#>
#> Intercepts:
#> Estimate Std.Err z-value P(>|z|) Std.lv Std.all
#> .Feducltr_8 0.076 0.040 1.917 0.055 0.047 0.047
#> .Feducltr_9 0.024 0.040 0.590 0.555 0.014 0.014
#> .Fedcltr_10 0.052 0.041 1.280 0.201 0.031 0.031
#> .Fedcltr_11 -0.042 0.039 -1.095 0.274 -0.027 -0.027
#> eu_7 1.263 0.023 55.406 0.000 1.263 1.092
#> .eu_8 0.470 0.019 24.324 0.000 0.470 0.398
#> .eu_9 0.367 0.019 18.977 0.000 0.367 0.312
#> .eu_10 0.547 0.020 28.054 0.000 0.547 0.458
#> .eu_11 0.535 0.020 26.733 0.000 0.535 0.445
#> .edcltr_7.1 (j) 12.074 0.043 281.887 0.000 12.074 4.303
#> .edcltr_7.2 (j) 12.074 0.043 281.887 0.000 12.074 4.303
#> .edcltr_7.3 (j) 12.074 0.043 281.887 0.000 12.074 4.303
#> .edcltr_7.4 (j) 12.074 0.043 281.887 0.000 12.074 4.303
#> .edcltr_7.5 (j) 12.074 0.043 281.887 0.000 12.074 4.303
#> .edcltr_8.1 (j) 12.074 0.043 281.887 0.000 12.074 4.424
#> .edcltr_8.2 (j) 12.074 0.043 281.887 0.000 12.074 4.424
#> .edcltr_8.3 (j) 12.074 0.043 281.887 0.000 12.074 4.424
#> .edcltr_8.4 (j) 12.074 0.043 281.887 0.000 12.074 4.424
#> .edcltr_8.5 (j) 12.074 0.043 281.887 0.000 12.074 4.424
#> .edcltr_9.1 (j) 12.074 0.043 281.887 0.000 12.074 4.481
#> .edcltr_9.2 (j) 12.074 0.043 281.887 0.000 12.074 4.481
#> .edcltr_9.3 (j) 12.074 0.043 281.887 0.000 12.074 4.481
#> .edcltr_9.4 (j) 12.074 0.043 281.887 0.000 12.074 4.481
#> .edcltr_9.5 (j) 12.074 0.043 281.887 0.000 12.074 4.481
#> .edclt_10.1 (j) 12.074 0.043 281.887 0.000 12.074 4.383
#> .edclt_10.2 (j) 12.074 0.043 281.887 0.000 12.074 4.383
#> .edclt_10.3 (j) 12.074 0.043 281.887 0.000 12.074 4.383
#> .edclt_10.4 (j) 12.074 0.043 281.887 0.000 12.074 4.383
#> .edclt_10.5 (j) 12.074 0.043 281.887 0.000 12.074 4.383
#> .edclt_11.1 (j) 12.074 0.043 281.887 0.000 12.074 4.377
#> .edclt_11.2 (j) 12.074 0.043 281.887 0.000 12.074 4.377
#> .edclt_11.3 (j) 12.074 0.043 281.887 0.000 12.074 4.377
#> .edclt_11.4 (j) 12.074 0.043 281.887 0.000 12.074 4.377
#> .edclt_11.5 (j) 12.074 0.043 281.887 0.000 12.074 4.377
#> Feducltr_7 0.000 0.000 0.000
#>
#> Variances:
#> Estimate Std.Err z-value P(>|z|) Std.lv Std.all
#> .edcltr_7.1 (e) 5.225 0.096 54.622 0.000 5.225 0.664
#> .edcltr_7.2 (e) 5.225 0.096 54.622 0.000 5.225 0.664
#> .edcltr_7.3 (e) 5.225 0.096 54.622 0.000 5.225 0.664
#> .edcltr_7.4 (e) 5.225 0.096 54.622 0.000 5.225 0.664
#> .edcltr_7.5 (e) 5.225 0.096 54.622 0.000 5.225 0.664
#> .edcltr_8.1 (f) 4.824 0.087 55.707 0.000 4.824 0.648
#> .edcltr_8.2 (f) 4.824 0.087 55.707 0.000 4.824 0.648
#> .edcltr_8.3 (f) 4.824 0.087 55.707 0.000 4.824 0.648
#> .edcltr_8.4 (f) 4.824 0.087 55.707 0.000 4.824 0.648
#> .edcltr_8.5 (f) 4.824 0.087 55.707 0.000 4.824 0.648
#> .edcltr_9.1 (g) 4.617 0.082 56.602 0.000 4.617 0.636
#> .edcltr_9.2 (g) 4.617 0.082 56.602 0.000 4.617 0.636
#> .edcltr_9.3 (g) 4.617 0.082 56.602 0.000 4.617 0.636
#> .edcltr_9.4 (g) 4.617 0.082 56.602 0.000 4.617 0.636
#> .edcltr_9.5 (g) 4.617 0.082 56.602 0.000 4.617 0.636
#> .edclt_10.1 (h) 4.732 0.085 55.399 0.000 4.732 0.624
#> .edclt_10.2 (h) 4.732 0.085 55.399 0.000 4.732 0.624
#> .edclt_10.3 (h) 4.732 0.085 55.399 0.000 4.732 0.624
#> .edclt_10.4 (h) 4.732 0.085 55.399 0.000 4.732 0.624
#> .edclt_10.5 (h) 4.732 0.085 55.399 0.000 4.732 0.624
#> .edclt_11.1 (i) 5.115 0.104 49.074 0.000 5.115 0.672
#> .edclt_11.2 (i) 5.115 0.104 49.074 0.000 5.115 0.672
#> .edclt_11.3 (i) 5.115 0.104 49.074 0.000 5.115 0.672
#> .edclt_11.4 (i) 5.115 0.104 49.074 0.000 5.115 0.672
#> .edclt_11.5 (i) 5.115 0.104 49.074 0.000 5.115 0.672
#> eu_7 1.338 0.037 35.882 0.000 1.338 1.000
#> .eu_8 0.708 0.020 35.531 0.000 0.708 0.509
#> .eu_9 0.680 0.019 35.645 0.000 0.680 0.490
#> .eu_10 0.720 0.020 35.695 0.000 0.720 0.504
#> .eu_11 0.720 0.020 35.671 0.000 0.720 0.498
#> Feducltr_7 2.650 0.106 24.976 0.000 1.000 1.000
#> .Feducltr_8 -0.163 0.049 -3.318 0.001 -0.062 -0.062
#> .Feducltr_9 -0.119 0.044 -2.695 0.007 -0.045 -0.045
#> .Fedcltr_10 0.073 0.050 1.459 0.145 0.026 0.026
#> .Fedcltr_11 -0.509 0.055 -9.208 0.000 -0.204 -0.204
myModel <- '
# Estimate the lagged effects (constrained)
eu_8 ~ a*eu_7 + b*Feducalter_7
eu_9 ~ a*eu_8 + b*Feducalter_8
eu_10 ~ a*eu_9 + b*Feducalter_9
eu_11 ~ a*eu_10 + b*Feducalter_10
Feducalter_8 ~ c*eu_7 + d*Feducalter_7
Feducalter_9 ~ c*eu_8 + d*Feducalter_8
Feducalter_10 ~ c*eu_9 + d*Feducalter_9
Feducalter_11 ~ c*eu_10 + d*Feducalter_10
# Estimate the covariance at the first wave.
eu_7 ~~ Feducalter_7 # Covariance
# Estimate the covariances between the residuals
eu_8 ~~ Feducalter_8
eu_9 ~~ Feducalter_9
eu_10 ~~ Feducalter_10
eu_11 ~~ Feducalter_11
# Estimate the variance
eu_7 ~~ eu_7
Feducalter_7 ~~ Feducalter_7
# Estimate the residual variance
eu_8 ~~ eu_8
Feducalter_8 ~~ Feducalter_8
eu_9 ~~ eu_9
Feducalter_9 ~~ Feducalter_9
eu_10 ~~ eu_10
Feducalter_10 ~~ Feducalter_10
eu_11 ~~ eu_11
Feducalter_11 ~~ Feducalter_11
#intercepts
Feducalter_7 ~ 1
Feducalter_8 ~ 1
Feducalter_9 ~ 1
Feducalter_10 ~ 1
Feducalter_11 ~ 1
eu_7 ~ 1
eu_8 ~ 1
eu_9 ~ 1
eu_10 ~ 1
eu_11 ~ 1
'
fit <- lavaan(myModel, data = datalwb, missing = 'ML', meanstructure = T, int.ov.free = T)
summary(fit, standardized = T)
#> lavaan 0.6-7 ended normally after 23 iterations
#>
#> Estimator ML
#> Optimization method NLMINB
#> Number of free parameters 41
#> Number of equality constraints 12
#>
#> Number of observations 2575
#> Number of missing patterns 2
#>
#> Model Test User Model:
#>
#> Test statistic 2622.975
#> Degrees of freedom 36
#> P-value (Chi-square) 0.000
#>
#> Parameter Estimates:
#>
#> Standard errors Standard
#> Information Observed
#> Observed information based on Hessian
#>
#> Regressions:
#> Estimate Std.Err z-value P(>|z|) Std.lv Std.all
#> eu_8 ~
#> eu_7 (a) 0.693 0.007 95.356 0.000 0.693 0.679
#> Feducltr_7 (b) 0.077 0.009 8.842 0.000 0.077 0.068
#> eu_9 ~
#> eu_8 (a) 0.693 0.007 95.356 0.000 0.693 0.694
#> Feducltr_8 (b) 0.077 0.009 8.842 0.000 0.077 0.066
#> eu_10 ~
#> eu_9 (a) 0.693 0.007 95.356 0.000 0.693 0.683
#> Feducltr_9 (b) 0.077 0.009 8.842 0.000 0.077 0.063
#> eu_11 ~
#> eu_10 (a) 0.693 0.007 95.356 0.000 0.693 0.687
#> Fedcltr_10 (b) 0.077 0.009 8.842 0.000 0.077 0.062
#> Feducalter_8 ~
#> eu_7 (c) 0.073 0.006 11.633 0.000 0.073 0.084
#> Feducltr_7 (d) 0.632 0.007 85.127 0.000 0.632 0.650
#> Feducalter_9 ~
#> eu_8 (c) 0.073 0.006 11.633 0.000 0.073 0.087
#> Feducltr_8 (d) 0.632 0.007 85.127 0.000 0.632 0.649
#> Feducalter_10 ~
#> eu_9 (c) 0.073 0.006 11.633 0.000 0.073 0.089
#> Feducltr_9 (d) 0.632 0.007 85.127 0.000 0.632 0.644
#> Feducalter_11 ~
#> eu_10 (c) 0.073 0.006 11.633 0.000 0.073 0.093
#> Fedcltr_10 (d) 0.632 0.007 85.127 0.000 0.632 0.652
#>
#> Covariances:
#> Estimate Std.Err z-value P(>|z|) Std.lv Std.all
#> eu_7 ~~
#> Feducalter_7 0.251 0.025 10.258 0.000 0.251 0.209
#> .eu_8 ~~
#> .Feducalter_8 0.029 0.013 2.274 0.023 0.029 0.046
#> .eu_9 ~~
#> .Feducalter_9 0.004 0.012 0.333 0.739 0.004 0.007
#> .eu_10 ~~
#> .Feducalter_10 0.026 0.012 2.081 0.037 0.026 0.042
#> .eu_11 ~~
#> .Feducalter_11 0.032 0.012 2.733 0.006 0.032 0.055
#>
#> Intercepts:
#> Estimate Std.Err z-value P(>|z|) Std.lv Std.all
#> Feducalter_7 -0.003 0.021 -0.131 0.896 -0.003 -0.003
#> .Feducalter_8 0.009 0.017 0.556 0.578 0.009 0.009
#> .Feducalter_9 0.005 0.017 0.304 0.761 0.005 0.005
#> .Feducalter_10 0.063 0.016 3.838 0.000 0.063 0.065
#> .Feducalter_11 -0.054 0.016 -3.333 0.001 -0.054 -0.058
#> eu_7 1.263 0.023 55.406 0.000 1.263 1.092
#> .eu_8 0.450 0.019 23.660 0.000 0.450 0.382
#> .eu_9 0.346 0.019 18.370 0.000 0.346 0.294
#> .eu_10 0.525 0.019 27.533 0.000 0.525 0.440
#> .eu_11 0.509 0.020 25.940 0.000 0.509 0.423
#>
#> Variances:
#> Estimate Std.Err z-value P(>|z|) Std.lv Std.all
#> eu_7 1.338 0.037 35.882 0.000 1.338 1.000
#> Feducalter_7 1.079 0.031 35.307 0.000 1.079 1.000
#> .eu_8 0.716 0.020 35.868 0.000 0.716 0.515
#> .Feducalter_8 0.560 0.016 35.232 0.000 0.560 0.548
#> .eu_9 0.683 0.019 35.864 0.000 0.683 0.494
#> .Feducalter_9 0.529 0.015 35.269 0.000 0.529 0.546
#> .eu_10 0.727 0.020 35.855 0.000 0.727 0.511
#> .Feducalter_10 0.518 0.015 35.303 0.000 0.518 0.554
#> .eu_11 0.732 0.020 35.871 0.000 0.732 0.506
#> .Feducalter_11 0.474 0.013 35.304 0.000 0.474 0.540
myModel <- '
# Estimate the lagged effects (constrained)
eu_8 ~ a*eu_7 + b*Meducalter_7
eu_9 ~ a*eu_8 + b*Meducalter_8
eu_10 ~ a*eu_9 + b*Meducalter_9
eu_11 ~ a*eu_10 + b*Meducalter_10
Meducalter_8 ~ c*eu_7 + d*Meducalter_7
Meducalter_9 ~ c*eu_8 + d*Meducalter_8
Meducalter_10 ~ c*eu_9 + d*Meducalter_9
Meducalter_11 ~ c*eu_10 + d*Meducalter_10
# Estimate the covariance at the first wave.
eu_7 ~~ Meducalter_7 # Covariance
# Estimate the covariances between the residuals
eu_8 ~~ Meducalter_8
eu_9 ~~ Meducalter_9
eu_10 ~~ Meducalter_10
eu_11 ~~ Meducalter_11
# Estimate the variance
eu_7 ~~ eu_7
Meducalter_7 ~~ Meducalter_7
# Estimate the residual variance
eu_8 ~~ eu_8
Meducalter_8 ~~ Meducalter_8
eu_9 ~~ eu_9
Meducalter_9 ~~ Meducalter_9
eu_10 ~~ eu_10
Meducalter_10 ~~ Meducalter_10
eu_11 ~~ eu_11
Meducalter_11 ~~ Meducalter_11
#intercepts
Meducalter_7 ~ 1
Meducalter_8 ~ 1
Meducalter_9 ~ 1
Meducalter_10 ~ 1
Meducalter_11 ~ 1
eu_7 ~ 1
eu_8 ~ 1
eu_9 ~ 1
eu_10 ~ 1
eu_11 ~ 1
'
fit <- lavaan(myModel, data = datalwb, missing = 'ML', meanstructure = T, int.ov.free = T)
summary(fit, standardized = T)
#> lavaan 0.6-7 ended normally after 47 iterations
#>
#> Estimator ML
#> Optimization method NLMINB
#> Number of free parameters 41
#> Number of equality constraints 12
#>
#> Number of observations 2575
#> Number of missing patterns 32
#>
#> Model Test User Model:
#>
#> Test statistic 2287.451
#> Degrees of freedom 36
#> P-value (Chi-square) 0.000
#>
#> Parameter Estimates:
#>
#> Standard errors Standard
#> Information Observed
#> Observed information based on Hessian
#>
#> Regressions:
#> Estimate Std.Err z-value P(>|z|) Std.lv Std.all
#> eu_8 ~
#> eu_7 (a) 0.691 0.007 94.436 0.000 0.691 0.678
#> Meducltr_7 (b) 0.038 0.004 8.907 0.000 0.038 0.069
#> eu_9 ~
#> eu_8 (a) 0.691 0.007 94.436 0.000 0.691 0.692
#> Meducltr_8 (b) 0.038 0.004 8.907 0.000 0.038 0.070
#> eu_10 ~
#> eu_9 (a) 0.691 0.007 94.436 0.000 0.691 0.681
#> Meducltr_9 (b) 0.038 0.004 8.907 0.000 0.038 0.067
#> eu_11 ~
#> eu_10 (a) 0.691 0.007 94.436 0.000 0.691 0.685
#> Medcltr_10 (b) 0.038 0.004 8.907 0.000 0.038 0.067
#> Meducalter_8 ~
#> eu_7 (c) 0.138 0.013 10.468 0.000 0.138 0.074
#> Meducltr_7 (d) 0.723 0.008 95.777 0.000 0.723 0.712
#> Meducalter_9 ~
#> eu_8 (c) 0.138 0.013 10.468 0.000 0.138 0.078
#> Meducltr_8 (d) 0.723 0.008 95.777 0.000 0.723 0.740
#> Meducalter_10 ~
#> eu_9 (c) 0.138 0.013 10.468 0.000 0.138 0.077
#> Meducltr_9 (d) 0.723 0.008 95.777 0.000 0.723 0.719
#> Meducalter_11 ~
#> eu_10 (c) 0.138 0.013 10.468 0.000 0.138 0.079
#> Medcltr_10 (d) 0.723 0.008 95.777 0.000 0.723 0.729
#>
#> Covariances:
#> Estimate Std.Err z-value P(>|z|) Std.lv Std.all
#> eu_7 ~~
#> Meducalter_7 0.550 0.052 10.592 0.000 0.550 0.225
#> .eu_8 ~~
#> .Meducalter_8 0.054 0.027 1.962 0.050 0.054 0.044
#> .eu_9 ~~
#> .Meducalter_9 0.033 0.025 1.337 0.181 0.033 0.030
#> .eu_10 ~~
#> .Meducalter_10 0.050 0.026 1.899 0.058 0.050 0.042
#> .eu_11 ~~
#> .Meducalter_11 0.079 0.027 2.862 0.004 0.079 0.067
#>
#> Intercepts:
#> Estimate Std.Err z-value P(>|z|) Std.lv Std.all
#> Meducalter_7 12.105 0.044 275.851 0.000 12.105 5.735
#> .Meducalter_8 3.260 0.095 34.423 0.000 3.260 1.520
#> .Meducalter_9 3.227 0.095 34.125 0.000 3.227 1.540
#> .Meducalter_10 3.285 0.095 34.494 0.000 3.285 1.559
#> .Meducalter_11 3.207 0.096 33.521 0.000 3.207 1.535
#> eu_7 1.263 0.023 55.406 0.000 1.263 1.092
#> .eu_8 -0.011 0.053 -0.201 0.841 -0.011 -0.009
#> .eu_9 -0.110 0.053 -2.059 0.039 -0.110 -0.093
#> .eu_10 0.073 0.054 1.354 0.176 0.073 0.061
#> .eu_11 0.061 0.054 1.137 0.255 0.061 0.051
#>
#> Variances:
#> Estimate Std.Err z-value P(>|z|) Std.lv Std.all
#> eu_7 1.338 0.037 35.882 0.000 1.338 1.000
#> Meducalter_7 4.455 0.134 33.356 0.000 4.455 1.000
#> .eu_8 0.714 0.020 35.841 0.000 0.714 0.515
#> .Meducalter_8 2.134 0.068 31.221 0.000 2.134 0.464
#> .eu_9 0.684 0.019 35.843 0.000 0.684 0.494
#> .Meducalter_9 1.846 0.059 31.157 0.000 1.846 0.420
#> .eu_10 0.726 0.020 35.836 0.000 0.726 0.510
#> .Meducalter_10 2.001 0.064 31.171 0.000 2.001 0.451
#> .eu_11 0.730 0.020 35.842 0.000 0.730 0.504
#> .Meducalter_11 1.895 0.062 30.538 0.000 1.895 0.434
Be aware that Mulder is using cfa
and thus allows for all covariances between the factors. Why are the residual variances set to zero? we are assuming that the indicators and the ri perfectly predict the factors. no measurement error.??
RICLPM5.ext3 <- '
#####################
# MEASUREMENT MODEL #
#####################
# Factor models for x at 5 waves (constrained).
FX1 =~ a*x11 + b*x12 + c*x13
FX2 =~ a*x21 + b*x22 + c*x23
FX3 =~ a*x31 + b*x32 + c*x33
FX4 =~ a*x41 + b*x42 + c*x43
FX5 =~ a*x51 + b*x52 + c*x53
# Factor models for y at 5 waves (constrained).
FY1 =~ d*y11 + e*y12 + f*y13
FY2 =~ d*y21 + e*y22 + f*y23
FY3 =~ d*y31 + e*y32 + f*y33
FY4 =~ d*y41 + e*y42 + f*y43
FY5 =~ d*y51 + e*y52 + f*y53
# Constrained intercepts over time (this is necessary for strong factorial
# invariance; without these contraints we have week factorial invariance).
x11 + x21 + x31 + x41 + x51 ~ g*1
x12 + x22 + x32 + x42 + x52 ~ h*1
x13 + x23 + x33 + x43 + x53 ~ i*1
y11 + y21 + y31 + y41 + y51 ~ j*1
y12 + y22 + y32 + y42 + y52 ~ k*1
y13 + y23 + y33 + y43 + y53 ~ l*1
# Free latent means from t = 2 onward (only do this in combination with the
# constraints on the intercepts; without these, this would not be specified).
FX2 + FX3 + FX4 + FX5 + FY2 + FY3 + FY4 + FY5 ~ 1
################
# BETWEEN PART #
################
# Create between factors (random intercepts).
RIX =~ 1*FX1 + 1*FX2 + 1*FX3 + 1*FX4 + 1*FX5
RIY =~ 1*FY1 + 1*FY2 + 1*FY3 + 1*FY4 + 1*FY5
# Set the residual variances of all FX and FY variables to 0.
FX1 ~~ 0*FX1
FX2 ~~ 0*FX2
FX3 ~~ 0*FX3
FX4 ~~ 0*FX4
FX5 ~~ 0*FX5
FY1 ~~ 0*FY1
FY2 ~~ 0*FY2
FY3 ~~ 0*FY3
FY4 ~~ 0*FY4
FY5 ~~ 0*FY5
###############
# WITHIN PART #
###############
# Create the within-part.
WFX1 =~ 1*FX1
WFX2 =~ 1*FX2
WFX3 =~ 1*FX3
WFX4 =~ 1*FX4
WFX5 =~ 1*FX5
WFY1 =~ 1*FY1
WFY2 =~ 1*FY2
WFY3 =~ 1*FY3
WFY4 =~ 1*FY4
WFY5 =~ 1*FY5
# Specify the lagged effects between the within-person centered latent variables.
WFX2 + WFY2 ~ WFX1 + WFY1
WFX3 + WFY3 ~ WFX2 + WFY2
WFX4 + WFY4 ~ WFX3 + WFY3
WFX5 + WFY5 ~ WFX4 + WFY4
# Estimate the correlations within the same wave.
WFX2 ~~ WFY2
WFX3 ~~ WFY3
WFX4 ~~ WFY4
WFX5 ~~ WFY5
##########################
# ADDITIONAL CONSTRAINTS #
##########################
# Set correlations between the between-factors (random intercepts) and within-
# factors at wave 1 at 0.
RIX + RIY ~~ 0*WFX1 + 0*WFY1
'
RICLPM5.ext3.fit <- cfa(RICLPM5.ext3, data = datMI, missing = 'ML')
summary(RICLPM5.ext3.fit, standardized = T)
#> lavaan 0.6-7 ended normally after 105 iterations
#>
#> Estimator ML
#> Optimization method NLMINB
#> Number of free parameters 122
#> Number of equality constraints 40
#>
#> Number of observations 1189
#> Number of missing patterns 1
#>
#> Model Test User Model:
#>
#> Test statistic 381.605
#> Degrees of freedom 413
#> P-value (Chi-square) 0.864
#>
#> Parameter Estimates:
#>
#> Standard errors Standard
#> Information Observed
#> Observed information based on Hessian
#>
#> Latent Variables:
#> Estimate Std.Err z-value P(>|z|) Std.lv Std.all
#> FX1 =~
#> x11 (a) 1.000 0.294 0.391
#> x12 (b) 0.847 0.098 8.663 0.000 0.249 0.318
#> x13 (c) 0.779 0.091 8.578 0.000 0.229 0.310
#> FX2 =~
#> x21 (a) 1.000 0.223 0.307
#> x22 (b) 0.847 0.098 8.663 0.000 0.189 0.254
#> x23 (c) 0.779 0.091 8.578 0.000 0.174 0.244
#> FX3 =~
#> x31 (a) 1.000 0.243 0.344
#> x32 (b) 0.847 0.098 8.663 0.000 0.206 0.288
#> x33 (c) 0.779 0.091 8.578 0.000 0.189 0.250
#> FX4 =~
#> x41 (a) 1.000 0.263 0.348
#> x42 (b) 0.847 0.098 8.663 0.000 0.222 0.298
#> x43 (c) 0.779 0.091 8.578 0.000 0.205 0.272
#> FX5 =~
#> x51 (a) 1.000 0.239 0.322
#> x52 (b) 0.847 0.098 8.663 0.000 0.202 0.270
#> x53 (c) 0.779 0.091 8.578 0.000 0.186 0.253
#> FY1 =~
#> y11 (d) 1.000 0.289 0.371
#> y12 (e) 1.129 0.081 13.866 0.000 0.326 0.416
#> y13 (f) 1.140 0.080 14.172 0.000 0.329 0.426
#> FY2 =~
#> y21 (d) 1.000 0.317 0.411
#> y22 (e) 1.129 0.081 13.866 0.000 0.358 0.479
#> y23 (f) 1.140 0.080 14.172 0.000 0.361 0.447
#> FY3 =~
#> y31 (d) 1.000 0.263 0.347
#> y32 (e) 1.129 0.081 13.866 0.000 0.297 0.377
#> y33 (f) 1.140 0.080 14.172 0.000 0.300 0.377
#> FY4 =~
#> y41 (d) 1.000 0.291 0.371
#> y42 (e) 1.129 0.081 13.866 0.000 0.329 0.425
#> y43 (f) 1.140 0.080 14.172 0.000 0.332 0.432
#> FY5 =~
#> y51 (d) 1.000 0.310 0.398
#> y52 (e) 1.129 0.081 13.866 0.000 0.350 0.442
#> y53 (f) 1.140 0.080 14.172 0.000 0.354 0.457
#> RIX =~
#> FX1 1.000 0.410 0.410
#> FX2 1.000 0.541 0.541
#> FX3 1.000 0.496 0.496
#> FX4 1.000 0.459 0.459
#> FX5 1.000 0.505 0.505
#> RIY =~
#> FY1 1.000 0.523 0.523
#> FY2 1.000 0.477 0.477
#> FY3 1.000 0.575 0.575
#> FY4 1.000 0.519 0.519
#> FY5 1.000 0.487 0.487
#> WFX1 =~
#> FX1 1.000 0.912 0.912
#> WFX2 =~
#> FX2 1.000 0.841 0.841
#> WFX3 =~
#> FX3 1.000 0.868 0.868
#> WFX4 =~
#> FX4 1.000 0.888 0.888
#> WFX5 =~
#> FX5 1.000 0.863 0.863
#> WFY1 =~
#> FY1 1.000 0.852 0.852
#> WFY2 =~
#> FY2 1.000 0.879 0.879
#> WFY3 =~
#> FY3 1.000 0.818 0.818
#> WFY4 =~
#> FY4 1.000 0.855 0.855
#> WFY5 =~
#> FY5 1.000 0.873 0.873
#>
#> Regressions:
#> Estimate Std.Err z-value P(>|z|) Std.lv Std.all
#> WFX2 ~
#> WFX1 0.227 0.142 1.597 0.110 0.324 0.324
#> WFY1 -0.239 0.145 -1.645 0.100 -0.313 -0.313
#> WFY2 ~
#> WFX1 0.044 0.119 0.368 0.713 0.042 0.042
#> WFY1 0.214 0.143 1.492 0.136 0.189 0.189
#> WFX3 ~
#> WFX2 0.181 0.257 0.703 0.482 0.161 0.161
#> WFY2 -0.187 0.113 -1.659 0.097 -0.246 -0.246
#> WFY3 ~
#> WFX2 0.236 0.199 1.184 0.236 0.206 0.206
#> WFY2 0.404 0.100 4.035 0.000 0.523 0.523
#> WFX4 ~
#> WFX3 0.494 0.210 2.349 0.019 0.447 0.447
#> WFY3 0.027 0.164 0.164 0.870 0.025 0.025
#> WFY4 ~
#> WFX3 -0.127 0.170 -0.747 0.455 -0.108 -0.108
#> WFY3 0.643 0.167 3.843 0.000 0.555 0.555
#> WFX5 ~
#> WFX4 0.227 0.176 1.293 0.196 0.257 0.257
#> WFY4 -0.018 0.125 -0.145 0.885 -0.022 -0.022
#> WFY5 ~
#> WFX4 0.094 0.147 0.643 0.521 0.081 0.081
#> WFY4 0.439 0.125 3.503 0.000 0.403 0.403
#>
#> Covariances:
#> Estimate Std.Err z-value P(>|z|) Std.lv Std.all
#> .WFX2 ~~
#> .WFY2 -0.007 0.008 -0.902 0.367 -0.151 -0.151
#> .WFX3 ~~
#> .WFY3 0.002 0.007 0.333 0.739 0.066 0.066
#> .WFX4 ~~
#> .WFY4 -0.001 0.008 -0.171 0.864 -0.031 -0.031
#> .WFX5 ~~
#> .WFY5 0.003 0.007 0.456 0.649 0.068 0.068
#> RIX ~~
#> WFX1 0.000 0.000 0.000
#> WFY1 0.000 0.000 0.000
#> RIY ~~
#> WFX1 0.000 0.000 0.000
#> WFY1 0.000 0.000 0.000
#> RIX ~~
#> RIY 0.016 0.004 3.764 0.000 0.901 0.901
#> WFX1 ~~
#> WFY1 -0.009 0.008 -1.026 0.305 -0.130 -0.130
#>
#> Intercepts:
#> Estimate Std.Err z-value P(>|z|) Std.lv Std.all
#> .x11 (g) 0.272 0.018 15.080 0.000 0.272 0.361
#> .x21 (g) 0.272 0.018 15.080 0.000 0.272 0.375
#> .x31 (g) 0.272 0.018 15.080 0.000 0.272 0.385
#> .x41 (g) 0.272 0.018 15.080 0.000 0.272 0.360
#> .x51 (g) 0.272 0.018 15.080 0.000 0.272 0.367
#> .x12 (h) 0.253 0.017 15.133 0.000 0.253 0.324
#> .x22 (h) 0.253 0.017 15.133 0.000 0.253 0.340
#> .x32 (h) 0.253 0.017 15.133 0.000 0.253 0.354
#> .x42 (h) 0.253 0.017 15.133 0.000 0.253 0.339
#> .x52 (h) 0.253 0.017 15.133 0.000 0.253 0.337
#> .x13 (i) 0.268 0.016 16.820 0.000 0.268 0.363
#> .x23 (i) 0.268 0.016 16.820 0.000 0.268 0.376
#> .x33 (i) 0.268 0.016 16.820 0.000 0.268 0.353
#> .x43 (i) 0.268 0.016 16.820 0.000 0.268 0.356
#> .x53 (i) 0.268 0.016 16.820 0.000 0.268 0.365
#> .y11 (j) 0.324 0.016 20.376 0.000 0.324 0.417
#> .y21 (j) 0.324 0.016 20.376 0.000 0.324 0.421
#> .y31 (j) 0.324 0.016 20.376 0.000 0.324 0.429
#> .y41 (j) 0.324 0.016 20.376 0.000 0.324 0.413
#> .y51 (j) 0.324 0.016 20.376 0.000 0.324 0.416
#> .y12 (k) 0.331 0.017 19.214 0.000 0.331 0.422
#> .y22 (k) 0.331 0.017 19.214 0.000 0.331 0.444
#> .y32 (k) 0.331 0.017 19.214 0.000 0.331 0.421
#> .y42 (k) 0.331 0.017 19.214 0.000 0.331 0.428
#> .y52 (k) 0.331 0.017 19.214 0.000 0.331 0.418
#> .y13 (l) 0.325 0.017 18.742 0.000 0.325 0.420
#> .y23 (l) 0.325 0.017 18.742 0.000 0.325 0.401
#> .y33 (l) 0.325 0.017 18.742 0.000 0.325 0.408
#> .y43 (l) 0.325 0.017 18.742 0.000 0.325 0.422
#> .y53 (l) 0.325 0.017 18.742 0.000 0.325 0.419
#> .FX2 -0.077 0.021 -3.713 0.000 -0.346 -0.346
#> .FX3 -0.074 0.022 -3.416 0.001 -0.303 -0.303
#> .FX4 -0.158 0.023 -6.753 0.000 -0.600 -0.600
#> .FX5 -0.179 0.023 -7.636 0.000 -0.752 -0.752
#> .FY2 0.034 0.018 1.897 0.058 0.109 0.109
#> .FY3 0.016 0.018 0.906 0.365 0.063 0.063
#> .FY4 0.048 0.018 2.593 0.010 0.164 0.164
#> .FY5 0.052 0.019 2.791 0.005 0.169 0.169
#> .FX1 0.000 0.000 0.000
#> .FY1 0.000 0.000 0.000
#> RIX 0.000 0.000 0.000
#> RIY 0.000 0.000 0.000
#> WFX1 0.000 0.000 0.000
#> .WFX2 0.000 0.000 0.000
#> .WFX3 0.000 0.000 0.000
#> .WFX4 0.000 0.000 0.000
#> .WFX5 0.000 0.000 0.000
#> WFY1 0.000 0.000 0.000
#> .WFY2 0.000 0.000 0.000
#> .WFY3 0.000 0.000 0.000
#> .WFY4 0.000 0.000 0.000
#> .WFY5 0.000 0.000 0.000
#>
#> Variances:
#> Estimate Std.Err z-value P(>|z|) Std.lv Std.all
#> .FX1 0.000 0.000 0.000
#> .FX2 0.000 0.000 0.000
#> .FX3 0.000 0.000 0.000
#> .FX4 0.000 0.000 0.000
#> .FX5 0.000 0.000 0.000
#> .FY1 0.000 0.000 0.000
#> .FY2 0.000 0.000 0.000
#> .FY3 0.000 0.000 0.000
#> .FY4 0.000 0.000 0.000
#> .FY5 0.000 0.000 0.000
#> .x11 0.479 0.026 18.584 0.000 0.479 0.847
#> .x12 0.549 0.026 20.982 0.000 0.549 0.899
#> .x13 0.493 0.023 21.370 0.000 0.493 0.904
#> .x21 0.477 0.023 20.329 0.000 0.477 0.905
#> .x22 0.517 0.023 22.082 0.000 0.517 0.935
#> .x23 0.478 0.021 22.353 0.000 0.478 0.941
#> .x31 0.441 0.023 19.256 0.000 0.441 0.882
#> .x32 0.469 0.022 21.289 0.000 0.469 0.917
#> .x33 0.539 0.024 22.583 0.000 0.539 0.938
#> .x41 0.500 0.025 19.841 0.000 0.500 0.879
#> .x42 0.506 0.024 21.169 0.000 0.506 0.911
#> .x43 0.526 0.024 21.573 0.000 0.526 0.926
#> .x51 0.492 0.025 19.637 0.000 0.492 0.896
#> .x52 0.522 0.024 21.852 0.000 0.522 0.927
#> .x53 0.505 0.023 21.990 0.000 0.505 0.936
#> .y11 0.523 0.025 21.185 0.000 0.523 0.862
#> .y12 0.509 0.025 19.971 0.000 0.509 0.827
#> .y13 0.488 0.025 19.378 0.000 0.488 0.818
#> .y21 0.494 0.024 20.929 0.000 0.494 0.831
#> .y22 0.429 0.023 18.996 0.000 0.429 0.770
#> .y23 0.523 0.026 20.020 0.000 0.523 0.800
#> .y31 0.503 0.023 21.725 0.000 0.503 0.879
#> .y32 0.531 0.025 20.917 0.000 0.531 0.858
#> .y33 0.542 0.026 21.161 0.000 0.542 0.858
#> .y41 0.531 0.025 21.501 0.000 0.531 0.862
#> .y42 0.491 0.024 20.214 0.000 0.491 0.820
#> .y43 0.480 0.024 20.207 0.000 0.480 0.813
#> .y51 0.511 0.024 20.929 0.000 0.511 0.841
#> .y52 0.506 0.025 19.870 0.000 0.506 0.805
#> .y53 0.474 0.025 19.165 0.000 0.474 0.791
#> RIX 0.015 0.006 2.371 0.018 1.000 1.000
#> RIY 0.023 0.007 3.455 0.001 1.000 1.000
#> WFX1 0.072 0.017 4.102 0.000 1.000 1.000
#> .WFX2 0.027 0.014 1.988 0.047 0.771 0.771
#> .WFX3 0.040 0.014 2.864 0.004 0.899 0.899
#> .WFX4 0.044 0.015 2.891 0.004 0.801 0.801
#> .WFX5 0.040 0.014 2.811 0.005 0.933 0.933
#> WFY1 0.061 0.012 4.931 0.000 1.000 1.000
#> .WFY2 0.075 0.013 5.983 0.000 0.965 0.965
#> .WFY3 0.033 0.010 3.291 0.001 0.723 0.723
#> .WFY4 0.042 0.011 3.895 0.000 0.675 0.675
#> .WFY5 0.061 0.011 5.362 0.000 0.835 0.835
RICLPM5.ext3 <- '
################
# BETWEEN PART #
################
# Create between factors (random intercepts).
RIX =~ 1*FX1 + 1*FX2 + 1*FX3 + 1*FX4 + 1*FX5
RIY =~ 1*FY1 + 1*FY2 + 1*FY3 + 1*FY4 + 1*FY5
# Estimate the variance and covariance of the random intercepts.
RIX ~~ RIX
RIY ~~ RIY
RIX ~~ RIY
###############
# WITHIN PART #
###############
# Create the within-part.
WFX1 =~ 1*FX1
WFX2 =~ 1*FX2
WFX3 =~ 1*FX3
WFX4 =~ 1*FX4
WFX5 =~ 1*FX5
WFY1 =~ 1*FY1
WFY2 =~ 1*FY2
WFY3 =~ 1*FY3
WFY4 =~ 1*FY4
WFY5 =~ 1*FY5
# Specify the lagged effects between the within-person centered latent variables.
WFX2 + WFY2 ~ WFX1 + WFY1
WFX3 + WFY3 ~ WFX2 + WFY2
WFX4 + WFY4 ~ WFX3 + WFY3
WFX5 + WFY5 ~ WFX4 + WFY4
# Estimate the COVARIANCE within the same wave.
WFX2 ~~ WFY2
# Estimate the RESIDUAL COVARIANCE within the same wave.
WFX2 ~~ WFY2
WFX3 ~~ WFY3
WFX4 ~~ WFY4
WFX5 ~~ WFY5
# Estimate the (residual) variance of the within-person centered variables.
WFX1 ~~ WFX1 # Variances
WFY1 ~~ WFY1 # Variances
WFX2 ~~ WFX2 # Residual variances
WFX3 ~~ WFX3 # Residual variances
WFX4 ~~ WFX4 # Residual variances
WFX5 ~~ WFX5 # Residual variances
WFY2 ~~ WFY2 # Residual variances
WFY3 ~~ WFY3 # Residual variances
WFY4 ~~ WFY4 # Residual variances
WFY5 ~~ WFY5 # Residual variances
# intercepts
FX1 ~ 1
FX2 ~ 1
FX3 ~ 1
FX4 ~ 1
FX5 ~ 1
FY1 ~ 1
FY2 ~ 1
FY3 ~ 1
FY4 ~ 1
FY5 ~ 1
##########################
# ADDITIONAL CONSTRAINTS #
##########################
# Set correlations between the between-factors (random intercepts) and within-
# factors at wave 1 at 0.
RIX + RIY ~~ 0*WFX1 + 0*WFY1
'
RICLPM5.ext3.fit <- lavaan(RICLPM5.ext3, data = datMIb, missing = 'ML', meanstructure = T, int.ov.free = T)
summary(RICLPM5.ext3.fit, standardized = T)
#> lavaan 0.6-7 ended normally after 201 iterations
#>
#> Estimator ML
#> Optimization method NLMINB
#> Number of free parameters 43
#>
#> Number of observations 1189
#> Number of missing patterns 1
#>
#> Model Test User Model:
#>
#> Test statistic 1051.841
#> Degrees of freedom 22
#> P-value (Chi-square) 0.000
#>
#> Parameter Estimates:
#>
#> Standard errors Standard
#> Information Observed
#> Observed information based on Hessian
#>
#> Latent Variables:
#> Estimate Std.Err z-value P(>|z|) Std.lv Std.all
#> RIX =~
#> FX1 1.000 0.060 0.314
#> FX2 1.000 0.060 0.485
#> FX3 1.000 0.060 0.456
#> FX4 1.000 0.060 0.416
#> FX5 1.000 0.060 0.492
#> RIY =~
#> FY1 1.000 0.150 0.673
#> FY2 1.000 0.150 0.585
#> FY3 1.000 0.150 0.763
#> FY4 1.000 0.150 0.709
#> FY5 1.000 0.150 0.684
#> WFX1 =~
#> FX1 1.000 0.182 0.949
#> WFX2 =~
#> FX2 1.000 0.109 0.874
#> WFX3 =~
#> FX3 1.000 0.118 0.890
#> WFX4 =~
#> FX4 1.000 0.132 0.909
#> WFX5 =~
#> FX5 1.000 0.107 0.871
#> WFY1 =~
#> FY1 1.000 0.164 0.739
#> WFY2 =~
#> FY2 1.000 0.207 0.811
#> WFY3 =~
#> FY3 1.000 0.127 0.646
#> WFY4 =~
#> FY4 1.000 0.149 0.705
#> WFY5 =~
#> FY5 1.000 0.160 0.729
#>
#> Regressions:
#> Estimate Std.Err z-value P(>|z|) Std.lv Std.all
#> WFX2 ~
#> WFX1 0.475 0.024 20.135 0.000 0.795 0.795
#> WFY1 -0.311 0.019 -16.144 0.000 -0.470 -0.470
#> WFY2 ~
#> WFX1 0.096 0.032 2.961 0.003 0.084 0.084
#> WFY1 0.637 0.044 14.466 0.000 0.505 0.505
#> WFX3 ~
#> WFX2 0.525 0.042 12.612 0.000 0.485 0.485
#> WFY2 -0.205 0.016 -12.604 0.000 -0.361 -0.361
#> WFY3 ~
#> WFX2 -0.009 0.046 -0.198 0.843 -0.008 -0.008
#> WFY2 0.483 0.017 28.237 0.000 0.789 0.789
#> WFX4 ~
#> WFX3 0.891 0.030 29.798 0.000 0.796 0.796
#> WFY3 0.075 0.028 2.634 0.008 0.072 0.072
#> WFY4 ~
#> WFX3 -0.183 0.058 -3.181 0.001 -0.145 -0.145
#> WFY3 0.776 0.049 15.942 0.000 0.662 0.662
#> WFX5 ~
#> WFX4 0.430 0.034 12.576 0.000 0.530 0.530
#> WFY4 -0.072 0.025 -2.890 0.004 -0.100 -0.100
#> WFY5 ~
#> WFX4 -0.137 0.035 -3.936 0.000 -0.113 -0.113
#> WFY4 0.546 0.033 16.351 0.000 0.509 0.509
#>
#> Covariances:
#> Estimate Std.Err z-value P(>|z|) Std.lv Std.all
#> RIX ~~
#> RIY 0.017 0.001 20.337 0.000 1.846 1.846
#> .WFX2 ~~
#> .WFY2 -0.003 0.000 -6.246 0.000 -0.398 -0.398
#> .WFX3 ~~
#> .WFY3 -0.002 0.000 -9.503 0.000 -0.301 -0.301
#> .WFX4 ~~
#> .WFY4 0.000 0.000 1.820 0.069 0.054 0.054
#> .WFX5 ~~
#> .WFY5 -0.000 0.000 -0.428 0.669 -0.014 -0.014
#> RIX ~~
#> WFX1 0.000 0.000 0.000
#> WFY1 0.000 0.000 0.000
#> RIY ~~
#> WFX1 0.000 0.000 0.000
#> WFY1 0.000 0.000 0.000
#>
#> Intercepts:
#> Estimate Std.Err z-value P(>|z|) Std.lv Std.all
#> .FX1 -0.000 0.006 -0.000 1.000 -0.000 -0.000
#> .FX2 -0.077 0.004 -21.491 0.000 -0.077 -0.623
#> .FX3 -0.074 0.004 -19.240 0.000 -0.074 -0.558
#> .FX4 -0.158 0.004 -37.605 0.000 -0.158 -1.091
#> .FX5 -0.180 0.004 -50.542 0.000 -0.180 -1.466
#> .FY1 -0.000 0.006 -0.000 1.000 -0.000 -0.000
#> .FY2 0.034 0.007 4.654 0.000 0.034 0.135
#> .FY3 0.016 0.006 2.892 0.004 0.016 0.084
#> .FY4 0.048 0.006 7.859 0.000 0.048 0.228
#> .FY5 0.053 0.006 8.290 0.000 0.053 0.240
#> RIX 0.000 0.000 0.000
#> RIY 0.000 0.000 0.000
#> WFX1 0.000 0.000 0.000
#> .WFX2 0.000 0.000 0.000
#> .WFX3 0.000 0.000 0.000
#> .WFX4 0.000 0.000 0.000
#> .WFX5 0.000 0.000 0.000
#> WFY1 0.000 0.000 0.000
#> .WFY2 0.000 0.000 0.000
#> .WFY3 0.000 0.000 0.000
#> .WFY4 0.000 0.000 0.000
#> .WFY5 0.000 0.000 0.000
#>
#> Variances:
#> Estimate Std.Err z-value P(>|z|) Std.lv Std.all
#> RIX 0.004 0.001 4.106 0.000 1.000 1.000
#> RIY 0.022 0.001 15.702 0.000 1.000 1.000
#> WFX1 0.033 0.002 16.589 0.000 1.000 1.000
#> WFY1 0.027 0.002 14.171 0.000 1.000 1.000
#> .WFX2 0.002 0.000 7.476 0.000 0.147 0.147
#> .WFX3 0.007 0.000 22.434 0.000 0.529 0.529
#> .WFX4 0.007 0.000 24.835 0.000 0.423 0.423
#> .WFX5 0.008 0.000 20.716 0.000 0.674 0.674
#> .WFY2 0.032 0.001 23.521 0.000 0.738 0.738
#> .WFY3 0.006 0.000 20.176 0.000 0.374 0.374
#> .WFY4 0.010 0.000 21.608 0.000 0.438 0.438
#> .WFY5 0.018 0.001 22.051 0.000 0.691 0.691
#> .FX1 0.000 0.000 0.000
#> .FX2 0.000 0.000 0.000
#> .FX3 0.000 0.000 0.000
#> .FX4 0.000 0.000 0.000
#> .FX5 0.000 0.000 0.000
#> .FY1 0.000 0.000 0.000
#> .FY2 0.000 0.000 0.000
#> .FY3 0.000 0.000 0.000
#> .FY4 0.000 0.000 0.000
#> .FY5 0.000 0.000 0.000
myModel <- '
##################
#measurement part#
##################
#alters are identical thus equal loadings, variances and intercepts at each time point.
#constrained loadings
Feducalter_7 =~ 1*educalter_7.1 + 1*educalter_7.2 + 1*educalter_7.3 + 1*educalter_7.4 + 1*educalter_7.5
Feducalter_8 =~ 1*educalter_8.1 + 1*educalter_8.2 + 1*educalter_8.3 + 1*educalter_8.4 + 1*educalter_8.5
Feducalter_9 =~ 1*educalter_9.1 + 1*educalter_9.2 + 1*educalter_9.3 + 1*educalter_9.4 + 1*educalter_9.5
Feducalter_10 =~ 1*educalter_10.1 + 1*educalter_10.2 + 1*educalter_10.3 + 1*educalter_10.4 + 1*educalter_10.5
Feducalter_11 =~ 1*educalter_11.1 + 1*educalter_11.2 + 1*educalter_11.3 + 1*educalter_11.4 + 1*educalter_11.5
#constrained variances
educalter_7.1 ~~ e*educalter_7.1
educalter_7.2 ~~ e*educalter_7.2
educalter_7.3 ~~ e*educalter_7.3
educalter_7.4 ~~ e*educalter_7.4
educalter_7.5 ~~ e*educalter_7.5
educalter_8.1 ~~ f*educalter_8.1
educalter_8.2 ~~ f*educalter_8.2
educalter_8.3 ~~ f*educalter_8.3
educalter_8.4 ~~ f*educalter_8.4
educalter_8.5 ~~ f*educalter_8.5
educalter_9.1 ~~ g*educalter_9.1
educalter_9.2 ~~ g*educalter_9.2
educalter_9.3 ~~ g*educalter_9.3
educalter_9.4 ~~ g*educalter_9.4
educalter_9.5 ~~ g*educalter_9.5
educalter_10.1 ~~ h*educalter_10.1
educalter_10.2 ~~ h*educalter_10.2
educalter_10.3 ~~ h*educalter_10.3
educalter_10.4 ~~ h*educalter_10.4
educalter_10.5 ~~ h*educalter_10.5
educalter_11.1 ~~ i*educalter_11.1
educalter_11.2 ~~ i*educalter_11.2
educalter_11.3 ~~ i*educalter_11.3
educalter_11.4 ~~ i*educalter_11.4
educalter_11.5 ~~ i*educalter_11.5
#constrained intercepts
educalter_7.1 ~ j*1
educalter_7.2 ~ j*1
educalter_7.3 ~ j*1
educalter_7.4 ~ j*1
educalter_7.5 ~ j*1
educalter_8.1 ~ j*1
educalter_8.2 ~ j*1
educalter_8.3 ~ j*1
educalter_8.4 ~ j*1
educalter_8.5 ~ j*1
educalter_9.1 ~ j*1
educalter_9.2 ~ j*1
educalter_9.3 ~ j*1
educalter_9.4 ~ j*1
educalter_9.5 ~ j*1
educalter_10.1 ~ j*1
educalter_10.2 ~ j*1
educalter_10.3 ~ j*1
educalter_10.4 ~ j*1
educalter_10.5 ~ j*1
educalter_11.1 ~ j*1
educalter_11.2 ~ j*1
educalter_11.3 ~ j*1
educalter_11.4 ~ j*1
educalter_11.5 ~ j*1
# Free latent means from t = 2 onward.
Feducalter_8 ~ 1
Feducalter_9 ~ 1
Feducalter_10 ~ 1
Feducalter_11 ~ 1
#################
#structural part#
#################
# Create between components (random intercepts)
RIx =~ 1*Feducalter_7 + 1*Feducalter_8 + 1*Feducalter_9 + 1*Feducalter_10 + 1*Feducalter_11
RIy =~ 1*eu_7 + 1*eu_8 + 1*eu_9 + 1*eu_10 + 1*eu_11
# Set the residual variances of all FX variables to 0. I DONT UNDERSTAND THIS! no measurement error?? how do we deal with this in the two-step approach? if i do i get negative variance of within components.
#Feducalter_7 ~~ 0*Feducalter_7
#Feducalter_8 ~~ 0*Feducalter_8
#Feducalter_9 ~~ 0*Feducalter_9
#Feducalter_10 ~~ 0*Feducalter_10
#Feducalter_11 ~~ 0*Feducalter_11
# Create within-person centered variables.
wFeducalter_7 =~ 1*Feducalter_7
wFeducalter_8 =~ 1*Feducalter_8
wFeducalter_9 =~ 1*Feducalter_9
wFeducalter_10 =~ 1*Feducalter_10
wFeducalter_11 =~ 1*Feducalter_11
weu_7 =~ 1*eu_7
weu_8 =~ 1*eu_8
weu_9 =~ 1*eu_9
weu_10 =~ 1*eu_10
weu_11 =~ 1*eu_11
# Estimate the lagged effects (constrained)
weu_8 ~ a*weu_7 + b*wFeducalter_7
weu_9 ~ a*weu_8 + b*wFeducalter_8
weu_10 ~ a*weu_9 + b*wFeducalter_9
weu_11 ~ a*weu_10 + b*wFeducalter_10
wFeducalter_8 ~ c*weu_7 + d*wFeducalter_7
wFeducalter_9 ~ c*weu_8 + d*wFeducalter_8
wFeducalter_10 ~ c*weu_9 + d*wFeducalter_9
wFeducalter_11 ~ c*weu_10 + d*wFeducalter_10
# Estimate the covariance at the first wave.
weu_7 ~~ wFeducalter_7 # Covariance
# Estimate the covariances between the residuals
weu_8 ~~ wFeducalter_8
weu_9 ~~ wFeducalter_9
weu_10 ~~ wFeducalter_10
weu_11 ~~ wFeducalter_11
# Estimate the variance
weu_7 ~~ weu_7
wFeducalter_7 ~~ wFeducalter_7
# Estimate the residual variance
weu_8 ~~ weu_8
wFeducalter_8 ~~ wFeducalter_8
weu_9 ~~ weu_9
wFeducalter_9 ~~ wFeducalter_9
weu_10 ~~ weu_10
wFeducalter_10 ~~ wFeducalter_10
weu_11 ~~ weu_11
wFeducalter_11 ~~ wFeducalter_11
# Estimate the variance and covariance of the random intercepts.
RIx ~~ RIx
RIy ~~ RIy
RIx ~~ RIy
eu_7 ~ 1
eu_8 ~ 1
eu_9 ~ 1
eu_10 ~ 1
eu_11 ~ 1
##########################
# ADDITIONAL CONSTRAINTS #
##########################
# Set correlations between the between-factors (random intercepts) and within-
# factors at wave 1 at 0. I DONT UNDERSTAND WHY, OR BETTER WHY THIS IS NOT INCLUDED IN THE MODEL WITH ONLY ONE INDICATOR
RIx + RIy ~~ 0*wFeducalter_7 + 0*weu_7
'
fit <- lavaan(myModel, data = datalw, missing = 'ML', meanstructure = T, int.ov.free = T)
summary(fit, standardized = T)
#> lavaan 0.6-7 ended normally after 74 iterations
#>
#> Estimator ML
#> Optimization method NLMINB
#> Number of free parameters 93
#> Number of equality constraints 56
#>
#> Number of observations 2575
#> Number of missing patterns 1612
#>
#> Model Test User Model:
#>
#> Test statistic 3037.585
#> Degrees of freedom 458
#> P-value (Chi-square) 0.000
#>
#> Parameter Estimates:
#>
#> Standard errors Standard
#> Information Observed
#> Observed information based on Hessian
#>
#> Latent Variables:
#> Estimate Std.Err z-value P(>|z|) Std.lv Std.all
#> Feducalter_7 =~
#> educalter_7.1 1.000 1.604 0.573
#> educalter_7.2 1.000 1.604 0.573
#> educalter_7.3 1.000 1.604 0.573
#> educalter_7.4 1.000 1.604 0.573
#> educalter_7.5 1.000 1.604 0.573
#> Feducalter_8 =~
#> educalter_8.1 1.000 1.546 0.563
#> educalter_8.2 1.000 1.546 0.563
#> educalter_8.3 1.000 1.546 0.563
#> educalter_8.4 1.000 1.546 0.563
#> educalter_8.5 1.000 1.546 0.563
#> Feducalter_9 =~
#> educalter_9.1 1.000 1.539 0.569
#> educalter_9.2 1.000 1.539 0.569
#> educalter_9.3 1.000 1.539 0.569
#> educalter_9.4 1.000 1.539 0.569
#> educalter_9.5 1.000 1.539 0.569
#> Feducalter_10 =~
#> educalter_10.1 1.000 1.517 0.554
#> educalter_10.2 1.000 1.517 0.554
#> educalter_10.3 1.000 1.517 0.554
#> educalter_10.4 1.000 1.517 0.554
#> educalter_10.5 1.000 1.517 0.554
#> Feducalter_11 =~
#> educalter_11.1 1.000 1.553 0.566
#> educalter_11.2 1.000 1.553 0.566
#> educalter_11.3 1.000 1.553 0.566
#> educalter_11.4 1.000 1.553 0.566
#> educalter_11.5 1.000 1.553 0.566
#> RIx =~
#> Feducalter_7 1.000 1.048 1.048
#> Feducalter_8 1.000 1.088 1.088
#> Feducalter_9 1.000 1.092 1.092
#> Feducalter_10 1.000 1.108 1.108
#> Feducalter_11 1.000 1.083 1.083
#> RIy =~
#> eu_7 1.000 0.953 0.814
#> eu_8 1.000 0.953 0.808
#> eu_9 1.000 0.953 0.811
#> eu_10 1.000 0.953 0.805
#> eu_11 1.000 0.953 0.800
#> wFeducalter_7 =~
#> Feducalter_7 1.000 NA NA
#> wFeducalter_8 =~
#> Feducalter_8 1.000 NA NA
#> wFeducalter_9 =~
#> Feducalter_9 1.000 NA NA
#> wFeducalter_10 =~
#> Feducalter_10 1.000 NA NA
#> wFeducalter_11 =~
#> Feducalter_11 1.000 NA NA
#> weu_7 =~
#> eu_7 1.000 0.681 0.581
#> weu_8 =~
#> eu_8 1.000 0.695 0.589
#> weu_9 =~
#> eu_9 1.000 0.689 0.586
#> weu_10 =~
#> eu_10 1.000 0.704 0.594
#> weu_11 =~
#> eu_11 1.000 0.715 0.600
#>
#> Regressions:
#> Estimate Std.Err z-value P(>|z|) Std.lv Std.all
#> weu_8 ~
#> weu_7 (a) 0.137 0.015 8.896 0.000 0.134 0.134
#> wFedcltr_7 (b) -0.013 0.021 -0.642 0.521 NA NA
#> weu_9 ~
#> weu_8 (a) 0.137 0.015 8.896 0.000 0.138 0.138
#> wFedcltr_8 (b) -0.013 0.021 -0.642 0.521 NA NA
#> weu_10 ~
#> weu_9 (a) 0.137 0.015 8.896 0.000 0.134 0.134
#> wFedcltr_9 (b) -0.013 0.021 -0.642 0.521 NA NA
#> weu_11 ~
#> weu_10 (a) 0.137 0.015 8.896 0.000 0.134 0.134
#> wFdcltr_10 (b) -0.013 0.021 -0.642 0.521 NA NA
#> wFeducalter_8 ~
#> weu_7 (c) 0.033 0.021 1.544 0.123 NA NA
#> wFedcltr_7 (d) -0.170 0.029 -5.791 0.000 NA NA
#> wFeducalter_9 ~
#> weu_8 (c) 0.033 0.021 1.544 0.123 NA NA
#> wFedcltr_8 (d) -0.170 0.029 -5.791 0.000 NA NA
#> wFeducalter_10 ~
#> weu_9 (c) 0.033 0.021 1.544 0.123 NA NA
#> wFedcltr_9 (d) -0.170 0.029 -5.791 0.000 NA NA
#> wFeducalter_11 ~
#> weu_10 (c) 0.033 0.021 1.544 0.123 NA NA
#> wFdcltr_10 (d) -0.170 0.029 -5.791 0.000 NA NA
#>
#> Covariances:
#> Estimate Std.Err z-value P(>|z|) Std.lv Std.all
#> wFeducalter_7 ~~
#> weu_7 -0.008 0.021 -0.373 0.709 -0.022 -0.022
#> .wFeducalter_8 ~~
#> .weu_8 0.018 0.019 0.958 0.338 0.040 0.040
#> .wFeducalter_9 ~~
#> .weu_9 0.013 0.019 0.694 0.488 0.028 0.028
#> .wFeducalter_10 ~~
#> .weu_10 0.014 0.018 0.745 0.456 0.027 0.027
#> .wFeducalter_11 ~~
#> .weu_11 0.008 0.021 0.403 0.687 0.019 0.019
#> RIx ~~
#> RIy 0.556 0.038 14.482 0.000 0.347 0.347
#> wFeducalter_7 0.000 0.000 0.000
#> weu_7 0.000 0.000 0.000
#> RIy ~~
#> wFeducalter_7 0.000 0.000 0.000
#> weu_7 0.000 0.000 0.000
#>
#> Intercepts:
#> Estimate Std.Err z-value P(>|z|) Std.lv Std.all
#> .edcltr_7.1 (j) 12.077 0.042 284.997 0.000 12.077 4.311
#> .edcltr_7.2 (j) 12.077 0.042 284.997 0.000 12.077 4.311
#> .edcltr_7.3 (j) 12.077 0.042 284.997 0.000 12.077 4.311
#> .edcltr_7.4 (j) 12.077 0.042 284.997 0.000 12.077 4.311
#> .edcltr_7.5 (j) 12.077 0.042 284.997 0.000 12.077 4.311
#> .edcltr_8.1 (j) 12.077 0.042 284.997 0.000 12.077 4.401
#> .edcltr_8.2 (j) 12.077 0.042 284.997 0.000 12.077 4.401
#> .edcltr_8.3 (j) 12.077 0.042 284.997 0.000 12.077 4.401
#> .edcltr_8.4 (j) 12.077 0.042 284.997 0.000 12.077 4.401
#> .edcltr_8.5 (j) 12.077 0.042 284.997 0.000 12.077 4.401
#> .edcltr_9.1 (j) 12.077 0.042 284.997 0.000 12.077 4.464
#> .edcltr_9.2 (j) 12.077 0.042 284.997 0.000 12.077 4.464
#> .edcltr_9.3 (j) 12.077 0.042 284.997 0.000 12.077 4.464
#> .edcltr_9.4 (j) 12.077 0.042 284.997 0.000 12.077 4.464
#> .edcltr_9.5 (j) 12.077 0.042 284.997 0.000 12.077 4.464
#> .edclt_10.1 (j) 12.077 0.042 284.997 0.000 12.077 4.415
#> .edclt_10.2 (j) 12.077 0.042 284.997 0.000 12.077 4.415
#> .edclt_10.3 (j) 12.077 0.042 284.997 0.000 12.077 4.415
#> .edclt_10.4 (j) 12.077 0.042 284.997 0.000 12.077 4.415
#> .edclt_10.5 (j) 12.077 0.042 284.997 0.000 12.077 4.415
#> .edclt_11.1 (j) 12.077 0.042 284.997 0.000 12.077 4.403
#> .edclt_11.2 (j) 12.077 0.042 284.997 0.000 12.077 4.403
#> .edclt_11.3 (j) 12.077 0.042 284.997 0.000 12.077 4.403
#> .edclt_11.4 (j) 12.077 0.042 284.997 0.000 12.077 4.403
#> .edclt_11.5 (j) 12.077 0.042 284.997 0.000 12.077 4.403
#> .Feducltr_8 0.093 0.033 2.789 0.005 0.060 0.060
#> .Feducltr_9 0.133 0.033 4.011 0.000 0.087 0.087
#> .Fedcltr_10 0.223 0.033 6.725 0.000 0.147 0.147
#> .Fedcltr_11 0.224 0.035 6.451 0.000 0.144 0.144
#> .eu_7 1.263 0.023 54.705 0.000 1.263 1.078
#> .eu_8 1.325 0.023 56.999 0.000 1.325 1.123
#> .eu_9 1.272 0.023 54.873 0.000 1.272 1.081
#> .eu_10 1.419 0.023 60.778 0.000 1.419 1.198
#> .eu_11 1.512 0.023 64.390 0.000 1.512 1.269
#> .Feducltr_7 0.000 0.000 0.000
#> RIx 0.000 0.000 0.000
#> RIy 0.000 0.000 0.000
#> wFedcltr_7 0.000 NA NA
#> .wFedcltr_8 0.000 NA NA
#> .wFedcltr_9 0.000 NA NA
#> .wFdcltr_10 0.000 NA NA
#> .wFdcltr_11 0.000 NA NA
#> weu_7 0.000 0.000 0.000
#> .weu_8 0.000 0.000 0.000
#> .weu_9 0.000 0.000 0.000
#> .weu_10 0.000 0.000 0.000
#> .weu_11 0.000 0.000 0.000
#>
#> Variances:
#> Estimate Std.Err z-value P(>|z|) Std.lv Std.all
#> .edcltr_7.1 (e) 5.274 0.101 52.432 0.000 5.274 0.672
#> .edcltr_7.2 (e) 5.274 0.101 52.432 0.000 5.274 0.672
#> .edcltr_7.3 (e) 5.274 0.101 52.432 0.000 5.274 0.672
#> .edcltr_7.4 (e) 5.274 0.101 52.432 0.000 5.274 0.672
#> .edcltr_7.5 (e) 5.274 0.101 52.432 0.000 5.274 0.672
#> .edcltr_8.1 (f) 5.142 0.100 51.327 0.000 5.142 0.683
#> .edcltr_8.2 (f) 5.142 0.100 51.327 0.000 5.142 0.683
#> .edcltr_8.3 (f) 5.142 0.100 51.327 0.000 5.142 0.683
#> .edcltr_8.4 (f) 5.142 0.100 51.327 0.000 5.142 0.683
#> .edcltr_8.5 (f) 5.142 0.100 51.327 0.000 5.142 0.683
#> .edcltr_9.1 (g) 4.951 0.095 52.277 0.000 4.951 0.676
#> .edcltr_9.2 (g) 4.951 0.095 52.277 0.000 4.951 0.676
#> .edcltr_9.3 (g) 4.951 0.095 52.277 0.000 4.951 0.676
#> .edcltr_9.4 (g) 4.951 0.095 52.277 0.000 4.951 0.676
#> .edcltr_9.5 (g) 4.951 0.095 52.277 0.000 4.951 0.676
#> .edclt_10.1 (h) 5.182 0.102 51.011 0.000 5.182 0.693
#> .edclt_10.2 (h) 5.182 0.102 51.011 0.000 5.182 0.693
#> .edclt_10.3 (h) 5.182 0.102 51.011 0.000 5.182 0.693
#> .edclt_10.4 (h) 5.182 0.102 51.011 0.000 5.182 0.693
#> .edclt_10.5 (h) 5.182 0.102 51.011 0.000 5.182 0.693
#> .edclt_11.1 (i) 5.112 0.104 49.156 0.000 5.112 0.679
#> .edclt_11.2 (i) 5.112 0.104 49.156 0.000 5.112 0.679
#> .edclt_11.3 (i) 5.112 0.104 49.156 0.000 5.112 0.679
#> .edclt_11.4 (i) 5.112 0.104 49.156 0.000 5.112 0.679
#> .edclt_11.5 (i) 5.112 0.104 49.156 0.000 5.112 0.679
#> weu_7 0.464 0.017 27.587 0.000 1.000 1.000
#> wFedcltr_7 -0.255 0.045 -5.705 0.000 NA NA
#> .weu_8 0.474 0.017 28.261 0.000 0.982 0.982
#> .wFedcltr_8 -0.431 0.039 -11.072 0.000 NA NA
#> .weu_9 0.466 0.016 28.645 0.000 0.981 0.981
#> .wFedcltr_9 -0.446 0.039 -11.482 0.000 NA NA
#> .weu_10 0.486 0.017 28.680 0.000 0.982 0.982
#> .wFdcltr_10 -0.513 0.037 -13.799 0.000 NA NA
#> .weu_11 0.502 0.017 30.160 0.000 0.982 0.982
#> .wFdcltr_11 -0.400 0.044 -9.048 0.000 NA NA
#> RIx 2.827 0.092 30.645 0.000 1.000 1.000
#> RIy 0.909 0.029 31.329 0.000 1.000 1.000
#> .eu_7 0.000 0.000 0.000
#> .eu_8 0.000 0.000 0.000
#> .eu_9 0.000 0.000 0.000
#> .eu_10 0.000 0.000 0.000
#> .eu_11 0.000 0.000 0.000
#> .Feducltr_7 0.000 0.000 0.000
#> .Feducltr_8 0.000 0.000 0.000
#> .Feducltr_9 0.000 0.000 0.000
#> .Fedcltr_10 0.000 0.000 0.000
#> .Fedcltr_11 0.000 0.000 0.000
myModel <- '
################
# BETWEEN PART #
###############
# Create between components (random intercepts)
RIx =~ 1*Feducalter_7 + 1*Feducalter_8 + 1*Feducalter_9 + 1*Feducalter_10 + 1*Feducalter_11
RIy =~ 1*eu_7 + 1*eu_8 + 1*eu_9 + 1*eu_10 + 1*eu_11
# Estimate the variance and covariance of the random intercepts.
RIx ~~ RIx
RIy ~~ RIy
RIx ~~ RIy
# Set the residual variances of all FX variables to 0. I DONT UNDERSTAND THIS! no measurement error??
Feducalter_7 ~~ 0*Feducalter_7
Feducalter_8 ~~ 0*Feducalter_8
Feducalter_9 ~~ 0*Feducalter_9
Feducalter_10 ~~ 0*Feducalter_10
Feducalter_11 ~~ 0*Feducalter_11
###############
# WITHIN PART #
###############
# Create within-person centered variables.
wFeducalter_7 =~ 1*Feducalter_7
wFeducalter_8 =~ 1*Feducalter_8
wFeducalter_9 =~ 1*Feducalter_9
wFeducalter_10 =~ 1*Feducalter_10
wFeducalter_11 =~ 1*Feducalter_11
weu_7 =~ 1*eu_7
weu_8 =~ 1*eu_8
weu_9 =~ 1*eu_9
weu_10 =~ 1*eu_10
weu_11 =~ 1*eu_11
# Estimate the lagged effects (constrained)
weu_8 ~ a*weu_7 + b*wFeducalter_7
weu_9 ~ a*weu_8 + b*wFeducalter_8
weu_10 ~ a*weu_9 + b*wFeducalter_9
weu_11 ~ a*weu_10 + b*wFeducalter_10
wFeducalter_8 ~ c*weu_7 + d*wFeducalter_7
wFeducalter_9 ~ c*weu_8 + d*wFeducalter_8
wFeducalter_10 ~ c*weu_9 + d*wFeducalter_9
wFeducalter_11 ~ c*weu_10 + d*wFeducalter_10
# Estimate the covariance at the first wave.
weu_7 ~~ wFeducalter_7 # Covariance
# Estimate the covariances between the residuals
weu_8 ~~ wFeducalter_8
weu_9 ~~ wFeducalter_9
weu_10 ~~ wFeducalter_10
weu_11 ~~ wFeducalter_11
# Estimate the variance
weu_7 ~~ weu_7
wFeducalter_7 ~~ wFeducalter_7
# Estimate the residual variance
weu_8 ~~ weu_8
wFeducalter_8 ~~ wFeducalter_8
weu_9 ~~ weu_9
wFeducalter_9 ~~ wFeducalter_9
weu_10 ~~ weu_10
wFeducalter_10 ~~ wFeducalter_10
weu_11 ~~ weu_11
wFeducalter_11 ~~ wFeducalter_11
#intercepts
Feducalter_7 ~ 1
Feducalter_8 ~ 1
Feducalter_9 ~ 1
Feducalter_10 ~ 1
Feducalter_11 ~ 1
eu_7 ~ 1
eu_8 ~ 1
eu_9 ~ 1
eu_10 ~ 1
eu_11 ~ 1
##########################
# ADDITIONAL CONSTRAINTS #
##########################
# Set correlations between the between-factors (random intercepts) and within-
# factors at wave 1 at 0.
RIx + RIy ~~ 0*wFeducalter_7 + 0*weu_7
'
fit <- lavaan(myModel, data = datalwb, missing = 'ML', meanstructure = T, int.ov.free = T)
summary(fit, standardized = T)
#> lavaan 0.6-7 ended normally after 34 iterations
#>
#> Estimator ML
#> Optimization method NLMINB
#> Number of free parameters 44
#> Number of equality constraints 12
#>
#> Number of observations 2575
#> Number of missing patterns 2
#>
#> Model Test User Model:
#>
#> Test statistic 91.502
#> Degrees of freedom 33
#> P-value (Chi-square) 0.000
#>
#> Parameter Estimates:
#>
#> Standard errors Standard
#> Information Observed
#> Observed information based on Hessian
#>
#> Latent Variables:
#> Estimate Std.Err z-value P(>|z|) Std.lv Std.all
#> RIx =~
#> Feducalter_7 1.000 0.783 0.758
#> Feducalter_8 1.000 0.783 0.799
#> Feducalter_9 1.000 0.783 0.805
#> Feducalter_10 1.000 0.783 0.804
#> Feducalter_11 1.000 0.783 0.806
#> RIy =~
#> eu_7 1.000 0.954 0.814
#> eu_8 1.000 0.954 0.808
#> eu_9 1.000 0.954 0.811
#> eu_10 1.000 0.954 0.805
#> eu_11 1.000 0.954 0.800
#> wFeducalter_7 =~
#> Feducalter_7 1.000 0.672 0.652
#> wFeducalter_8 =~
#> Feducalter_8 1.000 0.590 0.602
#> wFeducalter_9 =~
#> Feducalter_9 1.000 0.577 0.594
#> wFeducalter_10 =~
#> Feducalter_10 1.000 0.578 0.594
#> wFeducalter_11 =~
#> Feducalter_11 1.000 0.575 0.592
#> weu_7 =~
#> eu_7 1.000 0.681 0.581
#> weu_8 =~
#> eu_8 1.000 0.695 0.589
#> weu_9 =~
#> eu_9 1.000 0.688 0.585
#> weu_10 =~
#> eu_10 1.000 0.703 0.594
#> weu_11 =~
#> eu_11 1.000 0.716 0.600
#>
#> Regressions:
#> Estimate Std.Err z-value P(>|z|) Std.lv Std.all
#> weu_8 ~
#> weu_7 (a) 0.135 0.015 8.835 0.000 0.133 0.133
#> wFedcltr_7 (b) 0.024 0.015 1.590 0.112 0.023 0.023
#> weu_9 ~
#> weu_8 (a) 0.135 0.015 8.835 0.000 0.137 0.137
#> wFedcltr_8 (b) 0.024 0.015 1.590 0.112 0.020 0.020
#> weu_10 ~
#> weu_9 (a) 0.135 0.015 8.835 0.000 0.132 0.132
#> wFedcltr_9 (b) 0.024 0.015 1.590 0.112 0.019 0.019
#> weu_11 ~
#> weu_10 (a) 0.135 0.015 8.835 0.000 0.133 0.133
#> wFdcltr_10 (b) 0.024 0.015 1.590 0.112 0.019 0.019
#> wFeducalter_8 ~
#> weu_7 (c) 0.023 0.011 2.082 0.037 0.027 0.027
#> wFedcltr_7 (d) 0.073 0.014 5.132 0.000 0.083 0.083
#> wFeducalter_9 ~
#> weu_8 (c) 0.023 0.011 2.082 0.037 0.028 0.028
#> wFedcltr_8 (d) 0.073 0.014 5.132 0.000 0.075 0.075
#> wFeducalter_10 ~
#> weu_9 (c) 0.023 0.011 2.082 0.037 0.027 0.027
#> wFedcltr_9 (d) 0.073 0.014 5.132 0.000 0.073 0.073
#> wFeducalter_11 ~
#> weu_10 (c) 0.023 0.011 2.082 0.037 0.028 0.028
#> wFdcltr_10 (d) 0.073 0.014 5.132 0.000 0.073 0.073
#>
#> Covariances:
#> Estimate Std.Err z-value P(>|z|) Std.lv Std.all
#> RIx ~~
#> RIy 0.244 0.018 13.736 0.000 0.327 0.327
#> wFeducalter_7 ~~
#> weu_7 0.012 0.011 1.074 0.283 0.027 0.027
#> .wFeducalter_8 ~~
#> .weu_8 0.002 0.010 0.174 0.862 0.004 0.004
#> .wFeducalter_9 ~~
#> .weu_9 -0.000 0.010 -0.035 0.972 -0.001 -0.001
#> .wFeducalter_10 ~~
#> .weu_10 0.009 0.010 0.895 0.371 0.023 0.023
#> .wFeducalter_11 ~~
#> .weu_11 0.012 0.010 1.174 0.240 0.028 0.028
#> RIx ~~
#> wFeducalter_7 0.000 0.000 0.000
#> weu_7 0.000 0.000 0.000
#> RIy ~~
#> wFeducalter_7 0.000 0.000 0.000
#> weu_7 0.000 0.000 0.000
#>
#> Intercepts:
#> Estimate Std.Err z-value P(>|z|) Std.lv Std.all
#> .Feducalter_7 -0.003 0.021 -0.127 0.899 -0.003 -0.003
#> .Feducalter_8 0.100 0.020 5.109 0.000 0.100 0.102
#> .Feducalter_9 0.165 0.019 8.499 0.000 0.165 0.170
#> .Feducalter_10 0.260 0.019 13.380 0.000 0.260 0.268
#> .Feducalter_11 0.214 0.019 11.002 0.000 0.214 0.220
#> .eu_7 1.263 0.023 54.683 0.000 1.263 1.078
#> .eu_8 1.325 0.023 56.992 0.000 1.325 1.123
#> .eu_9 1.272 0.023 54.884 0.000 1.272 1.082
#> .eu_10 1.419 0.023 60.774 0.000 1.419 1.198
#> .eu_11 1.512 0.023 64.362 0.000 1.512 1.268
#> RIx 0.000 0.000 0.000
#> RIy 0.000 0.000 0.000
#> wFeducalter_7 0.000 0.000 0.000
#> .wFeducalter_8 0.000 0.000 0.000
#> .wFeducalter_9 0.000 0.000 0.000
#> .wFeducalter_10 0.000 0.000 0.000
#> .wFeducalter_11 0.000 0.000 0.000
#> weu_7 0.000 0.000 0.000
#> .weu_8 0.000 0.000 0.000
#> .weu_9 0.000 0.000 0.000
#> .weu_10 0.000 0.000 0.000
#> .weu_11 0.000 0.000 0.000
#>
#> Variances:
#> Estimate Std.Err z-value P(>|z|) Std.lv Std.all
#> RIx 0.612 0.020 30.827 0.000 1.000 1.000
#> RIy 0.909 0.029 31.333 0.000 1.000 1.000
#> .Feducalter_7 0.000 0.000 0.000
#> .Feducalter_8 0.000 0.000 0.000
#> .Feducalter_9 0.000 0.000 0.000
#> .Feducalter_10 0.000 0.000 0.000
#> .Feducalter_11 0.000 0.000 0.000
#> weu_7 0.464 0.017 27.564 0.000 1.000 1.000
#> wFeducalter_7 0.452 0.015 29.552 0.000 1.000 1.000
#> .weu_8 0.474 0.017 28.238 0.000 0.982 0.982
#> .wFeducalter_8 0.345 0.012 27.662 0.000 0.992 0.992
#> .weu_9 0.464 0.016 28.618 0.000 0.981 0.981
#> .wFeducalter_9 0.331 0.012 27.724 0.000 0.994 0.994
#> .weu_10 0.486 0.017 28.672 0.000 0.982 0.982
#> .wFeducalter_10 0.332 0.012 27.593 0.000 0.994 0.994
#> .weu_11 0.503 0.017 30.154 0.000 0.982 0.982
#> .wFeducalter_11 0.328 0.011 28.650 0.000 0.994 0.994
#> .eu_7 0.000 0.000 0.000
#> .eu_8 0.000 0.000 0.000
#> .eu_9 0.000 0.000 0.000
#> .eu_10 0.000 0.000 0.000
#> .eu_11 0.000 0.000 0.000
I do not really understand why the cross-lagged effects become smaller after introduction of educego.
myModel <- '
# Create between components (random intercepts)
RIx =~ 1*Feducalter_7 + 1*Feducalter_8 + 1*Feducalter_9 + 1*Feducalter_10 + 1*Feducalter_11
RIy =~ 1*eu_7 + 1*eu_8 + 1*eu_9 + 1*eu_10 + 1*eu_11
# Create within-person centered variables.
wFeducalter_7 =~ 1*Feducalter_7
wFeducalter_8 =~ 1*Feducalter_8
wFeducalter_9 =~ 1*Feducalter_9
wFeducalter_10 =~ 1*Feducalter_10
wFeducalter_11 =~ 1*Feducalter_11
weu_7 =~ 1*eu_7
weu_8 =~ 1*eu_8
weu_9 =~ 1*eu_9
weu_10 =~ 1*eu_10
weu_11 =~ 1*eu_11
# Estimate the lagged effects (constrained)
weu_8 ~ a*weu_7 + b*wFeducalter_7
weu_9 ~ a*weu_8 + b*wFeducalter_8
weu_10 ~ a*weu_9 + b*wFeducalter_9
weu_11 ~ a*weu_10 + b*wFeducalter_10
wFeducalter_8 ~ c*weu_7 + d*wFeducalter_7
wFeducalter_9 ~ c*weu_8 + d*wFeducalter_8
wFeducalter_10 ~ c*weu_9 + d*wFeducalter_9
wFeducalter_11 ~ c*weu_10 + d*wFeducalter_10
# Estimate the covariance at the first wave.
weu_7 ~~ wFeducalter_7 # Covariance
# Estimate the covariances between the residuals
weu_8 ~~ wFeducalter_8
weu_9 ~~ wFeducalter_9
weu_10 ~~ wFeducalter_10
weu_11 ~~ wFeducalter_11
# Estimate the variance
weu_7 ~~ weu_7
wFeducalter_7 ~~ wFeducalter_7
# Estimate the residual variance
weu_8 ~~ weu_8
wFeducalter_8 ~~ wFeducalter_8
weu_9 ~~ weu_9
wFeducalter_9 ~~ wFeducalter_9
weu_10 ~~ weu_10
wFeducalter_10 ~~ wFeducalter_10
weu_11 ~~ weu_11
wFeducalter_11 ~~ wFeducalter_11
# Estimate the variance and covariance of the random intercepts.
RIx ~~ RIx
RIy ~~ RIy
RIx ~~ RIy
#intercepts
Feducalter_7 ~ 1
Feducalter_8 ~ 1
Feducalter_9 ~ 1
Feducalter_10 ~ 1
Feducalter_11 ~ 1
eu_7 ~ 1
eu_8 ~ 1
eu_9 ~ 1
eu_10 ~ 1
eu_11 ~ 1
'
fit <- lavaan(myModel, data = datalwb, missing = 'ML', meanstructure = T, int.ov.free = T)
summary(fit, standardized = T)
#> lavaan 0.6-7 ended normally after 34 iterations
#>
#> Estimator ML
#> Optimization method NLMINB
#> Number of free parameters 44
#> Number of equality constraints 12
#>
#> Number of observations 2575
#> Number of missing patterns 2
#>
#> Model Test User Model:
#>
#> Test statistic 91.502
#> Degrees of freedom 33
#> P-value (Chi-square) 0.000
#>
#> Parameter Estimates:
#>
#> Standard errors Standard
#> Information Observed
#> Observed information based on Hessian
#>
#> Latent Variables:
#> Estimate Std.Err z-value P(>|z|) Std.lv Std.all
#> RIx =~
#> Feducalter_7 1.000 0.783 0.758
#> Feducalter_8 1.000 0.783 0.799
#> Feducalter_9 1.000 0.783 0.805
#> Feducalter_10 1.000 0.783 0.804
#> Feducalter_11 1.000 0.783 0.806
#> RIy =~
#> eu_7 1.000 0.954 0.814
#> eu_8 1.000 0.954 0.808
#> eu_9 1.000 0.954 0.811
#> eu_10 1.000 0.954 0.805
#> eu_11 1.000 0.954 0.800
#> wFeducalter_7 =~
#> Feducalter_7 1.000 0.672 0.652
#> wFeducalter_8 =~
#> Feducalter_8 1.000 0.590 0.602
#> wFeducalter_9 =~
#> Feducalter_9 1.000 0.577 0.594
#> wFeducalter_10 =~
#> Feducalter_10 1.000 0.578 0.594
#> wFeducalter_11 =~
#> Feducalter_11 1.000 0.575 0.592
#> weu_7 =~
#> eu_7 1.000 0.681 0.581
#> weu_8 =~
#> eu_8 1.000 0.695 0.589
#> weu_9 =~
#> eu_9 1.000 0.688 0.585
#> weu_10 =~
#> eu_10 1.000 0.703 0.594
#> weu_11 =~
#> eu_11 1.000 0.716 0.600
#>
#> Regressions:
#> Estimate Std.Err z-value P(>|z|) Std.lv Std.all
#> weu_8 ~
#> weu_7 (a) 0.135 0.015 8.835 0.000 0.133 0.133
#> wFedcltr_7 (b) 0.024 0.015 1.590 0.112 0.023 0.023
#> weu_9 ~
#> weu_8 (a) 0.135 0.015 8.835 0.000 0.137 0.137
#> wFedcltr_8 (b) 0.024 0.015 1.590 0.112 0.020 0.020
#> weu_10 ~
#> weu_9 (a) 0.135 0.015 8.835 0.000 0.132 0.132
#> wFedcltr_9 (b) 0.024 0.015 1.590 0.112 0.019 0.019
#> weu_11 ~
#> weu_10 (a) 0.135 0.015 8.835 0.000 0.133 0.133
#> wFdcltr_10 (b) 0.024 0.015 1.590 0.112 0.019 0.019
#> wFeducalter_8 ~
#> weu_7 (c) 0.023 0.011 2.082 0.037 0.027 0.027
#> wFedcltr_7 (d) 0.073 0.014 5.132 0.000 0.083 0.083
#> wFeducalter_9 ~
#> weu_8 (c) 0.023 0.011 2.082 0.037 0.028 0.028
#> wFedcltr_8 (d) 0.073 0.014 5.132 0.000 0.075 0.075
#> wFeducalter_10 ~
#> weu_9 (c) 0.023 0.011 2.082 0.037 0.027 0.027
#> wFedcltr_9 (d) 0.073 0.014 5.132 0.000 0.073 0.073
#> wFeducalter_11 ~
#> weu_10 (c) 0.023 0.011 2.082 0.037 0.028 0.028
#> wFdcltr_10 (d) 0.073 0.014 5.132 0.000 0.073 0.073
#>
#> Covariances:
#> Estimate Std.Err z-value P(>|z|) Std.lv Std.all
#> wFeducalter_7 ~~
#> weu_7 0.012 0.011 1.074 0.283 0.027 0.027
#> .wFeducalter_8 ~~
#> .weu_8 0.002 0.010 0.174 0.862 0.004 0.004
#> .wFeducalter_9 ~~
#> .weu_9 -0.000 0.010 -0.035 0.972 -0.001 -0.001
#> .wFeducalter_10 ~~
#> .weu_10 0.009 0.010 0.895 0.371 0.023 0.023
#> .wFeducalter_11 ~~
#> .weu_11 0.012 0.010 1.174 0.240 0.028 0.028
#> RIx ~~
#> RIy 0.244 0.018 13.736 0.000 0.327 0.327
#>
#> Intercepts:
#> Estimate Std.Err z-value P(>|z|) Std.lv Std.all
#> .Feducalter_7 -0.003 0.021 -0.127 0.899 -0.003 -0.003
#> .Feducalter_8 0.100 0.020 5.109 0.000 0.100 0.102
#> .Feducalter_9 0.165 0.019 8.499 0.000 0.165 0.170
#> .Feducalter_10 0.260 0.019 13.380 0.000 0.260 0.268
#> .Feducalter_11 0.214 0.019 11.002 0.000 0.214 0.220
#> .eu_7 1.263 0.023 54.683 0.000 1.263 1.078
#> .eu_8 1.325 0.023 56.992 0.000 1.325 1.123
#> .eu_9 1.272 0.023 54.884 0.000 1.272 1.082
#> .eu_10 1.419 0.023 60.774 0.000 1.419 1.198
#> .eu_11 1.512 0.023 64.362 0.000 1.512 1.268
#> RIx 0.000 0.000 0.000
#> RIy 0.000 0.000 0.000
#> wFeducalter_7 0.000 0.000 0.000
#> .wFeducalter_8 0.000 0.000 0.000
#> .wFeducalter_9 0.000 0.000 0.000
#> .wFeducalter_10 0.000 0.000 0.000
#> .wFeducalter_11 0.000 0.000 0.000
#> weu_7 0.000 0.000 0.000
#> .weu_8 0.000 0.000 0.000
#> .weu_9 0.000 0.000 0.000
#> .weu_10 0.000 0.000 0.000
#> .weu_11 0.000 0.000 0.000
#>
#> Variances:
#> Estimate Std.Err z-value P(>|z|) Std.lv Std.all
#> weu_7 0.464 0.017 27.564 0.000 1.000 1.000
#> wFeducalter_7 0.452 0.015 29.552 0.000 1.000 1.000
#> .weu_8 0.474 0.017 28.238 0.000 0.982 0.982
#> .wFeducalter_8 0.345 0.012 27.662 0.000 0.992 0.992
#> .weu_9 0.464 0.016 28.618 0.000 0.981 0.981
#> .wFeducalter_9 0.331 0.012 27.724 0.000 0.994 0.994
#> .weu_10 0.486 0.017 28.672 0.000 0.982 0.982
#> .wFeducalter_10 0.332 0.012 27.593 0.000 0.994 0.994
#> .weu_11 0.503 0.017 30.154 0.000 0.982 0.982
#> .wFeducalter_11 0.328 0.011 28.650 0.000 0.994 0.994
#> RIx 0.612 0.020 30.827 0.000 1.000 1.000
#> RIy 0.909 0.029 31.333 0.000 1.000 1.000
#> .Feducalter_7 0.000 0.000 0.000
#> .Feducalter_8 0.000 0.000 0.000
#> .Feducalter_9 0.000 0.000 0.000
#> .Feducalter_10 0.000 0.000 0.000
#> .Feducalter_11 0.000 0.000 0.000
#> .eu_7 0.000 0.000 0.000
#> .eu_8 0.000 0.000 0.000
#> .eu_9 0.000 0.000 0.000
#> .eu_10 0.000 0.000 0.000
#> .eu_11 0.000 0.000 0.000
myModel <- '
# Create between components (random intercepts)
RIx =~ 1*Feducalter_7 + 1*Feducalter_8 + 1*Feducalter_9 + 1*Feducalter_10 + 1*Feducalter_11
RIy =~ 1*eu_7 + 1*eu_8 + 1*eu_9 + 1*eu_10 + 1*eu_11
# Regression of random intercepts on z1.
RIx + RIy ~ educego_7
# Create within-person centered variables.
wFeducalter_7 =~ 1*Feducalter_7
wFeducalter_8 =~ 1*Feducalter_8
wFeducalter_9 =~ 1*Feducalter_9
wFeducalter_10 =~ 1*Feducalter_10
wFeducalter_11 =~ 1*Feducalter_11
weu_7 =~ 1*eu_7
weu_8 =~ 1*eu_8
weu_9 =~ 1*eu_9
weu_10 =~ 1*eu_10
weu_11 =~ 1*eu_11
# Estimate the lagged effects (constrained)
weu_8 ~ a*weu_7 + b*wFeducalter_7
weu_9 ~ a*weu_8 + b*wFeducalter_8
weu_10 ~ a*weu_9 + b*wFeducalter_9
weu_11 ~ a*weu_10 + b*wFeducalter_10
wFeducalter_8 ~ c*weu_7 + d*wFeducalter_7
wFeducalter_9 ~ c*weu_8 + d*wFeducalter_8
wFeducalter_10 ~ c*weu_9 + d*wFeducalter_9
wFeducalter_11 ~ c*weu_10 + d*wFeducalter_10
# Estimate the covariance at the first wave.
weu_7 ~~ wFeducalter_7 # Covariance
# Estimate the covariances between the residuals
weu_8 ~~ wFeducalter_8
weu_9 ~~ wFeducalter_9
weu_10 ~~ wFeducalter_10
weu_11 ~~ wFeducalter_11
# Estimate the variance
weu_7 ~~ weu_7
wFeducalter_7 ~~ wFeducalter_7
# Estimate the residual variance
weu_8 ~~ weu_8
wFeducalter_8 ~~ wFeducalter_8
weu_9 ~~ weu_9
wFeducalter_9 ~~ wFeducalter_9
weu_10 ~~ weu_10
wFeducalter_10 ~~ wFeducalter_10
weu_11 ~~ weu_11
wFeducalter_11 ~~ wFeducalter_11
# Estimate the variance and covariance of the random intercepts.
RIx ~~ RIx
RIy ~~ RIy
RIx ~~ RIy
#intercepts
Feducalter_7 ~ 1
Feducalter_8 ~ 1
Feducalter_9 ~ 1
Feducalter_10 ~ 1
Feducalter_11 ~ 1
eu_7 ~ 1
eu_8 ~ 1
eu_9 ~ 1
eu_10 ~ 1
eu_11 ~ 1
'
fit <- lavaan(myModel, data = datalwb, missing = 'ML', meanstructure = T, int.ov.free = T)
summary(fit, standardized = T)
#> lavaan 0.6-7 ended normally after 44 iterations
#>
#> Estimator ML
#> Optimization method NLMINB
#> Number of free parameters 46
#> Number of equality constraints 12
#>
#> Number of observations 2575
#> Number of missing patterns 2
#>
#> Model Test User Model:
#>
#> Test statistic 121.628
#> Degrees of freedom 41
#> P-value (Chi-square) 0.000
#>
#> Parameter Estimates:
#>
#> Standard errors Standard
#> Information Observed
#> Observed information based on Hessian
#>
#> Latent Variables:
#> Estimate Std.Err z-value P(>|z|) Std.lv Std.all
#> RIx =~
#> Feducalter_7 1.000 0.783 0.761
#> Feducalter_8 1.000 0.783 0.799
#> Feducalter_9 1.000 0.783 0.805
#> Feducalter_10 1.000 0.783 0.804
#> Feducalter_11 1.000 0.783 0.804
#> RIy =~
#> eu_7 1.000 0.953 0.814
#> eu_8 1.000 0.953 0.808
#> eu_9 1.000 0.953 0.810
#> eu_10 1.000 0.953 0.804
#> eu_11 1.000 0.953 0.800
#> wFeducalter_7 =~
#> Feducalter_7 1.000 0.668 0.649
#> wFeducalter_8 =~
#> Feducalter_8 1.000 0.589 0.601
#> wFeducalter_9 =~
#> Feducalter_9 1.000 0.577 0.594
#> wFeducalter_10 =~
#> Feducalter_10 1.000 0.580 0.595
#> wFeducalter_11 =~
#> Feducalter_11 1.000 0.578 0.594
#> weu_7 =~
#> eu_7 1.000 0.681 0.581
#> weu_8 =~
#> eu_8 1.000 0.695 0.589
#> weu_9 =~
#> eu_9 1.000 0.689 0.586
#> weu_10 =~
#> eu_10 1.000 0.704 0.594
#> weu_11 =~
#> eu_11 1.000 0.715 0.600
#>
#> Regressions:
#> Estimate Std.Err z-value P(>|z|) Std.lv Std.all
#> RIx ~
#> educego_7 0.217 0.010 21.488 0.000 0.277 0.421
#> RIy ~
#> educego_7 0.171 0.013 13.389 0.000 0.179 0.272
#> weu_8 ~
#> weu_7 (a) 0.137 0.015 8.894 0.000 0.134 0.134
#> wFedcltr_7 (b) 0.025 0.015 1.661 0.097 0.024 0.024
#> weu_9 ~
#> weu_8 (a) 0.137 0.015 8.894 0.000 0.138 0.138
#> wFedcltr_8 (b) 0.025 0.015 1.661 0.097 0.021 0.021
#> weu_10 ~
#> weu_9 (a) 0.137 0.015 8.894 0.000 0.134 0.134
#> wFedcltr_9 (b) 0.025 0.015 1.661 0.097 0.020 0.020
#> weu_11 ~
#> weu_10 (a) 0.137 0.015 8.894 0.000 0.134 0.134
#> wFdcltr_10 (b) 0.025 0.015 1.661 0.097 0.020 0.020
#> wFeducalter_8 ~
#> weu_7 (c) 0.025 0.011 2.264 0.024 0.029 0.029
#> wFedcltr_7 (d) 0.073 0.014 5.110 0.000 0.083 0.083
#> wFeducalter_9 ~
#> weu_8 (c) 0.025 0.011 2.264 0.024 0.030 0.030
#> wFedcltr_8 (d) 0.073 0.014 5.110 0.000 0.075 0.075
#> wFeducalter_10 ~
#> weu_9 (c) 0.025 0.011 2.264 0.024 0.030 0.030
#> wFedcltr_9 (d) 0.073 0.014 5.110 0.000 0.073 0.073
#> wFeducalter_11 ~
#> weu_10 (c) 0.025 0.011 2.264 0.024 0.031 0.031
#> wFdcltr_10 (d) 0.073 0.014 5.110 0.000 0.073 0.073
#>
#> Covariances:
#> Estimate Std.Err z-value P(>|z|) Std.lv Std.all
#> wFeducalter_7 ~~
#> weu_7 0.009 0.011 0.811 0.417 0.020 0.020
#> .wFeducalter_8 ~~
#> .weu_8 0.003 0.010 0.254 0.800 0.006 0.006
#> .wFeducalter_9 ~~
#> .weu_9 0.001 0.010 0.077 0.939 0.002 0.002
#> .wFeducalter_10 ~~
#> .weu_10 0.011 0.010 1.089 0.276 0.028 0.028
#> .wFeducalter_11 ~~
#> .weu_11 0.012 0.010 1.185 0.236 0.029 0.029
#> .RIx ~~
#> .RIy 0.158 0.016 10.133 0.000 0.242 0.242
#>
#> Intercepts:
#> Estimate Std.Err z-value P(>|z|) Std.lv Std.all
#> .Feducalter_7 -0.835 0.043 -19.231 0.000 -0.835 -0.811
#> .Feducalter_8 -0.732 0.043 -17.043 0.000 -0.732 -0.747
#> .Feducalter_9 -0.667 0.043 -15.548 0.000 -0.667 -0.686
#> .Feducalter_10 -0.572 0.043 -13.326 0.000 -0.572 -0.587
#> .Feducalter_11 -0.618 0.043 -14.418 0.000 -0.618 -0.635
#> .eu_7 0.610 0.054 11.352 0.000 0.610 0.521
#> .eu_8 0.672 0.054 12.492 0.000 0.672 0.570
#> .eu_9 0.619 0.054 11.510 0.000 0.619 0.526
#> .eu_10 0.766 0.054 14.228 0.000 0.766 0.646
#> .eu_11 0.859 0.054 15.942 0.000 0.859 0.721
#> .RIx 0.000 0.000 0.000
#> .RIy 0.000 0.000 0.000
#> wFeducalter_7 0.000 0.000 0.000
#> .wFeducalter_8 0.000 0.000 0.000
#> .wFeducalter_9 0.000 0.000 0.000
#> .wFeducalter_10 0.000 0.000 0.000
#> .wFeducalter_11 0.000 0.000 0.000
#> weu_7 0.000 0.000 0.000
#> .weu_8 0.000 0.000 0.000
#> .weu_9 0.000 0.000 0.000
#> .weu_10 0.000 0.000 0.000
#> .weu_11 0.000 0.000 0.000
#>
#> Variances:
#> Estimate Std.Err z-value P(>|z|) Std.lv Std.all
#> weu_7 0.463 0.017 27.568 0.000 1.000 1.000
#> wFeducalter_7 0.446 0.015 29.605 0.000 1.000 1.000
#> .weu_8 0.474 0.017 28.253 0.000 0.981 0.981
#> .wFeducalter_8 0.344 0.012 27.680 0.000 0.992 0.992
#> .weu_9 0.466 0.016 28.658 0.000 0.980 0.980
#> .wFeducalter_9 0.331 0.012 27.851 0.000 0.993 0.993
#> .weu_10 0.487 0.017 28.709 0.000 0.982 0.982
#> .wFeducalter_10 0.334 0.012 27.770 0.000 0.994 0.994
#> .weu_11 0.502 0.017 30.175 0.000 0.981 0.981
#> .wFeducalter_11 0.332 0.011 28.870 0.000 0.994 0.994
#> .RIx 0.504 0.017 29.939 0.000 0.823 0.823
#> .RIy 0.842 0.027 30.959 0.000 0.926 0.926
#> .Feducalter_7 0.000 0.000 0.000
#> .Feducalter_8 0.000 0.000 0.000
#> .Feducalter_9 0.000 0.000 0.000
#> .Feducalter_10 0.000 0.000 0.000
#> .Feducalter_11 0.000 0.000 0.000
#> .eu_7 0.000 0.000 0.000
#> .eu_8 0.000 0.000 0.000
#> .eu_9 0.000 0.000 0.000
#> .eu_10 0.000 0.000 0.000
#> .eu_11 0.000 0.000 0.000
myModel <- '
# Create between components (random intercepts)
RIx =~ 1*Feducalter_7 + 1*Feducalter_8 + 1*Feducalter_9 + 1*Feducalter_10 + 1*Feducalter_11
RIy =~ 1*eu_7 + 1*eu_8 + 1*eu_9 + 1*eu_10 + 1*eu_11
# Regression of random intercepts on z1.
RIx + RIy ~ educego_7
# Create within-person centered variables.
wFeducalter_7 =~ 1*Feducalter_7
wFeducalter_8 =~ 1*Feducalter_8
wFeducalter_9 =~ 1*Feducalter_9
wFeducalter_10 =~ 1*Feducalter_10
wFeducalter_11 =~ 1*Feducalter_11
weu_7 =~ 1*eu_7
weu_8 =~ 1*eu_8
weu_9 =~ 1*eu_9
weu_10 =~ 1*eu_10
weu_11 =~ 1*eu_11
# Estimate the lagged effects (constrained)
weu_8 ~ a*weu_7 + b*wFeducalter_7
weu_9 ~ a*weu_8 + b*wFeducalter_8
weu_10 ~ a*weu_9 + b*wFeducalter_9
weu_11 ~ a*weu_10 + b*wFeducalter_10
wFeducalter_8 ~ c*weu_7 + d*wFeducalter_7
wFeducalter_9 ~ c*weu_8 + d*wFeducalter_8
wFeducalter_10 ~ c*weu_9 + d*wFeducalter_9
wFeducalter_11 ~ c*weu_10 + d*wFeducalter_10
# Estimate the covariance at the first wave.
weu_7 ~~ wFeducalter_7 # Covariance
# Estimate the covariances between the residuals
weu_8 ~~ wFeducalter_8
weu_9 ~~ wFeducalter_9
weu_10 ~~ wFeducalter_10
weu_11 ~~ wFeducalter_11
# Estimate the variance
weu_7 ~~ weu_7
wFeducalter_7 ~~ wFeducalter_7
# Estimate the residual variance
weu_8 ~~ weu_8
wFeducalter_8 ~~ wFeducalter_8
weu_9 ~~ weu_9
wFeducalter_9 ~~ wFeducalter_9
weu_10 ~~ weu_10
wFeducalter_10 ~~ wFeducalter_10
weu_11 ~~ weu_11
wFeducalter_11 ~~ wFeducalter_11
# Estimate the variance and covariance of the random intercepts.
RIx ~~ RIx
RIy ~~ RIy
RIx ~~ RIy
#intercepts
Feducalter_7 ~ 1
Feducalter_8 ~ 1
Feducalter_9 ~ 1
Feducalter_10 ~ 1
Feducalter_11 ~ 1
eu_7 ~ 1
eu_8 ~ 1
eu_9 ~ 1
eu_10 ~ 1
eu_11 ~ 1
'
fit <- lavaan(myModel, data = datalwb, missing = 'ML', meanstructure = T, int.ov.free = T)
summary(fit, standardized = T)
#> lavaan 0.6-7 ended normally after 44 iterations
#>
#> Estimator ML
#> Optimization method NLMINB
#> Number of free parameters 46
#> Number of equality constraints 12
#>
#> Number of observations 2575
#> Number of missing patterns 2
#>
#> Model Test User Model:
#>
#> Test statistic 121.628
#> Degrees of freedom 41
#> P-value (Chi-square) 0.000
#>
#> Parameter Estimates:
#>
#> Standard errors Standard
#> Information Observed
#> Observed information based on Hessian
#>
#> Latent Variables:
#> Estimate Std.Err z-value P(>|z|) Std.lv Std.all
#> RIx =~
#> Feducalter_7 1.000 0.783 0.761
#> Feducalter_8 1.000 0.783 0.799
#> Feducalter_9 1.000 0.783 0.805
#> Feducalter_10 1.000 0.783 0.804
#> Feducalter_11 1.000 0.783 0.804
#> RIy =~
#> eu_7 1.000 0.953 0.814
#> eu_8 1.000 0.953 0.808
#> eu_9 1.000 0.953 0.810
#> eu_10 1.000 0.953 0.804
#> eu_11 1.000 0.953 0.800
#> wFeducalter_7 =~
#> Feducalter_7 1.000 0.668 0.649
#> wFeducalter_8 =~
#> Feducalter_8 1.000 0.589 0.601
#> wFeducalter_9 =~
#> Feducalter_9 1.000 0.577 0.594
#> wFeducalter_10 =~
#> Feducalter_10 1.000 0.580 0.595
#> wFeducalter_11 =~
#> Feducalter_11 1.000 0.578 0.594
#> weu_7 =~
#> eu_7 1.000 0.681 0.581
#> weu_8 =~
#> eu_8 1.000 0.695 0.589
#> weu_9 =~
#> eu_9 1.000 0.689 0.586
#> weu_10 =~
#> eu_10 1.000 0.704 0.594
#> weu_11 =~
#> eu_11 1.000 0.715 0.600
#>
#> Regressions:
#> Estimate Std.Err z-value P(>|z|) Std.lv Std.all
#> RIx ~
#> educego_7 0.217 0.010 21.488 0.000 0.277 0.421
#> RIy ~
#> educego_7 0.171 0.013 13.389 0.000 0.179 0.272
#> weu_8 ~
#> weu_7 (a) 0.137 0.015 8.894 0.000 0.134 0.134
#> wFedcltr_7 (b) 0.025 0.015 1.661 0.097 0.024 0.024
#> weu_9 ~
#> weu_8 (a) 0.137 0.015 8.894 0.000 0.138 0.138
#> wFedcltr_8 (b) 0.025 0.015 1.661 0.097 0.021 0.021
#> weu_10 ~
#> weu_9 (a) 0.137 0.015 8.894 0.000 0.134 0.134
#> wFedcltr_9 (b) 0.025 0.015 1.661 0.097 0.020 0.020
#> weu_11 ~
#> weu_10 (a) 0.137 0.015 8.894 0.000 0.134 0.134
#> wFdcltr_10 (b) 0.025 0.015 1.661 0.097 0.020 0.020
#> wFeducalter_8 ~
#> weu_7 (c) 0.025 0.011 2.264 0.024 0.029 0.029
#> wFedcltr_7 (d) 0.073 0.014 5.110 0.000 0.083 0.083
#> wFeducalter_9 ~
#> weu_8 (c) 0.025 0.011 2.264 0.024 0.030 0.030
#> wFedcltr_8 (d) 0.073 0.014 5.110 0.000 0.075 0.075
#> wFeducalter_10 ~
#> weu_9 (c) 0.025 0.011 2.264 0.024 0.030 0.030
#> wFedcltr_9 (d) 0.073 0.014 5.110 0.000 0.073 0.073
#> wFeducalter_11 ~
#> weu_10 (c) 0.025 0.011 2.264 0.024 0.031 0.031
#> wFdcltr_10 (d) 0.073 0.014 5.110 0.000 0.073 0.073
#>
#> Covariances:
#> Estimate Std.Err z-value P(>|z|) Std.lv Std.all
#> wFeducalter_7 ~~
#> weu_7 0.009 0.011 0.811 0.417 0.020 0.020
#> .wFeducalter_8 ~~
#> .weu_8 0.003 0.010 0.254 0.800 0.006 0.006
#> .wFeducalter_9 ~~
#> .weu_9 0.001 0.010 0.077 0.939 0.002 0.002
#> .wFeducalter_10 ~~
#> .weu_10 0.011 0.010 1.089 0.276 0.028 0.028
#> .wFeducalter_11 ~~
#> .weu_11 0.012 0.010 1.185 0.236 0.029 0.029
#> .RIx ~~
#> .RIy 0.158 0.016 10.133 0.000 0.242 0.242
#>
#> Intercepts:
#> Estimate Std.Err z-value P(>|z|) Std.lv Std.all
#> .Feducalter_7 -0.835 0.043 -19.231 0.000 -0.835 -0.811
#> .Feducalter_8 -0.732 0.043 -17.043 0.000 -0.732 -0.747
#> .Feducalter_9 -0.667 0.043 -15.548 0.000 -0.667 -0.686
#> .Feducalter_10 -0.572 0.043 -13.326 0.000 -0.572 -0.587
#> .Feducalter_11 -0.618 0.043 -14.418 0.000 -0.618 -0.635
#> .eu_7 0.610 0.054 11.352 0.000 0.610 0.521
#> .eu_8 0.672 0.054 12.492 0.000 0.672 0.570
#> .eu_9 0.619 0.054 11.510 0.000 0.619 0.526
#> .eu_10 0.766 0.054 14.228 0.000 0.766 0.646
#> .eu_11 0.859 0.054 15.942 0.000 0.859 0.721
#> .RIx 0.000 0.000 0.000
#> .RIy 0.000 0.000 0.000
#> wFeducalter_7 0.000 0.000 0.000
#> .wFeducalter_8 0.000 0.000 0.000
#> .wFeducalter_9 0.000 0.000 0.000
#> .wFeducalter_10 0.000 0.000 0.000
#> .wFeducalter_11 0.000 0.000 0.000
#> weu_7 0.000 0.000 0.000
#> .weu_8 0.000 0.000 0.000
#> .weu_9 0.000 0.000 0.000
#> .weu_10 0.000 0.000 0.000
#> .weu_11 0.000 0.000 0.000
#>
#> Variances:
#> Estimate Std.Err z-value P(>|z|) Std.lv Std.all
#> weu_7 0.463 0.017 27.568 0.000 1.000 1.000
#> wFeducalter_7 0.446 0.015 29.605 0.000 1.000 1.000
#> .weu_8 0.474 0.017 28.253 0.000 0.981 0.981
#> .wFeducalter_8 0.344 0.012 27.680 0.000 0.992 0.992
#> .weu_9 0.466 0.016 28.658 0.000 0.980 0.980
#> .wFeducalter_9 0.331 0.012 27.851 0.000 0.993 0.993
#> .weu_10 0.487 0.017 28.709 0.000 0.982 0.982
#> .wFeducalter_10 0.334 0.012 27.770 0.000 0.994 0.994
#> .weu_11 0.502 0.017 30.175 0.000 0.981 0.981
#> .wFeducalter_11 0.332 0.011 28.870 0.000 0.994 0.994
#> .RIx 0.504 0.017 29.939 0.000 0.823 0.823
#> .RIy 0.842 0.027 30.959 0.000 0.926 0.926
#> .Feducalter_7 0.000 0.000 0.000
#> .Feducalter_8 0.000 0.000 0.000
#> .Feducalter_9 0.000 0.000 0.000
#> .Feducalter_10 0.000 0.000 0.000
#> .Feducalter_11 0.000 0.000 0.000
#> .eu_7 0.000 0.000 0.000
#> .eu_8 0.000 0.000 0.000
#> .eu_9 0.000 0.000 0.000
#> .eu_10 0.000 0.000 0.000
#> .eu_11 0.000 0.000 0.000
myModel <- '
# Create between components (random intercepts)
RIx =~ 1*Feducalter_7 + 1*Feducalter_8 + 1*Feducalter_9 + 1*Feducalter_10 + 1*Feducalter_11
RIy =~ 1*eu_7 + 1*eu_8 + 1*eu_9 + 1*eu_10 + 1*eu_11
# Regression of random intercepts on z1.
RIx + RIy ~ educego_7
# Create within-person centered variables.
wFeducalter_7 =~ 1*Feducalter_7
wFeducalter_8 =~ 1*Feducalter_8
wFeducalter_9 =~ 1*Feducalter_9
wFeducalter_10 =~ 1*Feducalter_10
wFeducalter_11 =~ 1*Feducalter_11
weu_7 =~ 1*eu_7
weu_8 =~ 1*eu_8
weu_9 =~ 1*eu_9
weu_10 =~ 1*eu_10
weu_11 =~ 1*eu_11
# Estimate the lagged effects (constrained)
weu_8 ~ weu_7 + wFeducalter_7
weu_9 ~ weu_8 + wFeducalter_8
weu_10 ~ weu_9 + wFeducalter_9
weu_11 ~ weu_10 + wFeducalter_10
wFeducalter_8 ~ weu_7 + wFeducalter_7
wFeducalter_9 ~ weu_8 + wFeducalter_8
wFeducalter_10 ~ weu_9 + wFeducalter_9
wFeducalter_11 ~ weu_10 + wFeducalter_10
# Estimate the covariance at the first wave.
weu_7 ~~ wFeducalter_7 # Covariance
# Estimate the covariances between the residuals
weu_8 ~~ wFeducalter_8
weu_9 ~~ wFeducalter_9
weu_10 ~~ wFeducalter_10
weu_11 ~~ wFeducalter_11
# Estimate the variance
weu_7 ~~ weu_7
wFeducalter_7 ~~ wFeducalter_7
# Estimate the residual variance
weu_8 ~~ weu_8
wFeducalter_8 ~~ wFeducalter_8
weu_9 ~~ weu_9
wFeducalter_9 ~~ wFeducalter_9
weu_10 ~~ weu_10
wFeducalter_10 ~~ wFeducalter_10
weu_11 ~~ weu_11
wFeducalter_11 ~~ wFeducalter_11
# Estimate the variance and covariance of the random intercepts.
RIx ~~ RIx
RIy ~~ RIy
RIx ~~ RIy
#intercepts
Feducalter_7 ~ 1
Feducalter_8 ~ 1
Feducalter_9 ~ 1
Feducalter_10 ~ 1
Feducalter_11 ~ 1
eu_7 ~ 1
eu_8 ~ 1
eu_9 ~ 1
eu_10 ~ 1
eu_11 ~ 1
'
fit <- lavaan(myModel, data = datalwb, missing = 'ML', meanstructure = T, int.ov.free = T)
summary(fit, standardized = T)
#> lavaan 0.6-7 ended normally after 49 iterations
#>
#> Estimator ML
#> Optimization method NLMINB
#> Number of free parameters 46
#>
#> Number of observations 2575
#> Number of missing patterns 2
#>
#> Model Test User Model:
#>
#> Test statistic 94.854
#> Degrees of freedom 29
#> P-value (Chi-square) 0.000
#>
#> Parameter Estimates:
#>
#> Standard errors Standard
#> Information Observed
#> Observed information based on Hessian
#>
#> Latent Variables:
#> Estimate Std.Err z-value P(>|z|) Std.lv Std.all
#> RIx =~
#> Feducalter_7 1.000 0.784 0.768
#> Feducalter_8 1.000 0.784 0.808
#> Feducalter_9 1.000 0.784 0.807
#> Feducalter_10 1.000 0.784 0.798
#> Feducalter_11 1.000 0.784 0.796
#> RIy =~
#> eu_7 1.000 0.954 0.813
#> eu_8 1.000 0.954 0.808
#> eu_9 1.000 0.954 0.813
#> eu_10 1.000 0.954 0.810
#> eu_11 1.000 0.954 0.798
#> wFeducalter_7 =~
#> Feducalter_7 1.000 0.654 0.641
#> wFeducalter_8 =~
#> Feducalter_8 1.000 0.573 0.590
#> wFeducalter_9 =~
#> Feducalter_9 1.000 0.574 0.591
#> wFeducalter_10 =~
#> Feducalter_10 1.000 0.592 0.602
#> wFeducalter_11 =~
#> Feducalter_11 1.000 0.596 0.605
#> weu_7 =~
#> eu_7 1.000 0.683 0.582
#> weu_8 =~
#> eu_8 1.000 0.696 0.590
#> weu_9 =~
#> eu_9 1.000 0.685 0.583
#> weu_10 =~
#> eu_10 1.000 0.690 0.586
#> weu_11 =~
#> eu_11 1.000 0.722 0.603
#>
#> Regressions:
#> Estimate Std.Err z-value P(>|z|) Std.lv Std.all
#> RIx ~
#> educego_7 0.219 0.010 21.620 0.000 0.279 0.423
#> RIy ~
#> educego_7 0.170 0.013 13.338 0.000 0.178 0.271
#> weu_8 ~
#> weu_7 0.136 0.031 4.415 0.000 0.133 0.133
#> wFeducalter_7 0.030 0.029 1.030 0.303 0.028 0.028
#> weu_9 ~
#> weu_8 0.147 0.029 5.152 0.000 0.150 0.150
#> wFeducalter_8 0.077 0.034 2.270 0.023 0.065 0.065
#> weu_10 ~
#> weu_9 0.072 0.032 2.283 0.022 0.072 0.072
#> wFeducalter_9 0.001 0.035 0.021 0.983 0.001 0.001
#> weu_11 ~
#> weu_10 0.162 0.030 5.318 0.000 0.155 0.155
#> wFeducalter_10 -0.004 0.033 -0.116 0.908 -0.003 -0.003
#> wFeducalter_8 ~
#> weu_7 0.023 0.025 0.904 0.366 0.027 0.027
#> wFeducalter_7 0.007 0.027 0.258 0.796 0.008 0.008
#> wFeducalter_9 ~
#> weu_8 0.026 0.024 1.057 0.290 0.031 0.031
#> wFeducalter_8 0.065 0.031 2.063 0.039 0.065 0.065
#> wFeducalter_10 ~
#> weu_9 0.031 0.026 1.208 0.227 0.036 0.036
#> wFeducalter_9 0.069 0.031 2.271 0.023 0.067 0.067
#> wFeducalter_11 ~
#> weu_10 0.029 0.024 1.225 0.221 0.034 0.034
#> wFeducalter_10 0.154 0.029 5.357 0.000 0.152 0.152
#>
#> Covariances:
#> Estimate Std.Err z-value P(>|z|) Std.lv Std.all
#> wFeducalter_7 ~~
#> weu_7 0.009 0.012 0.744 0.457 0.021 0.021
#> .wFeducalter_8 ~~
#> .weu_8 0.006 0.012 0.526 0.599 0.016 0.016
#> .wFeducalter_9 ~~
#> .weu_9 0.005 0.011 0.428 0.669 0.012 0.012
#> .wFeducalter_10 ~~
#> .weu_10 0.007 0.012 0.624 0.532 0.018 0.018
#> .wFeducalter_11 ~~
#> .weu_11 0.011 0.011 0.991 0.322 0.025 0.025
#> .RIx ~~
#> .RIy 0.156 0.016 9.993 0.000 0.239 0.239
#>
#> Intercepts:
#> Estimate Std.Err z-value P(>|z|) Std.lv Std.all
#> .Feducalter_7 -0.842 0.043 -19.395 0.000 -0.842 -0.824
#> .Feducalter_8 -0.739 0.043 -17.213 0.000 -0.739 -0.761
#> .Feducalter_9 -0.674 0.043 -15.690 0.000 -0.674 -0.693
#> .Feducalter_10 -0.579 0.043 -13.447 0.000 -0.579 -0.589
#> .Feducalter_11 -0.626 0.043 -14.523 0.000 -0.626 -0.635
#> .eu_7 0.612 0.054 11.369 0.000 0.612 0.521
#> .eu_8 0.674 0.054 12.508 0.000 0.674 0.570
#> .eu_9 0.620 0.054 11.533 0.000 0.620 0.528
#> .eu_10 0.768 0.054 14.262 0.000 0.768 0.652
#> .eu_11 0.861 0.054 15.946 0.000 0.861 0.720
#> .RIx 0.000 0.000 0.000
#> .RIy 0.000 0.000 0.000
#> wFeducalter_7 0.000 0.000 0.000
#> .wFeducalter_8 0.000 0.000 0.000
#> .wFeducalter_9 0.000 0.000 0.000
#> .wFeducalter_10 0.000 0.000 0.000
#> .wFeducalter_11 0.000 0.000 0.000
#> weu_7 0.000 0.000 0.000
#> .weu_8 0.000 0.000 0.000
#> .weu_9 0.000 0.000 0.000
#> .weu_10 0.000 0.000 0.000
#> .weu_11 0.000 0.000 0.000
#>
#> Variances:
#> Estimate Std.Err z-value P(>|z|) Std.lv Std.all
#> weu_7 0.466 0.019 24.250 0.000 1.000 1.000
#> wFeducalter_7 0.428 0.016 26.970 0.000 1.000 1.000
#> .weu_8 0.476 0.019 25.539 0.000 0.981 0.981
#> .wFeducalter_8 0.328 0.014 22.735 0.000 0.999 0.999
#> .weu_9 0.456 0.018 25.613 0.000 0.973 0.973
#> .wFeducalter_9 0.328 0.013 24.552 0.000 0.995 0.995
#> .weu_10 0.474 0.020 23.587 0.000 0.995 0.995
#> .wFeducalter_10 0.348 0.014 24.906 0.000 0.994 0.994
#> .weu_11 0.508 0.018 28.330 0.000 0.976 0.976
#> .wFeducalter_11 0.347 0.013 27.648 0.000 0.975 0.975
#> .RIx 0.505 0.017 29.717 0.000 0.821 0.821
#> .RIy 0.844 0.027 30.932 0.000 0.927 0.927
#> .Feducalter_7 0.000 0.000 0.000
#> .Feducalter_8 0.000 0.000 0.000
#> .Feducalter_9 0.000 0.000 0.000
#> .Feducalter_10 0.000 0.000 0.000
#> .Feducalter_11 0.000 0.000 0.000
#> .eu_7 0.000 0.000 0.000
#> .eu_8 0.000 0.000 0.000
#> .eu_9 0.000 0.000 0.000
#> .eu_10 0.000 0.000 0.000
#> .eu_11 0.000 0.000 0.000
this means that we no longer have a random intercept but rather a latent variable. We however know we have also structural changes. And our measures are one year apart.
myModel <- '
# Create between components (random intercepts)
RIx =~ 1*Feducalter_7 + Feducalter_8 + Feducalter_9 + Feducalter_10 + Feducalter_11
RIy =~ 1*eu_7 + eu_8 + eu_9 + eu_10 + eu_11
# Regression of random intercepts / latent variable on z1.
RIx + RIy ~ educego_7
# Create within-person centered variables.
wFeducalter_7 =~ 1*Feducalter_7
wFeducalter_8 =~ 1*Feducalter_8
wFeducalter_9 =~ 1*Feducalter_9
wFeducalter_10 =~ 1*Feducalter_10
wFeducalter_11 =~ 1*Feducalter_11
weu_7 =~ 1*eu_7
weu_8 =~ 1*eu_8
weu_9 =~ 1*eu_9
weu_10 =~ 1*eu_10
weu_11 =~ 1*eu_11
# Estimate the lagged effects (constrained)
weu_8 ~ weu_7 + wFeducalter_7
weu_9 ~ weu_8 + wFeducalter_8
weu_10 ~ weu_9 + wFeducalter_9
weu_11 ~ weu_10 + wFeducalter_10
wFeducalter_8 ~ weu_7 + wFeducalter_7
wFeducalter_9 ~ weu_8 + wFeducalter_8
wFeducalter_10 ~ weu_9 + wFeducalter_9
wFeducalter_11 ~ weu_10 + wFeducalter_10
# Estimate the covariance at the first wave.
weu_7 ~~ wFeducalter_7 # Covariance
# Estimate the covariances between the residuals
weu_8 ~~ wFeducalter_8
weu_9 ~~ wFeducalter_9
weu_10 ~~ wFeducalter_10
weu_11 ~~ wFeducalter_11
# Estimate the variance
weu_7 ~~ weu_7
wFeducalter_7 ~~ wFeducalter_7
# Estimate the residual variance
weu_8 ~~ weu_8
wFeducalter_8 ~~ wFeducalter_8
weu_9 ~~ weu_9
wFeducalter_9 ~~ wFeducalter_9
weu_10 ~~ weu_10
wFeducalter_10 ~~ wFeducalter_10
weu_11 ~~ weu_11
wFeducalter_11 ~~ wFeducalter_11
# Estimate the variance and covariance of the random intercepts.
RIx ~~ RIx
RIy ~~ RIy
RIx ~~ RIy
#intercepts
Feducalter_7 ~ 1
Feducalter_8 ~ 1
Feducalter_9 ~ 1
Feducalter_10 ~ 1
Feducalter_11 ~ 1
eu_7 ~ 1
eu_8 ~ 1
eu_9 ~ 1
eu_10 ~ 1
eu_11 ~ 1
'
fit <- lavaan(myModel, data = datalwb, missing = 'ML', meanstructure = T, int.ov.free = T)
summary(fit, standardized = T)
#> lavaan 0.6-7 ended normally after 61 iterations
#>
#> Estimator ML
#> Optimization method NLMINB
#> Number of free parameters 54
#>
#> Number of observations 2575
#> Number of missing patterns 2
#>
#> Model Test User Model:
#>
#> Test statistic 45.122
#> Degrees of freedom 21
#> P-value (Chi-square) 0.002
#>
#> Parameter Estimates:
#>
#> Standard errors Standard
#> Information Observed
#> Observed information based on Hessian
#>
#> Latent Variables:
#> Estimate Std.Err z-value P(>|z|) Std.lv Std.all
#> RIx =~
#> Feducalter_7 1.000 0.817 0.787
#> Feducalter_8 0.980 0.025 39.535 0.000 0.801 0.825
#> Feducalter_9 1.014 0.028 35.734 0.000 0.829 0.832
#> Feducalter_10 0.948 0.028 33.597 0.000 0.775 0.788
#> Feducalter_11 0.869 0.025 34.369 0.000 0.710 0.753
#> RIy =~
#> eu_7 1.000 0.927 0.801
#> eu_8 1.044 0.023 46.041 0.000 0.968 0.814
#> eu_9 1.052 0.027 38.833 0.000 0.976 0.823
#> eu_10 1.019 0.031 32.882 0.000 0.944 0.807
#> eu_11 1.041 0.029 35.465 0.000 0.965 0.802
#> wFeducalter_7 =~
#> Feducalter_7 1.000 0.641 0.617
#> wFeducalter_8 =~
#> Feducalter_8 1.000 0.548 0.565
#> wFeducalter_9 =~
#> Feducalter_9 1.000 0.553 0.555
#> wFeducalter_10 =~
#> Feducalter_10 1.000 0.606 0.616
#> wFeducalter_11 =~
#> Feducalter_11 1.000 0.620 0.658
#> weu_7 =~
#> eu_7 1.000 0.692 0.598
#> weu_8 =~
#> eu_8 1.000 0.692 0.581
#> weu_9 =~
#> eu_9 1.000 0.673 0.568
#> weu_10 =~
#> eu_10 1.000 0.690 0.590
#> weu_11 =~
#> eu_11 1.000 0.719 0.598
#>
#> Regressions:
#> Estimate Std.Err z-value P(>|z|) Std.lv Std.all
#> RIx ~
#> educego_7 0.228 0.011 19.981 0.000 0.279 0.423
#> RIy ~
#> educego_7 0.165 0.013 12.893 0.000 0.178 0.270
#> weu_8 ~
#> weu_7 0.140 0.040 3.546 0.000 0.140 0.140
#> wFeducalter_7 0.026 0.031 0.841 0.401 0.024 0.024
#> weu_9 ~
#> weu_8 0.125 0.035 3.582 0.000 0.129 0.129
#> wFeducalter_8 0.082 0.036 2.238 0.025 0.066 0.066
#> weu_10 ~
#> weu_9 0.058 0.040 1.428 0.153 0.056 0.056
#> wFeducalter_9 0.005 0.037 0.131 0.896 0.004 0.004
#> weu_11 ~
#> weu_10 0.159 0.040 3.982 0.000 0.152 0.152
#> wFeducalter_10 0.002 0.032 0.069 0.945 0.002 0.002
#> wFeducalter_8 ~
#> weu_7 0.019 0.024 0.799 0.425 0.024 0.024
#> wFeducalter_7 -0.048 0.036 -1.332 0.183 -0.056 -0.056
#> wFeducalter_9 ~
#> weu_8 0.023 0.026 0.904 0.366 0.029 0.029
#> wFeducalter_8 -0.015 0.039 -0.380 0.704 -0.015 -0.015
#> wFeducalter_10 ~
#> weu_9 0.035 0.027 1.316 0.188 0.039 0.039
#> wFeducalter_9 0.068 0.042 1.615 0.106 0.062 0.062
#> wFeducalter_11 ~
#> weu_10 0.030 0.022 1.335 0.182 0.033 0.033
#> wFeducalter_10 0.214 0.029 7.316 0.000 0.209 0.209
#>
#> Covariances:
#> Estimate Std.Err z-value P(>|z|) Std.lv Std.all
#> wFeducalter_7 ~~
#> weu_7 0.006 0.012 0.510 0.610 0.014 0.014
#> .wFeducalter_8 ~~
#> .weu_8 0.004 0.012 0.341 0.733 0.011 0.011
#> .wFeducalter_9 ~~
#> .weu_9 0.007 0.011 0.631 0.528 0.020 0.020
#> .wFeducalter_10 ~~
#> .weu_10 0.010 0.012 0.828 0.408 0.024 0.024
#> .wFeducalter_11 ~~
#> .weu_11 0.013 0.010 1.211 0.226 0.029 0.029
#> .RIx ~~
#> .RIy 0.155 0.016 9.620 0.000 0.234 0.234
#>
#> Intercepts:
#> Estimate Std.Err z-value P(>|z|) Std.lv Std.all
#> .Feducalter_7 -0.877 0.048 -18.271 0.000 -0.877 -0.845
#> .Feducalter_8 -0.757 0.046 -16.474 0.000 -0.757 -0.780
#> .Feducalter_9 -0.721 0.046 -15.581 0.000 -0.721 -0.724
#> .Feducalter_10 -0.569 0.045 -12.721 0.000 -0.569 -0.578
#> .Feducalter_11 -0.545 0.042 -13.090 0.000 -0.545 -0.579
#> .eu_7 0.632 0.054 11.749 0.000 0.632 0.546
#> .eu_8 0.666 0.056 11.917 0.000 0.666 0.560
#> .eu_9 0.608 0.055 10.948 0.000 0.608 0.513
#> .eu_10 0.776 0.054 14.324 0.000 0.776 0.663
#> .eu_11 0.855 0.056 15.401 0.000 0.855 0.710
#> .RIx 0.000 0.000 0.000
#> .RIy 0.000 0.000 0.000
#> wFeducalter_7 0.000 0.000 0.000
#> .wFeducalter_8 0.000 0.000 0.000
#> .wFeducalter_9 0.000 0.000 0.000
#> .wFeducalter_10 0.000 0.000 0.000
#> .wFeducalter_11 0.000 0.000 0.000
#> weu_7 0.000 0.000 0.000
#> .weu_8 0.000 0.000 0.000
#> .weu_9 0.000 0.000 0.000
#> .weu_10 0.000 0.000 0.000
#> .weu_11 0.000 0.000 0.000
#>
#> Variances:
#> Estimate Std.Err z-value P(>|z|) Std.lv Std.all
#> weu_7 0.479 0.023 21.010 0.000 1.000 1.000
#> wFeducalter_7 0.410 0.018 22.270 0.000 1.000 1.000
#> .weu_8 0.468 0.023 20.197 0.000 0.980 0.980
#> .wFeducalter_8 0.299 0.019 15.697 0.000 0.996 0.996
#> .weu_9 0.443 0.020 21.708 0.000 0.979 0.979
#> .wFeducalter_9 0.305 0.017 18.147 0.000 0.999 0.999
#> .weu_10 0.475 0.026 18.176 0.000 0.997 0.997
#> .wFeducalter_10 0.365 0.016 22.518 0.000 0.995 0.995
#> .weu_11 0.506 0.020 24.704 0.000 0.977 0.977
#> .wFeducalter_11 0.367 0.012 30.045 0.000 0.955 0.955
#> .RIx 0.548 0.026 21.099 0.000 0.821 0.821
#> .RIy 0.797 0.036 21.861 0.000 0.927 0.927
#> .Feducalter_7 0.000 0.000 0.000
#> .Feducalter_8 0.000 0.000 0.000
#> .Feducalter_9 0.000 0.000 0.000
#> .Feducalter_10 0.000 0.000 0.000
#> .Feducalter_11 0.000 0.000 0.000
#> .eu_7 0.000 0.000 0.000
#> .eu_8 0.000 0.000 0.000
#> .eu_9 0.000 0.000 0.000
#> .eu_10 0.000 0.000 0.000
#> .eu_11 0.000 0.000 0.000
Hamaker, Ellen L, Rebecca M Kuiper, and Raoul PPP Grasman. 2015. “A Critique of the Cross-Lagged Panel Model.” Psychological Methods 20 (1): 102.
Mulder, Jeroen D., and Ellen L. Hamaker. 2020. “Three Extensions of the Random Intercept Cross-Lagged Panel Model.” Structural Equation Modeling: A Multidisciplinary Journal. https://doi.org/10.1080/10705511.2020.1784738.
Rosseel, Yves. 2012. “lavaan: An R Package for Structural Equation Modeling.” Journal of Statistical Software 48 (2): 1–36. http://www.jstatsoft.org/v48/i02/.