── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
✔ dplyr 1.1.4 ✔ readr 2.1.5
✔ forcats 1.0.0 ✔ stringr 1.5.1
✔ ggplot2 3.5.1 ✔ tibble 3.2.1
✔ lubridate 1.9.3 ✔ tidyr 1.3.1
✔ purrr 1.0.2
── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
✖ dplyr::filter() masks stats::filter()
✖ dplyr::lag() masks stats::lag()
ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
library (ggplot2)
library (lavaan)
This is lavaan 0.6-19
lavaan is FREE software! Please report any bugs.
library (lavaanPlot)
library (semPlot)
library (semTools)
###############################################################################
This is semTools 0.5-6
All users of R (or SEM) are invited to submit functions or ideas for functions.
###############################################################################
Attaching package: 'semTools'
The following object is masked from 'package:readr':
clipboard
library (grid)
library (haven)
library (knitr)
library (kableExtra)
Attaching package: 'kableExtra'
The following object is masked from 'package:dplyr':
group_rows
library (lattice)
library (patchwork)
library (lcsm)
This is lcsm 0.3.2
Please report any issues or ideas at:
https://github.com/milanwiedemann/lcsm/issues
plot_x <- plot_trajectories (data = NLSY_Data,
id_var = "id" ,
var_list = c ("math2" , "math3" , "math4" , "math5" ,"math6"
,"math7" , "math8" ),
xlab = "Wave" , ylab = "Math Score" ,
connect_missing = TRUE ,
random_sample_frac = 0.3 )
plot_x
Warning: Removed 1292 rows containing missing values or values outside the scale range
(`geom_point()`).
plot_y <- plot_trajectories (data = NLSY_Data,
id_var = "id" ,
var_list = c ("rec2" , "rec3" , "rec4" , "rec5" , "rec6" ,
"rec7" , "rec8" ),
xlab = "Wave" , ylab = "Reading Score" ,
connect_missing = TRUE ,
random_sample_frac = 0.3 )
plot_y
Warning: Removed 1293 rows containing missing values or values outside the scale range
(`geom_point()`).
plot_x + plot_y + plot_annotation (tag_levels = 'A' )
Warning: Removed 1292 rows containing missing values or values outside the scale range
(`geom_point()`).
Removed 1293 rows containing missing values or values outside the scale range
(`geom_point()`).
bdcm.lavaan <- '
#mathematics
#latent true scores
lm1 =~ 1*math2
lm2 =~ 1*math3
lm3 =~ 1*math4
lm4 =~ 1*math5
lm5 =~ 1*math6
lm6 =~ 1*math7
lm7 =~ 1*math8
#latent true score means
lm1 ~ 1
lm2 ~ 0*1
lm3 ~ 0*1
lm4 ~ 0*1
lm5 ~ 0*1
lm6 ~ 0*1
lm7 ~ 0*1
#latent true score variances
lm1 ~~ start(15)*lm1
lm2 ~~ 0*lm2
lm3 ~~ 0*lm3
lm4 ~~ 0*lm4
lm5 ~~ 0*lm5
lm6 ~~ 0*lm6
lm7 ~~ 0*lm7
#observed intercepts (fixed to zero)
math2 ~ 0*1
math3 ~ 0*1
math4 ~ 0*1
math5 ~ 0*1
math6 ~ 0*1
math7 ~ 0*1
math8 ~ 0*1
#observed residual variances
math2 ~~ sigma2_u*math2
math3 ~~ sigma2_u*math3
math4 ~~ sigma2_u*math4
math5 ~~ sigma2_u*math5
math6 ~~ sigma2_u*math6
math7 ~~ sigma2_u*math7
math8 ~~ sigma2_u*math8
#autoregressions
lm2 ~ 1*lm1
lm3 ~ 1*lm2
lm4 ~ 1*lm3
lm5 ~ 1*lm4
lm6 ~ 1*lm5
lm7 ~ 1*lm6
#latent change scores
dm2 =~ 1*lm2
dm3 =~ 1*lm3
dm4 =~ 1*lm4
dm5 =~ 1*lm5
dm6 =~ 1*lm6
dm7 =~ 1*lm7
#latent change score means
dm2 ~ 0*1
dm3 ~ 0*1
dm4 ~ 0*1
dm5 ~ 0*1
dm6 ~ 0*1
dm7 ~ 0*1
#latent change score variances
dm2 ~~ 0*dm2
dm3 ~~ 0*dm3
dm4 ~~ 0*dm4
dm5 ~~ 0*dm5
dm6 ~~ 0*dm6
dm7 ~~ 0*dm7
#constant change factor
g2 =~ 1*dm2 +
1*dm3 +
1*dm4 +
1*dm5 +
1*dm6 +
1*dm7
#constant change factor mean
g2 ~ start(15)*1
#constant change factor variance
g2 ~~ g2
#constant change factor covariance with the initial true score
g2 ~~ lm1
#proportional effects
dm2 ~ start(-.2)*pi_m * lm1
dm3 ~ start(-.2)*pi_m * lm2
dm4 ~ start(-.2)*pi_m * lm3
dm5 ~ start(-.2)*pi_m * lm4
dm6 ~ start(-.2)*pi_m * lm5
dm7 ~ start(-.2)*pi_m * lm6
#reading
#latent true scores
lr1 =~ 1*rec2
lr2 =~ 1*rec3
lr3 =~ 1*rec4
lr4 =~ 1*rec5
lr5 =~ 1*rec6
lr6 =~ 1*rec7
lr7 =~ 1*rec8
#latent true score means
lr1 ~ 1
lr2 ~ 0*1
lr3 ~ 0*1
lr4 ~ 0*1
lr5 ~ 0*1
lr6 ~ 0*1
lr7 ~ 0*1
#latent true score variances
lr1 ~~ start(15)*lr1
lr2 ~~ 0*lr2
lr3 ~~ 0*lr3
lr4 ~~ 0*lr4
lr5 ~~ 0*lr5
lr6 ~~ 0*lr6
lr7 ~~ 0*lr7
#observed intercept variances (fixed to zero)
rec2 ~ 0*1
rec3 ~ 0*1
rec4 ~ 0*1
rec5 ~ 0*1
rec6 ~ 0*1
rec7 ~ 0*1
rec8 ~ 0*1
#observed residual variances
rec2 ~~ sigma2_s*rec2
rec3 ~~ sigma2_s*rec3
rec4 ~~ sigma2_s*rec4
rec5 ~~ sigma2_s*rec5
rec6 ~~ sigma2_s*rec6
rec7 ~~ sigma2_s*rec7
rec8 ~~ sigma2_s*rec8
#autoregressions
lr2 ~ 1*lr1
lr3 ~ 1*lr2
lr4 ~ 1*lr3
lr5 ~ 1*lr4
lr6 ~ 1*lr5
lr7 ~ 1*lr6
#latent change scores
dr2 =~ 1*lr2
dr3 =~ 1*lr3
dr4 =~ 1*lr4
dr5 =~ 1*lr5
dr6 =~ 1*lr6
dr7 =~ 1*lr7
#latent change score means
dr2 ~ 0*1
dr3 ~ 0*1
dr4 ~ 0*1
dr5 ~ 0*1
dr6 ~ 0*1
dr7 ~ 0*1
#latent change score variances
dr2 ~~ 0*dr2
dr3 ~~ 0*dr3
dr4 ~~ 0*dr4
dr5 ~~ 0*dr5
dr6 ~~ 0*dr6
dr7 ~~ 0*dr7
#constant change factor
j2 =~ 1*dr2 +
1*dr3 +
1*dr4 +
1*dr5 +
1*dr6 +
1*dr7
#constant change factor mean
j2 ~ start(10)*1
#constant change factor variance
j2 ~~ j2
#constant change factor covariance with the initial true score
j2 ~~ lr1
#proportional effects
dr2 ~ start(-.2)*pi_r * lr1
dr3 ~ start(-.2)*pi_r * lr2
dr4 ~ start(-.2)*pi_r * lr3
dr5 ~ start(-.2)*pi_r * lr4
dr6 ~ start(-.2)*pi_r * lr5
dr7 ~ start(-.2)*pi_r * lr6
#bivariate information
#covariances between the latent growth factors
lm1 ~~ lr1
g2 ~~ j2
lm1 ~~ j2
lr1 ~~ g2
#residual covariances
math2 ~~ sigma_su*rec2
math3 ~~ sigma_su*rec3
math4 ~~ sigma_su*rec4
math5 ~~ sigma_su*rec5
math6 ~~ sigma_su*rec6
math7 ~~ sigma_su*rec7
#coupling parameters
#math to reading
dr2 ~ delta_r*lm1
dr3 ~ delta_r*lm2
dr4 ~ delta_r*lm3
dr5 ~ delta_r*lm4
dr6 ~ delta_r*lm5
dr7 ~ delta_r*lm6
#reading to math
dm2 ~ delta_m*lr1
dm3 ~ delta_m*lr2
dm4 ~ delta_m*lr3
dm5 ~ delta_m*lr4
dm6 ~ delta_m*lr5
dm7 ~ delta_m*lr6'
lavaan.fit <- lavaan (bdcm.lavaan,
data = NLSY_Data,
meanstructure = TRUE ,
estimator = "ML" ,
missing = "fiml" ,
fixed.x = FALSE ,
mimic= "mplus" ,
control= list (iter.max= 500 ),
verbose= FALSE )
Warning: lavaan->lav_data_full():
some cases are empty and will be ignored: 741.
Warning: lavaan->lav_data_full():
due to missing values, some pairwise combinations have less than 10%
coverage; use lavInspect(fit, "coverage") to investigate.
Warning: lavaan->lav_mvnorm_missing_h1_estimate_moments():
Maximum number of iterations reached when computing the sample moments
using EM; use the em.h1.iter.max= argument to increase the number of
iterations
summary (lavaan.fit, fit.measures = TRUE , std.nox = FALSE )
lavaan 0.6-19 ended normally after 252 iterations
Estimator ML
Optimization method NLMINB
Number of model parameters 58
Number of equality constraints 37
Used Total
Number of observations 932 933
Number of missing patterns 66
Model Test User Model:
Test statistic 166.098
Degrees of freedom 98
P-value (Chi-square) 0.000
Model Test Baseline Model:
Test statistic 2710.581
Degrees of freedom 91
P-value 0.000
User Model versus Baseline Model:
Comparative Fit Index (CFI) 0.974
Tucker-Lewis Index (TLI) 0.976
Robust Comparative Fit Index (CFI) 0.876
Robust Tucker-Lewis Index (TLI) 0.884
Loglikelihood and Information Criteria:
Loglikelihood user model (H0) -15680.484
Loglikelihood unrestricted model (H1) -15597.435
Akaike (AIC) 31402.968
Bayesian (BIC) 31504.552
Sample-size adjusted Bayesian (SABIC) 31437.857
Root Mean Square Error of Approximation:
RMSEA 0.027
90 Percent confidence interval - lower 0.020
90 Percent confidence interval - upper 0.034
P-value H_0: RMSEA <= 0.050 1.000
P-value H_0: RMSEA >= 0.080 0.000
Robust RMSEA 0.135
90 Percent confidence interval - lower 0.104
90 Percent confidence interval - upper 0.166
P-value H_0: Robust RMSEA <= 0.050 0.000
P-value H_0: Robust RMSEA >= 0.080 0.997
Standardized Root Mean Square Residual:
SRMR 0.111
Parameter Estimates:
Standard errors Standard
Information Observed
Observed information based on Hessian
Latent Variables:
Estimate Std.Err z-value P(>|z|)
lm1 =~
math2 1.000
lm2 =~
math3 1.000
lm3 =~
math4 1.000
lm4 =~
math5 1.000
lm5 =~
math6 1.000
lm6 =~
math7 1.000
lm7 =~
math8 1.000
dm2 =~
lm2 1.000
dm3 =~
lm3 1.000
dm4 =~
lm4 1.000
dm5 =~
lm5 1.000
dm6 =~
lm6 1.000
dm7 =~
lm7 1.000
g2 =~
dm2 1.000
dm3 1.000
dm4 1.000
dm5 1.000
dm6 1.000
dm7 1.000
lr1 =~
rec2 1.000
lr2 =~
rec3 1.000
lr3 =~
rec4 1.000
lr4 =~
rec5 1.000
lr5 =~
rec6 1.000
lr6 =~
rec7 1.000
lr7 =~
rec8 1.000
dr2 =~
lr2 1.000
dr3 =~
lr3 1.000
dr4 =~
lr4 1.000
dr5 =~
lr5 1.000
dr6 =~
lr6 1.000
dr7 =~
lr7 1.000
j2 =~
dr2 1.000
dr3 1.000
dr4 1.000
dr5 1.000
dr6 1.000
dr7 1.000
Regressions:
Estimate Std.Err z-value P(>|z|)
lm2 ~
lm1 1.000
lm3 ~
lm2 1.000
lm4 ~
lm3 1.000
lm5 ~
lm4 1.000
lm6 ~
lm5 1.000
lm7 ~
lm6 1.000
dm2 ~
lm1 (pi_m) -0.293 0.115 -2.560 0.010
dm3 ~
lm2 (pi_m) -0.293 0.115 -2.560 0.010
dm4 ~
lm3 (pi_m) -0.293 0.115 -2.560 0.010
dm5 ~
lm4 (pi_m) -0.293 0.115 -2.560 0.010
dm6 ~
lm5 (pi_m) -0.293 0.115 -2.560 0.010
dm7 ~
lm6 (pi_m) -0.293 0.115 -2.560 0.010
lr2 ~
lr1 1.000
lr3 ~
lr2 1.000
lr4 ~
lr3 1.000
lr5 ~
lr4 1.000
lr6 ~
lr5 1.000
lr7 ~
lr6 1.000
dr2 ~
lr1 (pi_r) -0.495 0.115 -4.308 0.000
dr3 ~
lr2 (pi_r) -0.495 0.115 -4.308 0.000
dr4 ~
lr3 (pi_r) -0.495 0.115 -4.308 0.000
dr5 ~
lr4 (pi_r) -0.495 0.115 -4.308 0.000
dr6 ~
lr5 (pi_r) -0.495 0.115 -4.308 0.000
dr7 ~
lr6 (pi_r) -0.495 0.115 -4.308 0.000
dr2 ~
lm1 (dlt_r) 0.391 0.129 3.029 0.002
dr3 ~
lm2 (dlt_r) 0.391 0.129 3.029 0.002
dr4 ~
lm3 (dlt_r) 0.391 0.129 3.029 0.002
dr5 ~
lm4 (dlt_r) 0.391 0.129 3.029 0.002
dr6 ~
lm5 (dlt_r) 0.391 0.129 3.029 0.002
dr7 ~
lm6 (dlt_r) 0.391 0.129 3.029 0.002
dm2 ~
lr1 (dlt_m) 0.053 0.098 0.540 0.589
dm3 ~
lr2 (dlt_m) 0.053 0.098 0.540 0.589
dm4 ~
lr3 (dlt_m) 0.053 0.098 0.540 0.589
dm5 ~
lr4 (dlt_m) 0.053 0.098 0.540 0.589
dm6 ~
lr5 (dlt_m) 0.053 0.098 0.540 0.589
dm7 ~
lr6 (dlt_m) 0.053 0.098 0.540 0.589
Covariances:
Estimate Std.Err z-value P(>|z|)
lm1 ~~
g2 14.165 2.164 6.545 0.000
lr1 ~~
j2 26.323 3.483 7.557 0.000
lm1 ~~
lr1 56.493 5.487 10.297 0.000
g2 ~~
j2 0.681 2.552 0.267 0.790
lm1 ~~
j2 6.163 3.103 1.986 0.047
g2 ~~
lr1 9.791 3.083 3.176 0.001
.math2 ~~
.rec2 (sgm_) 7.008 1.259 5.566 0.000
.math3 ~~
.rec3 (sgm_) 7.008 1.259 5.566 0.000
.math4 ~~
.rec4 (sgm_) 7.008 1.259 5.566 0.000
.math5 ~~
.rec5 (sgm_) 7.008 1.259 5.566 0.000
.math6 ~~
.rec6 (sgm_) 7.008 1.259 5.566 0.000
.math7 ~~
.rec7 (sgm_) 7.008 1.259 5.566 0.000
Intercepts:
Estimate Std.Err z-value P(>|z|)
lm1 32.543 0.446 72.980 0.000
.lm2 0.000
.lm3 0.000
.lm4 0.000
.lm5 0.000
.lm6 0.000
.lm7 0.000
.math2 0.000
.math3 0.000
.math4 0.000
.math5 0.000
.math6 0.000
.math7 0.000
.math8 0.000
.dm2 0.000
.dm3 0.000
.dm4 0.000
.dm5 0.000
.dm6 0.000
.dm7 0.000
g2 15.092 0.926 16.291 0.000
lr1 34.386 0.433 79.425 0.000
.lr2 0.000
.lr3 0.000
.lr4 0.000
.lr5 0.000
.lr6 0.000
.lr7 0.000
.rec2 0.000
.rec3 0.000
.rec4 0.000
.rec5 0.000
.rec6 0.000
.rec7 0.000
.rec8 0.000
.dr2 0.000
.dr3 0.000
.dr4 0.000
.dr5 0.000
.dr6 0.000
.dr7 0.000
j2 10.886 0.934 11.650 0.000
Variances:
Estimate Std.Err z-value P(>|z|)
lm1 72.886 6.603 11.038 0.000
.lm2 0.000
.lm3 0.000
.lm4 0.000
.lm5 0.000
.lm6 0.000
.lm7 0.000
.math2 (sigm2_) 31.306 1.609 19.460 0.000
.math3 (sigm2_) 31.306 1.609 19.460 0.000
.math4 (sigm2_) 31.306 1.609 19.460 0.000
.math5 (sigm2_) 31.306 1.609 19.460 0.000
.math6 (sigm2_) 31.306 1.609 19.460 0.000
.math7 (sigm2_) 31.306 1.609 19.460 0.000
.math8 (sigm2_) 31.306 1.609 19.460 0.000
.dm2 0.000
.dm3 0.000
.dm4 0.000
.dm5 0.000
.dm6 0.000
.dm7 0.000
g2 5.743 1.697 3.384 0.001
lr1 71.978 7.273 9.896 0.000
.lr2 0.000
.lr3 0.000
.lr4 0.000
.lr5 0.000
.lr6 0.000
.lr7 0.000
.rec2 (sgm2_s) 33.217 1.763 18.843 0.000
.rec3 (sgm2_s) 33.217 1.763 18.843 0.000
.rec4 (sgm2_s) 33.217 1.763 18.843 0.000
.rec5 (sgm2_s) 33.217 1.763 18.843 0.000
.rec6 (sgm2_s) 33.217 1.763 18.843 0.000
.rec7 (sgm2_s) 33.217 1.763 18.843 0.000
.rec8 (sgm2_s) 33.217 1.763 18.843 0.000
.dr2 0.000
.dr3 0.000
.dr4 0.000
.dr5 0.000
.dr6 0.000
.dr7 0.000
j2 18.384 6.806 2.701 0.007
bi_lcsm_01 <- fit_bi_lcsm (data = NLSY_Data,
var_x = c ("math2" , "math3" , "math4" , "math5" , "math6" ,
"math7" , "math8" ),
var_y = c ("rec2" , "rec3" , "rec4" , "rec5" , "rec6" ,
"rec7" , "rec8" ),
model_x = list (alpha_constant = TRUE ,
beta = TRUE ,
phi = TRUE ),
model_y = list (alpha_constant = TRUE ,
beta = TRUE ,
phi = TRUE ),
coupling = list (delta_lag_xy = TRUE ,
xi_lag_yx = TRUE ,
yi_lag_xy = TRUE ))
Warning: lavaan->lav_data_full():
some cases are empty and will be ignored: 741.
Warning: lavaan->lav_data_full():
due to missing values, some pairwise combinations have less than 10%
coverage; use lavInspect(fit, "coverage") to investigate.
Warning: lavaan->lav_mvnorm_missing_h1_estimate_moments():
Maximum number of iterations reached when computing the sample moments
using EM; use the em.h1.iter.max= argument to increase the number of
iterations
param_bi_lcsm_01 <- extract_param (bi_lcsm_01, printp = TRUE )[ , 1 : 7 ]
summary (param_bi_lcsm_01)
label estimate std.error statistic
Length:23 Min. :-0.5757 Min. :0.02186 Min. :-8.666
Class :character 1st Qu.: 1.2268 1st Qu.:0.35271 1st Qu.: 2.060
Mode :character Median :12.5644 Median :0.93538 Median : 6.854
Mean :20.1215 Mean :1.93245 Mean :12.090
3rd Qu.:32.2340 3rd Qu.:2.49098 3rd Qu.:13.225
Max. :85.2943 Max. :8.61516 Max. :78.248
p.value std.lv std.all
Length:23 Min. :-2.4705 Min. :-2.4705
Class :character 1st Qu.: 0.3956 1st Qu.: 0.2185
Mode :character Median : 1.0000 Median : 0.5998
Mean : 4.1398 Mean : 1.0063
3rd Qu.: 3.7145 3rd Qu.: 1.0000
Max. :33.7241 Max. : 5.8513
bi_lavaan_results <- fit_bi_lcsm (data = NLSY_Data,
var_x = c ("math2" , "math3" , "math4" , "math5" , "math6" ,"math7" , "math8" ),
var_y = c ("rec2" , "rec3" , "rec4" , "rec5" , "rec6" , "rec7" , "rec8" ),
model_x = list (alpha_constant = TRUE ,
beta = TRUE ,
phi = TRUE ),
model_y = list (alpha_constant = TRUE ,
beta = TRUE ,
phi = TRUE ),
coupling = list (delta_lag_xy = TRUE ,
xi_lag_yx = TRUE ,
yi_lag_xy = TRUE ))
Warning: lavaan->lav_data_full():
some cases are empty and will be ignored: 741.
Warning: lavaan->lav_data_full():
due to missing values, some pairwise combinations have less than 10%
coverage; use lavInspect(fit, "coverage") to investigate.
Warning: lavaan->lav_mvnorm_missing_h1_estimate_moments():
Maximum number of iterations reached when computing the sample moments
using EM; use the em.h1.iter.max= argument to increase the number of
iterations
summary (bi_lavaan_results)
lavaan 0.6-19 ended normally after 267 iterations
Estimator ML
Optimization method NLMINB
Number of model parameters 68
Number of equality constraints 45
Used Total
Number of observations 932 933
Number of missing patterns 66
Model Test User Model:
Standard Scaled
Test Statistic 173.733 184.781
Degrees of freedom 96 96
P-value (Chi-square) 0.000 0.000
Scaling correction factor 0.940
Yuan-Bentler correction (Mplus variant)
Parameter Estimates:
Standard errors Sandwich
Information bread Observed
Observed information based on Hessian
Latent Variables:
Estimate Std.Err z-value P(>|z|)
lx1 =~
x1 1.000
lx2 =~
x2 1.000
lx3 =~
x3 1.000
lx4 =~
x4 1.000
lx5 =~
x5 1.000
lx6 =~
x6 1.000
lx7 =~
x7 1.000
dx2 =~
lx2 1.000
dx3 =~
lx3 1.000
dx4 =~
lx4 1.000
dx5 =~
lx5 1.000
dx6 =~
lx6 1.000
dx7 =~
lx7 1.000
g2 =~
dx2 1.000
dx3 1.000
dx4 1.000
dx5 1.000
dx6 1.000
dx7 1.000
ly1 =~
y1 1.000
ly2 =~
y2 1.000
ly3 =~
y3 1.000
ly4 =~
y4 1.000
ly5 =~
y5 1.000
ly6 =~
y6 1.000
ly7 =~
y7 1.000
dy2 =~
ly2 1.000
dy3 =~
ly3 1.000
dy4 =~
ly4 1.000
dy5 =~
ly5 1.000
dy6 =~
ly6 1.000
dy7 =~
ly7 1.000
j2 =~
dy2 1.000
dy3 1.000
dy4 1.000
dy5 1.000
dy6 1.000
dy7 1.000
Regressions:
Estimate Std.Err z-value P(>|z|)
lx2 ~
lx1 1.000
lx3 ~
lx2 1.000
lx4 ~
lx3 1.000
lx5 ~
lx4 1.000
lx6 ~
lx5 1.000
lx7 ~
lx6 1.000
dx2 ~
lx1 (bt_x) -0.576 0.100 -5.759 0.000
dx3 ~
lx2 (bt_x) -0.576 0.100 -5.759 0.000
dx4 ~
lx3 (bt_x) -0.576 0.100 -5.759 0.000
dx5 ~
lx4 (bt_x) -0.576 0.100 -5.759 0.000
dx6 ~
lx5 (bt_x) -0.576 0.100 -5.759 0.000
dx7 ~
lx6 (bt_x) -0.576 0.100 -5.759 0.000
dx3 ~
dx2 (ph_x) 0.021 0.070 0.299 0.765
dx4 ~
dx3 (ph_x) 0.021 0.070 0.299 0.765
dx5 ~
dx4 (ph_x) 0.021 0.070 0.299 0.765
dx6 ~
dx5 (ph_x) 0.021 0.070 0.299 0.765
dx7 ~
dx6 (ph_x) 0.021 0.070 0.299 0.765
ly2 ~
ly1 1.000
ly3 ~
ly2 1.000
ly4 ~
ly3 1.000
ly5 ~
ly4 1.000
ly6 ~
ly5 1.000
ly7 ~
ly6 1.000
dy2 ~
ly1 (bt_y) -0.189 0.022 -8.666 0.000
dy3 ~
ly2 (bt_y) -0.189 0.022 -8.666 0.000
dy4 ~
ly3 (bt_y) -0.189 0.022 -8.666 0.000
dy5 ~
ly4 (bt_y) -0.189 0.022 -8.666 0.000
dy6 ~
ly5 (bt_y) -0.189 0.022 -8.666 0.000
dy7 ~
ly6 (bt_y) -0.189 0.022 -8.666 0.000
dy3 ~
dy2 (ph_y) 0.542 0.271 1.996 0.046
dy4 ~
dy3 (ph_y) 0.542 0.271 1.996 0.046
dy5 ~
dy4 (ph_y) 0.542 0.271 1.996 0.046
dy6 ~
dy5 (ph_y) 0.542 0.271 1.996 0.046
dy7 ~
dy6 (ph_y) 0.542 0.271 1.996 0.046
dx2 ~
ly1 (dl__) 0.290 0.090 3.245 0.001
dx3 ~
ly2 (dl__) 0.290 0.090 3.245 0.001
dx4 ~
ly3 (dl__) 0.290 0.090 3.245 0.001
dx5 ~
ly4 (dl__) 0.290 0.090 3.245 0.001
dx6 ~
ly5 (dl__) 0.290 0.090 3.245 0.001
dx7 ~
ly6 (dl__) 0.290 0.090 3.245 0.001
dy3 ~
dx2 (x_l_) -0.569 0.247 -2.302 0.021
dy4 ~
dx3 (x_l_) -0.569 0.247 -2.302 0.021
dy5 ~
dx4 (x_l_) -0.569 0.247 -2.302 0.021
dy6 ~
dx5 (x_l_) -0.569 0.247 -2.302 0.021
dy7 ~
dx6 (x_l_) -0.569 0.247 -2.302 0.021
Covariances:
Estimate Std.Err z-value P(>|z|)
lx1 ~~
g2 (sgm_g2lx1) 18.287 2.668 6.854 0.000
ly1 ~~
j2 (sgm_j2ly1) 18.251 1.793 10.180 0.000
.x1 ~~
.y1 (sgm_) 6.953 1.136 6.121 0.000
.x2 ~~
.y2 (sgm_) 6.953 1.136 6.121 0.000
.x3 ~~
.y3 (sgm_) 6.953 1.136 6.121 0.000
.x4 ~~
.y4 (sgm_) 6.953 1.136 6.121 0.000
.x5 ~~
.y5 (sgm_) 6.953 1.136 6.121 0.000
.x6 ~~
.y6 (sgm_) 6.953 1.136 6.121 0.000
.x7 ~~
.y7 (sgm_) 6.953 1.136 6.121 0.000
lx1 ~~
l1 (s_11) 62.771 5.285 11.876 0.000
g2 ~~
l1 (sgm_g2ly1) 3.069 3.705 0.828 0.407
lx1 ~~
j2 (sgm_j2lx1) 11.895 1.619 7.349 0.000
g2 ~~
j2 (s_22) 1.912 0.900 2.124 0.034
Intercepts:
Estimate Std.Err z-value P(>|z|)
lx1 (gmm_lx1) 32.278 0.471 68.533 0.000
.lx2 0.000
.lx3 0.000
.lx4 0.000
.lx5 0.000
.lx6 0.000
.lx7 0.000
.x1 0.000
.x2 0.000
.x3 0.000
.x4 0.000
.x5 0.000
.x6 0.000
.x7 0.000
.dx2 0.000
.dx3 0.000
.dx4 0.000
.dx5 0.000
.dx6 0.000
.dx7 0.000
g2 (alph_g2) 16.475 0.893 18.452 0.000
ly1 (gmm_ly1) 33.955 0.434 78.248 0.000
.ly2 0.000
.ly3 0.000
.ly4 0.000
.ly5 0.000
.ly6 0.000
.ly7 0.000
.y1 0.000
.y2 0.000
.y3 0.000
.y4 0.000
.y5 0.000
.y6 0.000
.y7 0.000
.dy2 0.000
.dy3 0.000
.dy4 0.000
.dy5 0.000
.dy6 0.000
.dy7 0.000
j2 (alph_j2) 13.968 0.935 14.933 0.000
Variances:
Estimate Std.Err z-value P(>|z|)
lx1 (sgm2_lx1) 73.990 6.774 10.922 0.000
.lx2 0.000
.lx3 0.000
.lx4 0.000
.lx5 0.000
.lx6 0.000
.lx7 0.000
.x1 (sgm2_x) 32.190 1.779 18.097 0.000
.x2 (sgm2_x) 32.190 1.779 18.097 0.000
.x3 (sgm2_x) 32.190 1.779 18.097 0.000
.x4 (sgm2_x) 32.190 1.779 18.097 0.000
.x5 (sgm2_x) 32.190 1.779 18.097 0.000
.x6 (sgm2_x) 32.190 1.779 18.097 0.000
.x7 (sgm2_x) 32.190 1.779 18.097 0.000
.dx2 0.000
.dx3 0.000
.dx4 0.000
.dx5 0.000
.dx6 0.000
.dx7 0.000
g2 (sgm2_g2) 12.564 3.467 3.624 0.000
ly1 (sgm2_ly1) 85.294 8.615 9.900 0.000
.ly2 0.000
.ly3 0.000
.ly4 0.000
.ly5 0.000
.ly6 0.000
.ly7 0.000
.y1 (sgm2_y) 33.724 2.314 14.574 0.000
.y2 (sgm2_y) 33.724 2.314 14.574 0.000
.y3 (sgm2_y) 33.724 2.314 14.574 0.000
.y4 (sgm2_y) 33.724 2.314 14.574 0.000
.y5 (sgm2_y) 33.724 2.314 14.574 0.000
.y6 (sgm2_y) 33.724 2.314 14.574 0.000
.y7 (sgm2_y) 33.724 2.314 14.574 0.000
.dy2 0.000
.dy3 0.000
.dy4 0.000
.dy5 0.000
.dy6 0.000
.dy7 0.000
j2 (sgm2_j2) 5.699 0.858 6.640 0.000
# Save the lavaan syntax that is used to create the layout matrix for semPlot
bi_lavaan_syntax <- fit_bi_lcsm (data = NLSY_Data,
var_x = c ("math2" , "math3" , "math4" , "math5" , "math6" ,"math7" , "math8" ),
var_y = c ("rec2" , "rec3" , "rec4" , "rec5" , "rec6" , "rec7" , "rec8" ),
model_x = list (alpha_constant = TRUE ,
beta = TRUE ,
phi = TRUE ),
model_y = list (alpha_constant = TRUE ,
beta = TRUE ,
phi = TRUE ),
coupling = list (delta_lag_xy = TRUE ,
xi_lag_yx = TRUE ,
yi_lag_xy = TRUE ),
return_lavaan_syntax = TRUE )
bi_lavaan_syntax
[1] "# # # # # # # # # # # # # # # # # # # # #\n# Specify parameters for construct x ----\n# # # # # # # # # # # # # # # # # # # # #\n# Specify latent true scores \nlx1 =~ 1 * x1 \nlx2 =~ 1 * x2 \nlx3 =~ 1 * x3 \nlx4 =~ 1 * x4 \nlx5 =~ 1 * x5 \nlx6 =~ 1 * x6 \nlx7 =~ 1 * x7 \n# Specify mean of latent true scores \nlx1 ~ gamma_lx1 * 1 \nlx2 ~ 0 * 1 \nlx3 ~ 0 * 1 \nlx4 ~ 0 * 1 \nlx5 ~ 0 * 1 \nlx6 ~ 0 * 1 \nlx7 ~ 0 * 1 \n# Specify variance of latent true scores \nlx1 ~~ sigma2_lx1 * lx1 \nlx2 ~~ 0 * lx2 \nlx3 ~~ 0 * lx3 \nlx4 ~~ 0 * lx4 \nlx5 ~~ 0 * lx5 \nlx6 ~~ 0 * lx6 \nlx7 ~~ 0 * lx7 \n# Specify intercept of obseved scores \nx1 ~ 0 * 1 \nx2 ~ 0 * 1 \nx3 ~ 0 * 1 \nx4 ~ 0 * 1 \nx5 ~ 0 * 1 \nx6 ~ 0 * 1 \nx7 ~ 0 * 1 \n# Specify variance of observed scores \nx1 ~~ sigma2_ux * x1 \nx2 ~~ sigma2_ux * x2 \nx3 ~~ sigma2_ux * x3 \nx4 ~~ sigma2_ux * x4 \nx5 ~~ sigma2_ux * x5 \nx6 ~~ sigma2_ux * x6 \nx7 ~~ sigma2_ux * x7 \n# Specify autoregressions of latent variables \nlx2 ~ 1 * lx1 \nlx3 ~ 1 * lx2 \nlx4 ~ 1 * lx3 \nlx5 ~ 1 * lx4 \nlx6 ~ 1 * lx5 \nlx7 ~ 1 * lx6 \n# Specify latent change scores \ndx2 =~ 1 * lx2 \ndx3 =~ 1 * lx3 \ndx4 =~ 1 * lx4 \ndx5 =~ 1 * lx5 \ndx6 =~ 1 * lx6 \ndx7 =~ 1 * lx7 \n# Specify latent change scores means \ndx2 ~ 0 * 1 \ndx3 ~ 0 * 1 \ndx4 ~ 0 * 1 \ndx5 ~ 0 * 1 \ndx6 ~ 0 * 1 \ndx7 ~ 0 * 1 \n# Specify latent change scores variances \ndx2 ~~ 0 * dx2 \ndx3 ~~ 0 * dx3 \ndx4 ~~ 0 * dx4 \ndx5 ~~ 0 * dx5 \ndx6 ~~ 0 * dx6 \ndx7 ~~ 0 * dx7 \n# Specify constant change factor \ng2 =~ 1 * dx2 + 1 * dx3 + 1 * dx4 + 1 * dx5 + 1 * dx6 + 1 * dx7 \n# Specify constant change factor mean \ng2 ~ alpha_g2 * 1 \n# Specify constant change factor variance \ng2 ~~ sigma2_g2 * g2 \n# Specify constant change factor covariance with the initial true score \ng2 ~~ sigma_g2lx1 * lx1\n# Specify proportional change component \ndx2 ~ beta_x * lx1 \ndx3 ~ beta_x * lx2 \ndx4 ~ beta_x * lx3 \ndx5 ~ beta_x * lx4 \ndx6 ~ beta_x * lx5 \ndx7 ~ beta_x * lx6 \n# Specify autoregression of change score \ndx3 ~ phi_x * dx2 \ndx4 ~ phi_x * dx3 \ndx5 ~ phi_x * dx4 \ndx6 ~ phi_x * dx5 \ndx7 ~ phi_x * dx6 \n# # # # # # # # # # # # # # # # # # # # #\n# Specify parameters for construct y ----\n# # # # # # # # # # # # # # # # # # # # #\n# Specify latent true scores \nly1 =~ 1 * y1 \nly2 =~ 1 * y2 \nly3 =~ 1 * y3 \nly4 =~ 1 * y4 \nly5 =~ 1 * y5 \nly6 =~ 1 * y6 \nly7 =~ 1 * y7 \n# Specify mean of latent true scores \nly1 ~ gamma_ly1 * 1 \nly2 ~ 0 * 1 \nly3 ~ 0 * 1 \nly4 ~ 0 * 1 \nly5 ~ 0 * 1 \nly6 ~ 0 * 1 \nly7 ~ 0 * 1 \n# Specify variance of latent true scores \nly1 ~~ sigma2_ly1 * ly1 \nly2 ~~ 0 * ly2 \nly3 ~~ 0 * ly3 \nly4 ~~ 0 * ly4 \nly5 ~~ 0 * ly5 \nly6 ~~ 0 * ly6 \nly7 ~~ 0 * ly7 \n# Specify intercept of obseved scores \ny1 ~ 0 * 1 \ny2 ~ 0 * 1 \ny3 ~ 0 * 1 \ny4 ~ 0 * 1 \ny5 ~ 0 * 1 \ny6 ~ 0 * 1 \ny7 ~ 0 * 1 \n# Specify variance of observed scores \ny1 ~~ sigma2_uy * y1 \ny2 ~~ sigma2_uy * y2 \ny3 ~~ sigma2_uy * y3 \ny4 ~~ sigma2_uy * y4 \ny5 ~~ sigma2_uy * y5 \ny6 ~~ sigma2_uy * y6 \ny7 ~~ sigma2_uy * y7 \n# Specify autoregressions of latent variables \nly2 ~ 1 * ly1 \nly3 ~ 1 * ly2 \nly4 ~ 1 * ly3 \nly5 ~ 1 * ly4 \nly6 ~ 1 * ly5 \nly7 ~ 1 * ly6 \n# Specify latent change scores \ndy2 =~ 1 * ly2 \ndy3 =~ 1 * ly3 \ndy4 =~ 1 * ly4 \ndy5 =~ 1 * ly5 \ndy6 =~ 1 * ly6 \ndy7 =~ 1 * ly7 \n# Specify latent change scores means \ndy2 ~ 0 * 1 \ndy3 ~ 0 * 1 \ndy4 ~ 0 * 1 \ndy5 ~ 0 * 1 \ndy6 ~ 0 * 1 \ndy7 ~ 0 * 1 \n# Specify latent change scores variances \ndy2 ~~ 0 * dy2 \ndy3 ~~ 0 * dy3 \ndy4 ~~ 0 * dy4 \ndy5 ~~ 0 * dy5 \ndy6 ~~ 0 * dy6 \ndy7 ~~ 0 * dy7 \n# Specify constant change factor \nj2 =~ 1 * dy2 + 1 * dy3 + 1 * dy4 + 1 * dy5 + 1 * dy6 + 1 * dy7 \n# Specify constant change factor mean \nj2 ~ alpha_j2 * 1 \n# Specify constant change factor variance \nj2 ~~ sigma2_j2 * j2 \n# Specify constant change factor covariance with the initial true score \nj2 ~~ sigma_j2ly1 * ly1\n# Specify proportional change component \ndy2 ~ beta_y * ly1 \ndy3 ~ beta_y * ly2 \ndy4 ~ beta_y * ly3 \ndy5 ~ beta_y * ly4 \ndy6 ~ beta_y * ly5 \ndy7 ~ beta_y * ly6 \n# Specify autoregression of change score \ndy3 ~ phi_y * dy2 \ndy4 ~ phi_y * dy3 \ndy5 ~ phi_y * dy4 \ndy6 ~ phi_y * dy5 \ndy7 ~ phi_y * dy6 \n# Specify residual covariances \nx1 ~~ sigma_su * y1 \nx2 ~~ sigma_su * y2 \nx3 ~~ sigma_su * y3 \nx4 ~~ sigma_su * y4 \nx5 ~~ sigma_su * y5 \nx6 ~~ sigma_su * y6 \nx7 ~~ sigma_su * y7 \n# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #\n# Specify covariances betweeen specified change components (alpha) and intercepts (initial latent true scores lx1 and ly1) ----\n# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #\n# Specify covariance of intercepts \nlx1 ~~ sigma_ly1lx1 * ly1 \n# Specify covariance of constant change and intercept between constructs \nly1 ~~ sigma_g2ly1 * g2 \n# Specify covariance of constant change and intercept between constructs \nlx1 ~~ sigma_j2lx1 * j2 \n# Specify covariance of constant change factors between constructs \ng2 ~~ sigma_j2g2 * j2 \n# # # # # # # # # # # # # # # # # # # # # # # # # # #\n# Specify between-construct coupling parameters ----\n# # # # # # # # # # # # # # # # # # # # # # # # # # #\n# Change score x (t) is determined by true score y (t-1) \ndx2 ~ delta_lag_xy * ly1 \ndx3 ~ delta_lag_xy * ly2 \ndx4 ~ delta_lag_xy * ly3 \ndx5 ~ delta_lag_xy * ly4 \ndx6 ~ delta_lag_xy * ly5 \ndx7 ~ delta_lag_xy * ly6 \n# Change score y (t) is determined by change score x (t-1) \ndy3 ~ xi_lag_yx * dx2 \ndy4 ~ xi_lag_yx * dx3 \ndy5 ~ xi_lag_yx * dx4 \ndy6 ~ xi_lag_yx * dx5 \ndy7 ~ xi_lag_yx * dx6 \n"
# Plot the results
plot_lcsm (lavaan_object = bi_lavaan_results,
lavaan_syntax = bi_lavaan_syntax,
lcsm_colours = TRUE ,
whatLabels = "est" ,
lcsm = "bivariate" )
VP <- function (lm1, lr1, scale = 1 ) {
# bet1 gmm2
math <- scale* (32.543 + - 0.567 * lm1 + - 0.283 * lr1)
# bet2 gmm1
reading <- scale* (34.386 + - 0.190 * lr1 + - 0.571 * lm1)
math_2 <- lm1 + math
reading_2 <- lr1 + reading
list (math_2 = math_2, reading_2 = reading_2)
}
VP
function(lm1, lr1, scale = 1) {
# bet1 gmm2
math <- scale*(32.543 + -0.567*lm1 + -0.283*lr1)
# bet2 gmm1
reading <- scale*(34.386 + -0.190*lr1 + -0.571*lm1)
math_2 <- lm1 + math
reading_2 <- lr1 + reading
list(math_2 = math_2, reading_2 = reading_2)
}
VP <- function (lm1, lr1, scale = 1 ) {
# bet1 gmm2
math <- scale* (32.543 + - 0.567 * lm1 + - 0.283 * lr1)
# bet2 gmm1
reading <- scale* (34.386 + - 0.190 * lr1 + - 0.571 * lm1)
math_2 <- lm1 + math
reading_2 <- lr1 + reading
list (math_2 = math_2, reading_2 = reading_2)
}
#scales the length of vectors plotted for better readability
scale_factor <- .25
#create a grid we want to use to get expected vectors
#stay within the observed data!
reading_grid <- seq (25 , 45 , length.out = 15 )
math_grid <- seq (25 , 45 , length.out = 10 )
newdata <- data.frame (expand.grid (lr1 = reading_grid, lm1 = math_grid))
#apply the vector function to the grid
t2 <- VP (newdata$ lm1, newdata$ lr1, scale = scale_factor)
#put the expected t2 scores into the data frame
newdata$ math_2 <- t2$ math_2
newdata$ reading_2 <- t2$ reading_2
newdata
lr1 lm1 math_2 reading_2
1 25.00000 25.00000 27.82325 28.84025
2 26.42857 25.00000 27.72218 30.20096
3 27.85714 25.00000 27.62111 31.56168
4 29.28571 25.00000 27.52004 32.92239
5 30.71429 25.00000 27.41896 34.28311
6 32.14286 25.00000 27.31789 35.64382
7 33.57143 25.00000 27.21682 37.00454
8 35.00000 25.00000 27.11575 38.36525
9 36.42857 25.00000 27.01468 39.72596
10 37.85714 25.00000 26.91361 41.08668
11 39.28571 25.00000 26.81254 42.44739
12 40.71429 25.00000 26.71146 43.80811
13 42.14286 25.00000 26.61039 45.16882
14 43.57143 25.00000 26.50932 46.52954
15 45.00000 25.00000 26.40825 47.89025
16 25.00000 27.22222 29.73047 28.52303
17 26.42857 27.22222 29.62940 29.88374
18 27.85714 27.22222 29.52833 31.24446
19 29.28571 27.22222 29.42726 32.60517
20 30.71429 27.22222 29.32619 33.96588
21 32.14286 27.22222 29.22512 35.32660
22 33.57143 27.22222 29.12404 36.68731
23 35.00000 27.22222 29.02297 38.04803
24 36.42857 27.22222 28.92190 39.40874
25 37.85714 27.22222 28.82083 40.76946
26 39.28571 27.22222 28.71976 42.13017
27 40.71429 27.22222 28.61869 43.49088
28 42.14286 27.22222 28.51762 44.85160
29 43.57143 27.22222 28.41654 46.21231
30 45.00000 27.22222 28.31547 47.57303
31 25.00000 29.44444 31.63769 28.20581
32 26.42857 29.44444 31.53662 29.56652
33 27.85714 29.44444 31.43555 30.92723
34 29.28571 29.44444 31.33448 32.28795
35 30.71429 29.44444 31.23341 33.64866
36 32.14286 29.44444 31.13234 35.00938
37 33.57143 29.44444 31.03127 36.37009
38 35.00000 29.44444 30.93019 37.73081
39 36.42857 29.44444 30.82912 39.09152
40 37.85714 29.44444 30.72805 40.45223
41 39.28571 29.44444 30.62698 41.81295
42 40.71429 29.44444 30.52591 43.17366
43 42.14286 29.44444 30.42484 44.53438
44 43.57143 29.44444 30.32377 45.89509
45 45.00000 29.44444 30.22269 47.25581
46 25.00000 31.66667 33.54492 27.88858
47 26.42857 31.66667 33.44385 29.24930
48 27.85714 31.66667 33.34277 30.61001
49 29.28571 31.66667 33.24170 31.97073
50 30.71429 31.66667 33.14063 33.33144
51 32.14286 31.66667 33.03956 34.69215
52 33.57143 31.66667 32.93849 36.05287
53 35.00000 31.66667 32.83742 37.41358
54 36.42857 31.66667 32.73635 38.77430
55 37.85714 31.66667 32.63527 40.13501
56 39.28571 31.66667 32.53420 41.49573
57 40.71429 31.66667 32.43313 42.85644
58 42.14286 31.66667 32.33206 44.21715
59 43.57143 31.66667 32.23099 45.57787
60 45.00000 31.66667 32.12992 46.93858
61 25.00000 33.88889 35.45214 27.57136
62 26.42857 33.88889 35.35107 28.93208
63 27.85714 33.88889 35.25000 30.29279
64 29.28571 33.88889 35.14892 31.65350
65 30.71429 33.88889 35.04785 33.01422
66 32.14286 33.88889 34.94678 34.37493
67 33.57143 33.88889 34.84571 35.73565
68 35.00000 33.88889 34.74464 37.09636
69 36.42857 33.88889 34.64357 38.45708
70 37.85714 33.88889 34.54250 39.81779
71 39.28571 33.88889 34.44142 41.17850
72 40.71429 33.88889 34.34035 42.53922
73 42.14286 33.88889 34.23928 43.89993
74 43.57143 33.88889 34.13821 45.26065
75 45.00000 33.88889 34.03714 46.62136
76 25.00000 36.11111 37.35936 27.25414
77 26.42857 36.11111 37.25829 28.61485
78 27.85714 36.11111 37.15722 29.97557
79 29.28571 36.11111 37.05615 31.33628
80 30.71429 36.11111 36.95508 32.69700
81 32.14286 36.11111 36.85400 34.05771
82 33.57143 36.11111 36.75293 35.41842
83 35.00000 36.11111 36.65186 36.77914
84 36.42857 36.11111 36.55079 38.13985
85 37.85714 36.11111 36.44972 39.50057
86 39.28571 36.11111 36.34865 40.86128
87 40.71429 36.11111 36.24758 42.22200
88 42.14286 36.11111 36.14650 43.58271
89 43.57143 36.11111 36.04543 44.94342
90 45.00000 36.11111 35.94436 46.30414
91 25.00000 38.33333 39.26658 26.93692
92 26.42857 38.33333 39.16551 28.29763
93 27.85714 38.33333 39.06444 29.65835
94 29.28571 38.33333 38.96337 31.01906
95 30.71429 38.33333 38.86230 32.37977
96 32.14286 38.33333 38.76123 33.74049
97 33.57143 38.33333 38.66015 35.10120
98 35.00000 38.33333 38.55908 36.46192
99 36.42857 38.33333 38.45801 37.82263
100 37.85714 38.33333 38.35694 39.18335
101 39.28571 38.33333 38.25587 40.54406
102 40.71429 38.33333 38.15480 41.90477
103 42.14286 38.33333 38.05373 43.26549
104 43.57143 38.33333 37.95265 44.62620
105 45.00000 38.33333 37.85158 45.98692
106 25.00000 40.55556 41.17381 26.61969
107 26.42857 40.55556 41.07273 27.98041
108 27.85714 40.55556 40.97166 29.34112
109 29.28571 40.55556 40.87059 30.70184
110 30.71429 40.55556 40.76952 32.06255
111 32.14286 40.55556 40.66845 33.42327
112 33.57143 40.55556 40.56738 34.78398
113 35.00000 40.55556 40.46631 36.14469
114 36.42857 40.55556 40.36523 37.50541
115 37.85714 40.55556 40.26416 38.86612
116 39.28571 40.55556 40.16309 40.22684
117 40.71429 40.55556 40.06202 41.58755
118 42.14286 40.55556 39.96095 42.94827
119 43.57143 40.55556 39.85988 44.30898
120 45.00000 40.55556 39.75881 45.66969
121 25.00000 42.77778 43.08103 26.30247
122 26.42857 42.77778 42.97996 27.66319
123 27.85714 42.77778 42.87888 29.02390
124 29.28571 42.77778 42.77781 30.38462
125 30.71429 42.77778 42.67674 31.74533
126 32.14286 42.77778 42.57567 33.10604
127 33.57143 42.77778 42.47460 34.46676
128 35.00000 42.77778 42.37353 35.82747
129 36.42857 42.77778 42.27246 37.18819
130 37.85714 42.77778 42.17138 38.54890
131 39.28571 42.77778 42.07031 39.90962
132 40.71429 42.77778 41.96924 41.27033
133 42.14286 42.77778 41.86817 42.63104
134 43.57143 42.77778 41.76710 43.99176
135 45.00000 42.77778 41.66603 45.35247
136 25.00000 45.00000 44.98825 25.98525
137 26.42857 45.00000 44.88718 27.34596
138 27.85714 45.00000 44.78611 28.70668
139 29.28571 45.00000 44.68504 30.06739
140 30.71429 45.00000 44.58396 31.42811
141 32.14286 45.00000 44.48289 32.78882
142 33.57143 45.00000 44.38182 34.14954
143 35.00000 45.00000 44.28075 35.51025
144 36.42857 45.00000 44.17968 36.87096
145 37.85714 45.00000 44.07861 38.23168
146 39.28571 45.00000 43.97754 39.59239
147 40.71429 45.00000 43.87646 40.95311
148 42.14286 45.00000 43.77539 42.31382
149 43.57143 45.00000 43.67432 43.67454
150 45.00000 45.00000 43.57325 45.03525
ggplot (newdata, aes (y = lm1, x = lr1)) +
geom_segment (aes (yend = math_2, xend = reading_2),
arrow = arrow (length = unit (.25 / 4 , "inches" ))) +
theme_minimal ()