library(tidyverse)
full_data_means_clpm <- full_data_means %>%
filter(agency != "XX") %>%
group_by(subag, year) %>%
summarize(
mut = mean(mut, na.rm = TRUE),
voice = mean(voice, na.rm = TRUE)
) %>%
pivot_wider(
names_from = c("year"),
values_from = c("mut", "voice")
)
## `summarise()` has grouped output by 'subag'. You can override using the `.groups` argument.
Build model
## Warning: package 'lavaan' was built under R version 4.3.1
## This is lavaan 0.6-17
## lavaan is FREE software! Please report any bugs.
model <-
'
voice_2011 ~ 1 + mut_2010 + voice_2010
voice_2012 ~ 1 + mut_2011 + voice_2011
voice_2013 ~ 1 + mut_2012 + voice_2012
voice_2014 ~ 1 + mut_2013 + voice_2013
voice_2015 ~ 1 + mut_2014 + voice_2014
voice_2016 ~ 1 + mut_2015 + voice_2015
voice_2017 ~ 1 + mut_2016 + voice_2016
voice_2018 ~ 1 + mut_2017 + voice_2017
voice_2019 ~ 1 + mut_2018 + voice_2018
voice_2010 ~~ mut_2010
voice_2011 ~~ mut_2011
voice_2012 ~~ mut_2012
voice_2013 ~~ mut_2013
voice_2014 ~~ mut_2014
voice_2015 ~~ mut_2015
voice_2016 ~~ mut_2016
voice_2017 ~~ mut_2017
voice_2018 ~~ mut_2018
voice_2019 ~~ mut_2019
'
m1 <- sem(model, data = full_data_means_clpm, missing = "ML")
## Warning in lav_data_full(data = data, group = group, cluster = cluster, : lavaan WARNING: some cases are empty and will be ignored:
## 527
summary(m1, standardized = TRUE)
## lavaan 0.6.17 ended normally after 364 iterations
##
## Estimator ML
## Optimization method NLMINB
## Number of model parameters 68
##
## Used Total
## Number of observations 526 527
## Number of missing patterns 84
##
## Model Test User Model:
##
## Test statistic 2506.204
## Degrees of freedom 162
## 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
## voice_2011 ~
## mut_2010 -0.526 0.044 -11.846 0.000 -0.526 -0.596
## voice_2010 0.769 0.035 21.775 0.000 0.769 0.890
## voice_2012 ~
## mut_2011 -0.570 0.061 -9.301 0.000 -0.570 -0.656
## voice_2011 0.791 0.051 15.391 0.000 0.791 0.812
## voice_2013 ~
## mut_2012 -0.509 0.074 -6.875 0.000 -0.509 -0.524
## voice_2012 0.812 0.060 13.542 0.000 0.812 0.832
## voice_2014 ~
## mut_2013 -0.534 0.086 -6.214 0.000 -0.534 -0.619
## voice_2013 1.023 0.064 16.111 0.000 1.023 1.117
## voice_2015 ~
## mut_2014 -0.697 0.051 -13.741 0.000 -0.697 -0.654
## voice_2014 0.867 0.043 20.275 0.000 0.867 0.655
## voice_2016 ~
## mut_2015 -0.606 0.054 -11.292 0.000 -0.606 -0.638
## voice_2015 0.805 0.041 19.631 0.000 0.805 0.881
## voice_2017 ~
## mut_2016 -0.722 0.073 -9.875 0.000 -0.722 -0.788
## voice_2016 1.066 0.040 26.676 0.000 1.066 1.146
## voice_2018 ~
## mut_2017 -0.851 0.050 -17.025 0.000 -0.851 -0.790
## voice_2017 1.076 0.035 30.668 0.000 1.076 0.876
## voice_2019 ~
## mut_2018 -0.157 0.036 -4.313 0.000 -0.157 -0.175
## voice_2018 0.769 0.046 16.848 0.000 0.769 0.929
##
## Covariances:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## mut_2010 ~~
## voice_2010 0.035 0.003 10.765 0.000 0.035 0.847
## .voice_2011 ~~
## mut_2011 0.028 0.003 10.351 0.000 0.028 0.918
## .voice_2012 ~~
## mut_2012 0.025 0.003 8.185 0.000 0.025 0.956
## .voice_2013 ~~
## mut_2013 0.025 0.003 7.348 0.000 0.025 0.947
## .voice_2014 ~~
## mut_2014 0.019 0.003 5.843 0.000 0.019 0.886
## .voice_2015 ~~
## mut_2015 0.032 0.005 6.636 0.000 0.032 0.972
## .voice_2016 ~~
## mut_2016 0.029 0.003 8.337 0.000 0.029 0.974
## .voice_2017 ~~
## mut_2017 0.024 0.003 7.609 0.000 0.024 0.939
## .voice_2018 ~~
## mut_2018 0.031 0.003 9.801 0.000 0.031 0.962
## .voice_2019 ~~
## mut_2019 0.018 0.003 6.433 0.000 0.018 0.765
##
## Intercepts:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## .voice_2011 2.530 0.114 22.147 0.000 2.530 14.328
## .voice_2012 2.540 0.160 15.840 0.000 2.540 14.763
## .voice_2013 2.225 0.137 16.193 0.000 2.225 13.253
## .voice_2014 1.549 0.192 8.080 0.000 1.549 10.072
## .voice_2015 2.644 0.174 15.181 0.000 2.644 12.987
## .voice_2016 2.651 0.145 18.308 0.000 2.651 14.254
## .voice_2017 2.143 0.192 11.148 0.000 2.143 12.382
## .voice_2018 2.507 0.139 18.080 0.000 2.507 11.800
## .voice_2019 1.373 0.177 7.771 0.000 1.373 7.805
## mut_2010 3.264 0.012 273.421 0.000 3.264 16.319
## voice_2010 3.562 0.012 302.683 0.000 3.562 17.417
## mut_2011 3.248 0.012 275.572 0.000 3.248 16.388
## mut_2012 3.149 0.014 231.067 0.000 3.149 18.225
## mut_2013 3.060 0.015 207.927 0.000 3.060 17.170
## mut_2014 3.071 0.017 179.257 0.000 3.071 16.096
## mut_2015 3.132 0.019 166.460 0.000 3.132 15.994
## mut_2016 3.215 0.013 250.478 0.000 3.215 17.013
## mut_2017 3.287 0.014 234.666 0.000 3.287 16.669
## mut_2018 3.296 0.013 260.834 0.000 3.296 16.791
## mut_2019 3.326 0.015 229.079 0.000 3.326 14.880
##
## Variances:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## .voice_2011 0.023 0.003 9.180 0.000 0.023 0.751
## .voice_2012 0.022 0.003 7.596 0.000 0.022 0.758
## .voice_2013 0.021 0.003 6.710 0.000 0.021 0.759
## .voice_2014 0.012 0.002 4.970 0.000 0.012 0.511
## .voice_2015 0.028 0.005 5.727 0.000 0.028 0.686
## .voice_2016 0.025 0.004 6.635 0.000 0.025 0.721
## .voice_2017 0.017 0.003 5.622 0.000 0.017 0.559
## .voice_2018 0.026 0.003 8.285 0.000 0.026 0.581
## .voice_2019 0.011 0.002 6.103 0.000 0.011 0.346
## mut_2010 0.040 0.003 11.810 0.000 0.040 1.000
## voice_2010 0.042 0.004 11.842 0.000 0.042 1.000
## mut_2011 0.039 0.003 11.937 0.000 0.039 1.000
## mut_2012 0.030 0.003 8.772 0.000 0.030 1.000
## mut_2013 0.032 0.004 8.118 0.000 0.032 1.000
## mut_2014 0.036 0.005 7.262 0.000 0.036 1.000
## mut_2015 0.038 0.005 7.296 0.000 0.038 1.000
## mut_2016 0.036 0.004 10.079 0.000 0.036 1.000
## mut_2017 0.039 0.004 9.519 0.000 0.039 1.000
## mut_2018 0.039 0.004 10.959 0.000 0.039 1.000
## mut_2019 0.050 0.005 10.886 0.000 0.050 1.000