Gina Dissertation Final

setwd("C:/Work Files/Dissertations/Gina Drury")
library(mice)

Attaching package: 'mice'
The following object is masked from 'package:stats':

    filter
The following objects are masked from 'package:base':

    cbind, rbind
library(lavaan)
This is lavaan 0.6-19
lavaan is FREE software! Please report any bugs.
library(tidyverse)
── 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.2     ✔ tibble    3.2.1
✔ lubridate 1.9.4     ✔ tidyr     1.3.1
✔ purrr     1.0.4     
── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
✖ dplyr::filter() masks mice::filter(), stats::filter()
✖ dplyr::lag()    masks stats::lag()
ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
library(knitr) 
library(kableExtra)

Attaching package: 'kableExtra'

The following object is masked from 'package:dplyr':

    group_rows
cleaned_data_final2 <- read.csv("cleaned_data_final2.csv")

cleaned_data_final2.1 <- cleaned_data_final2 %>% mutate(across(where(is.factor), ordered))

cleaned_data_final2.1_oboe_only <--(cleaned_data_final2.1$oboe_group==2)
cat_vars <- names(cleaned_data_final2.1)[sapply(cleaned_data_final2.1, is.factor)]

head(cat_vars)
character(0)
library(forcats)

# Collapse rare levels in all categorical variables
cleaned_data_final2.1[cat_vars] <- lapply(cleaned_data_final2.1[cat_vars], function(x) {
  fct_lump_min(x, min = 5)  # Change threshold based on your data
})
#categorical_vars <- c("final_nnns_class", "diabpprg", "gestdiab", "hyp", 
 #                     "prenatal_collapsed", "hepc", "hiv", "syph", "chlmyd", 
  #                    "any_subuse_y_n", "collapsed_mentheal", "sex")

#cleaned_data_final2.1[categorical_vars] <- lapply(cleaned_data_final2##.1[categorical_vars], as.factor)

Results

Model Block 1: disregard

Model Block 2:

SEM_model <- '

Mat_Health =~ diabpprg + gestdiab + hyp + prenatal_collapsed + hepc + hiv + syph + chlmyd + any_subuse_y_n

MatMen_health =~ collapsed_mentheal + acescore + Dep_Score + Anx_Score + Anger_Score + Supp_Score + Meaning_Score

Infant =~ imhbirthwt + imh_birthlt + imh_birthhcr + gawks + sex

SocioDem =~ MatAge + mmins_combined + mrace_combined + pcedlevel + MomOnlyFSIQ + any_subuse_y_n + hseincom

hepc    ~~  any_subuse_y_n
hepc ~~ mrace_combined
any_subuse_y_n ~~ mrace_combined

Mat_Health~~MatMen_health


Mat_Health ~ a*SocioDem
MatMen_health ~ b*SocioDem

Infant ~ c*Mat_Health + d*MatMen_health + e*SocioDem

final_nnns_class ~ f*Infant  

'


SEM_model_fit <- sem(SEM_model, estimator= "WLSMV", data=cleaned_data_final2.1, std.lv=TRUE, missing = "pairwise", mimic = "Mplus")
Warning: lavaan->lav_options_est_dwls():  
   estimator "DWLS" is not recommended for continuous data. Did you forget to 
   set the ordered= argument?
Warning: lavaan->lav_data_full():  
   some observed variances are (at least) a factor 1000 times larger than 
   others; use varTable(fit) to investigate
Warning: lavaan->lav_samplestats_from_data():  
   number of observations (291) too small to compute Gamma
Warning: lavaan->lav_model_vcov():  
   The variance-covariance matrix of the estimated parameters (vcov) does not 
   appear to be positive definite! The smallest eigenvalue (= -6.635754e-06) 
   is smaller than zero. This may be a symptom that the model is not 
   identified.
summary(SEM_model_fit, fit.measures = TRUE, standardized=TRUE)
lavaan 0.6-19 ended normally after 228 iterations

  Estimator                                       DWLS
  Optimization method                           NLMINB
  Number of model parameters                        94

  Number of observations                           291
  Number of missing patterns                        27

Model Test User Model:
                                              Standard      Scaled
  Test Statistic                               486.753     452.007
  Degrees of freedom                               340         340
  P-value (Chi-square)                           0.000       0.000
  Scaling correction factor                                  1.881
  Shift parameter                                          193.170
    simple second-order correction (WLSMV)                        

Model Test Baseline Model:

  Test statistic                              2225.862    1129.246
  Degrees of freedom                               378         378
  P-value                                        0.000       0.000
  Scaling correction factor                                  2.460

User Model versus Baseline Model:

  Comparative Fit Index (CFI)                    0.921       0.851
  Tucker-Lewis Index (TLI)                       0.912       0.834
                                                                  
  Robust Comparative Fit Index (CFI)                         0.886
  Robust Tucker-Lewis Index (TLI)                            0.873

Root Mean Square Error of Approximation:

  RMSEA                                          0.039       0.034
  90 Percent confidence interval - lower         0.031       0.025
  90 Percent confidence interval - upper         0.046       0.042
  P-value H_0: RMSEA <= 0.050                    0.995       1.000
  P-value H_0: RMSEA >= 0.080                    0.000       0.000
                                                                  
  Robust RMSEA                                               0.046
  90 Percent confidence interval - lower                     0.034
  90 Percent confidence interval - upper                     0.057
  P-value H_0: Robust RMSEA <= 0.050                         0.703
  P-value H_0: Robust RMSEA >= 0.080                         0.000

Standardized Root Mean Square Residual:

  SRMR                                           0.060       0.060

Parameter Estimates:

  Standard errors                           Robust.sem
  Information                                 Expected
  Information saturated (h1) model        Unstructured

Latent Variables:
                   Estimate   Std.Err  z-value  P(>|z|)   Std.lv   Std.all
  Mat_Health =~                                                           
    diabpprg          -0.003    0.003   -0.873    0.383    -0.003   -0.027
    gestdiab          -0.003    0.011   -0.293    0.770    -0.003   -0.015
    hyp               -0.078    0.034   -2.318    0.020    -0.081   -0.193
    prenatl_cllpsd    -0.060    0.029   -2.081    0.037    -0.062   -0.167
    hepc               0.066    0.063    1.039    0.299     0.068    0.073
    hiv                0.020    0.016    1.258    0.208     0.021    0.098
    syph              -0.018    0.015   -1.202    0.229    -0.019   -0.082
    chlmyd            -0.048    0.032   -1.483    0.138    -0.050   -0.124
    any_subuse_y_n    -0.067    0.032   -2.096    0.036    -0.070   -0.155
  MatMen_health =~                                                        
    collapsd_mnthl     0.305    0.051    5.941    0.000     0.309    0.329
    acescore          -0.930    0.150   -6.183    0.000    -0.942   -0.340
    Dep_Score         -7.969    0.426  -18.701    0.000    -8.069   -0.901
    Anx_Score         -8.515    0.454  -18.768    0.000    -8.622   -0.808
    Anger_Score       -6.770    0.564  -12.015    0.000    -6.855   -0.702
    Supp_Score         5.281    0.476   11.090    0.000     5.347    0.647
    Meaning_Score      5.316    0.530   10.021    0.000     5.382    0.590
  Infant =~                                                               
    imhbirthwt         0.333    1.355    0.246    0.806     0.431    0.950
    imh_birthlt        1.330    5.404    0.246    0.806     1.718    0.727
    imh_birthhcr       0.763    3.103    0.246    0.806     0.985    0.692
    gawks              0.280    1.138    0.246    0.805     0.362    0.361
    sex                0.067    0.270    0.247    0.805     0.086    0.173
  SocioDem =~                                                             
    MatAge             1.009    0.370    2.726    0.006     1.009    0.198
    mmins_combined    -0.159    0.038   -4.143    0.000    -0.159   -0.323
    mrace_combined     0.354    0.079    4.506    0.000     0.354    0.303
    pcedlevel          0.890    0.116    7.690    0.000     0.890    0.575
    MomOnlyFSIQ        8.743    1.124    7.775    0.000     8.743    0.626
    any_subuse_y_n    -0.174    0.038   -4.555    0.000    -0.174   -0.382
    hseincom          -6.537    4.955   -1.319    0.187    -6.537   -0.056

Regressions:
                     Estimate   Std.Err  z-value  P(>|z|)   Std.lv   Std.all
  Mat_Health ~                                                              
    SocioDem   (a)      -0.291    0.227   -1.281    0.200    -0.280   -0.280
  MatMen_health ~                                                           
    SocioDem   (b)       0.159    0.074    2.150    0.032     0.157    0.157
  Infant ~                                                                  
    Mat_Health (c)       3.421   81.232    0.042    0.966     2.758    2.758
    MatMn_hlth (d)      -3.245   80.498   -0.040    0.968    -2.543   -2.543
    SocioDem   (e)       2.016   38.811    0.052    0.959     1.560    1.560
  final_nnns_class ~                                                        
    Infant     (f)      -0.004    0.050   -0.089    0.929    -0.006   -0.006

Covariances:
                    Estimate   Std.Err  z-value  P(>|z|)   Std.lv   Std.all
 .hepc ~~                                                                  
   .any_subuse_y_n      0.141    0.021    6.800    0.000     0.141    0.358
   .mrace_combined      0.386    0.050    7.738    0.000     0.386    0.370
 .any_subuse_y_n ~~                                                        
   .mrace_combined      0.170    0.033    5.088    0.000     0.170    0.362
 .Mat_Health ~~                                                            
   .MatMen_health       0.983    0.338    2.909    0.004     0.983    0.983

Intercepts:
                   Estimate   Std.Err  z-value  P(>|z|)   Std.lv   Std.all
   .diabpprg           1.011    0.006  170.092    0.000     1.011    9.884
   .gestdiab           1.057    0.013   78.931    0.000     1.057    4.546
   .hyp                1.230    0.024   50.396    0.000     1.230    2.918
   .prenatl_cllpsd     1.165    0.021   54.550    0.000     1.165    3.131
   .hepc               1.732    0.055   31.448    0.000     1.732    1.847
   .hiv                1.024    0.012   82.905    0.000     1.024    4.868
   .syph               1.034    0.014   75.810    0.000     1.034    4.452
   .chlmyd             1.100    0.023   46.963    0.000     1.100    2.758
   .any_subuse_y_n     1.711    0.027   64.203    0.000     1.711    3.770
   .collapsd_mnthl     2.014    0.055   36.503    0.000     2.014    2.144
   .acescore           2.758    0.160   17.267    0.000     2.758    0.996
   .Dep_Score         47.667    0.491   97.043    0.000    47.667    5.323
   .Anx_Score         52.164    0.586   88.958    0.000    52.164    4.889
   .Anger_Score       51.645    0.536   96.264    0.000    51.645    5.290
   .Supp_Score        56.181    0.455  123.360    0.000    56.181    6.793
   .Meaning_Score     59.531    0.501  118.714    0.000    59.531    6.524
   .imhbirthwt         3.261    0.027  122.529    0.000     3.261    7.195
   .imh_birthlt       50.265    0.138  363.413    0.000    50.265   21.267
   .imh_birthhcr      34.200    0.083  410.346    0.000    34.200   24.013
   .gawks             38.729    0.059  657.764    0.000    38.729   38.625
   .sex                1.564    0.029   53.597    0.000     1.564    3.147
   .MatAge            29.753    0.299   99.470    0.000    29.753    5.841
   .mmins_combined     3.835    0.029  132.851    0.000     3.835    7.801
   .mrace_combined     3.423    0.069   49.815    0.000     3.423    2.925
   .pcedlevel          4.054    0.089   45.476    0.000     4.054    2.619
   .MomOnlyFSIQ       94.385    0.778  121.311    0.000    94.385    6.758
   .hseincom          20.643    6.465    3.193    0.001    20.643    0.177
   .finl_nnns_clss     2.137    0.060   35.522    0.000     2.137    2.086

Variances:
                   Estimate   Std.Err  z-value  P(>|z|)   Std.lv   Std.all
   .diabpprg           0.010    0.006    1.798    0.072     0.010    0.999
   .gestdiab           0.054    0.012    4.558    0.000     0.054    1.000
   .hyp                0.171    0.013   12.743    0.000     0.171    0.963
   .prenatl_cllpsd     0.135    0.014    9.563    0.000     0.135    0.972
   .hepc               0.875    0.032   27.296    0.000     0.875    0.995
   .hiv                0.044    0.023    1.914    0.056     0.044    0.990
   .syph               0.054    0.024    2.261    0.024     0.054    0.993
   .chlmyd             0.157    0.039    4.048    0.000     0.157    0.984
   .any_subuse_y_n     0.178    0.015   12.123    0.000     0.178    0.863
   .collapsd_mnthl     0.787    0.035   22.590    0.000     0.787    0.892
   .acescore           6.775    0.547   12.391    0.000     6.775    0.884
   .Dep_Score         15.091    2.881    5.238    0.000    15.091    0.188
   .Anx_Score         39.517    4.593    8.603    0.000    39.517    0.347
   .Anger_Score       48.306    6.230    7.754    0.000    48.306    0.507
   .Supp_Score        39.809    4.344    9.164    0.000    39.809    0.582
   .Meaning_Score     54.289    5.385   10.081    0.000    54.289    0.652
   .imhbirthwt         0.020    0.013    1.503    0.133     0.020    0.097
   .imh_birthlt        2.634    0.418    6.305    0.000     2.634    0.472
   .imh_birthhcr       1.057    0.127    8.333    0.000     1.057    0.521
   .gawks              0.874    0.075   11.666    0.000     0.874    0.869
   .sex                0.239    0.006   38.462    0.000     0.239    0.970
   .MatAge            24.928    1.950   12.782    0.000    24.928    0.961
   .mmins_combined     0.216    0.059    3.697    0.000     0.216    0.896
   .mrace_combined     1.244    0.115   10.810    0.000     1.244    0.908
   .pcedlevel          1.603    0.190    8.424    0.000     1.603    0.669
   .MomOnlyFSIQ      118.626   17.094    6.939    0.000   118.626    0.608
   .hseincom       13633.693 4744.947    2.873    0.004 13633.693    0.997
   .finl_nnns_clss     1.050    0.060   17.393    0.000     1.050    1.000
   .Mat_Health         1.000                                0.922    0.922
   .MatMen_health      1.000                                0.975    0.975
   .Infant             1.000                                0.599    0.599
    SocioDem           1.000                                1.000    1.000

The model in Block 2 also yields an adequate fit to the data. [\(\chi^2(340) = 486.75, p<.001\); CFI = .92, TLI = .91; RMSEA = 0.039; SRMR = 0.06].

parameterEstimates(SEM_model_fit, standardized=TRUE) %>%
  filter(op == "=~") %>%
  select('Latent Factor'=lhs, Indicator=rhs, B=est, SE=se, Z=z, 'p-value'=pvalue, Beta=std.all,CI_Lower=ci.lower, CI_Upper=ci.upper) %>%
  knitr::kable(digits = 3, format="html", booktabs=TRUE, caption="Total Sample Factor Loadings")%>%
  kable_classic(full_width = F, html_font = "Cambria")
Total Sample Factor Loadings
Latent Factor Indicator B SE Z p-value Beta CI_Lower CI_Upper
Mat_Health diabpprg -0.003 0.003 -0.873 0.383 -0.027 -0.009 0.003
Mat_Health gestdiab -0.003 0.011 -0.293 0.770 -0.015 -0.025 0.019
Mat_Health hyp -0.078 0.034 -2.318 0.020 -0.193 -0.144 -0.012
Mat_Health prenatal_collapsed -0.060 0.029 -2.081 0.037 -0.167 -0.116 -0.003
Mat_Health hepc 0.066 0.063 1.039 0.299 0.073 -0.058 0.189
Mat_Health hiv 0.020 0.016 1.258 0.208 0.098 -0.011 0.050
Mat_Health syph -0.018 0.015 -1.202 0.229 -0.082 -0.048 0.012
Mat_Health chlmyd -0.048 0.032 -1.483 0.138 -0.124 -0.111 0.015
Mat_Health any_subuse_y_n -0.067 0.032 -2.096 0.036 -0.155 -0.130 -0.004
MatMen_health collapsed_mentheal 0.305 0.051 5.941 0.000 0.329 0.204 0.406
MatMen_health acescore -0.930 0.150 -6.183 0.000 -0.340 -1.225 -0.636
MatMen_health Dep_Score -7.969 0.426 -18.701 0.000 -0.901 -8.805 -7.134
MatMen_health Anx_Score -8.515 0.454 -18.768 0.000 -0.808 -9.404 -7.626
MatMen_health Anger_Score -6.770 0.564 -12.015 0.000 -0.702 -7.875 -5.666
MatMen_health Supp_Score 5.281 0.476 11.090 0.000 0.647 4.348 6.215
MatMen_health Meaning_Score 5.316 0.530 10.021 0.000 0.590 4.276 6.356
Infant imhbirthwt 0.333 1.355 0.246 0.806 0.950 -2.322 2.989
Infant imh_birthlt 1.330 5.404 0.246 0.806 0.727 -9.262 11.922
Infant imh_birthhcr 0.763 3.103 0.246 0.806 0.692 -5.319 6.845
Infant gawks 0.280 1.138 0.246 0.805 0.361 -1.951 2.512
Infant sex 0.067 0.270 0.247 0.805 0.173 -0.463 0.596
SocioDem MatAge 1.009 0.370 2.726 0.006 0.198 0.283 1.734
SocioDem mmins_combined -0.159 0.038 -4.143 0.000 -0.323 -0.234 -0.084
SocioDem mrace_combined 0.354 0.079 4.506 0.000 0.303 0.200 0.508
SocioDem pcedlevel 0.890 0.116 7.690 0.000 0.575 0.663 1.117
SocioDem MomOnlyFSIQ 8.743 1.124 7.775 0.000 0.626 6.539 10.946
SocioDem any_subuse_y_n -0.174 0.038 -4.555 0.000 -0.382 -0.248 -0.099
SocioDem hseincom -6.537 4.955 -1.319 0.187 -0.056 -16.249 3.175
##Regression Table
parameterEstimates(SEM_model_fit, standardized=TRUE) %>%
  filter(op == "~") %>%
  select('LV1'=lhs, 'LV2'=rhs, B=est, SE=se, Z=z, 'p-value'=pvalue, Beta=std.all,CI_Lower=ci.lower, CI_Upper=ci.upper) %>%
  knitr::kable(digits = 3, format="html", booktabs=TRUE, caption="Total Sample Regressions")%>%
  kable_classic(full_width = F, html_font = "Cambria")
Total Sample Regressions
LV1 LV2 B SE Z p-value Beta CI_Lower CI_Upper
Mat_Health SocioDem -0.291 0.227 -1.281 0.200 -0.280 -0.737 0.154
MatMen_health SocioDem 0.159 0.074 2.150 0.032 0.157 0.014 0.303
Infant Mat_Health 3.421 81.232 0.042 0.966 2.758 -155.792 162.633
Infant MatMen_health -3.245 80.498 -0.040 0.968 -2.543 -161.018 154.529
Infant SocioDem 2.016 38.811 0.052 0.959 1.560 -74.053 78.084
final_nnns_class Infant -0.004 0.050 -0.089 0.929 -0.006 -0.103 0.094

Model Block 3

SEM_model_2 <- '

Mat_Health =~ diabpprg + gestdiab + hyp + prenatal_collapsed + hepc + hiv + syph + chlmyd + any_subuse_y_n

MatMen_health =~ collapsed_mentheal + acescore + Dep_Score + Anx_Score + Anger_Score + Supp_Score + Meaning_Score

Infant =~ imhbirthwt + imh_birthlt + imh_birthhcr + gawks + sex

SocioDem =~ MatAge + mmins_combined + mrace_combined + pcedlevel + MomOnlyFSIQ + any_subuse_y_n + hseincom

hepc    ~~  any_subuse_y_n
hepc ~~ mrace_combined
any_subuse_y_n ~~ mrace_combined

Mat_Health~~MatMen_health


Mat_Health ~ a*SocioDem
MatMen_health ~ b*SocioDem

Infant ~ c*Mat_Health + d*MatMen_health + e*SocioDem

n2attention ~ f*Infant  
n2regulation ~ g*Infant 
n2arousal ~ h*Infant  
n2tone ~ i*Infant  
n2nonoptref ~ j*Infant  
n2qmove ~ k*Infant  
n2stress ~ l*Infant  

'


SEM_model_fit_2 <- sem(SEM_model_2, estimator= "WLSMV", data=cleaned_data_final2.1, std.lv=TRUE,missing = "pairwise", mimic = "Mplus")
Warning: lavaan->lav_options_est_dwls():  
   estimator "DWLS" is not recommended for continuous data. Did you forget to 
   set the ordered= argument?
Warning: lavaan->lav_data_full():  
   some observed variances are (at least) a factor 1000 times larger than 
   others; use varTable(fit) to investigate
Warning: lavaan->lav_samplestats_from_data():  
   number of observations (291) too small to compute Gamma
Warning: lavaan->lav_model_vcov():  
   The variance-covariance matrix of the estimated parameters (vcov) does not 
   appear to be positive definite! The smallest eigenvalue (= -1.095361e-05) 
   is smaller than zero. This may be a symptom that the model is not 
   identified.
summary(SEM_model_fit_2, fit.measures = TRUE, standardized=TRUE)
lavaan 0.6-19 ended normally after 166 iterations

  Estimator                                       DWLS
  Optimization method                           NLMINB
  Number of model parameters                       133

  Number of observations                           291
  Number of missing patterns                        37

Model Test User Model:
                                              Standard      Scaled
  Test Statistic                               819.855     680.221
  Degrees of freedom                               496         496
  P-value (Chi-square)                           0.000       0.000
  Scaling correction factor                                  2.169
  Shift parameter                                          302.265
    simple second-order correction (WLSMV)                        

Model Test Baseline Model:

  Test statistic                              2837.560    1408.357
  Degrees of freedom                               561         561
  P-value                                        0.000       0.000
  Scaling correction factor                                  2.687

User Model versus Baseline Model:

  Comparative Fit Index (CFI)                    0.858       0.783
  Tucker-Lewis Index (TLI)                       0.839       0.754
                                                                  
  Robust Comparative Fit Index (CFI)                         0.824
  Robust Tucker-Lewis Index (TLI)                            0.801

Root Mean Square Error of Approximation:

  RMSEA                                          0.047       0.036
  90 Percent confidence interval - lower         0.042       0.029
  90 Percent confidence interval - upper         0.053       0.042
  P-value H_0: RMSEA <= 0.050                    0.763       1.000
  P-value H_0: RMSEA >= 0.080                    0.000       0.000
                                                                  
  Robust RMSEA                                               0.053
  90 Percent confidence interval - lower                     0.043
  90 Percent confidence interval - upper                     0.062
  P-value H_0: Robust RMSEA <= 0.050                         0.320
  P-value H_0: Robust RMSEA >= 0.080                         0.000

Standardized Root Mean Square Residual:

  SRMR                                           0.065       0.065

Parameter Estimates:

  Standard errors                           Robust.sem
  Information                                 Expected
  Information saturated (h1) model        Unstructured

Latent Variables:
                   Estimate   Std.Err  z-value  P(>|z|)   Std.lv   Std.all
  Mat_Health =~                                                           
    diabpprg          -0.003    0.003   -0.881    0.378    -0.003   -0.028
    gestdiab          -0.003    0.011   -0.281    0.778    -0.003   -0.014
    hyp               -0.079    0.034   -2.344    0.019    -0.083   -0.196
    prenatl_cllpsd    -0.060    0.029   -2.094    0.036    -0.063   -0.169
    hepc               0.067    0.064    1.046    0.296     0.070    0.074
    hiv                0.020    0.016    1.267    0.205     0.021    0.099
    syph              -0.018    0.015   -1.190    0.234    -0.019   -0.082
    chlmyd            -0.048    0.032   -1.475    0.140    -0.050   -0.124
    any_subuse_y_n    -0.067    0.032   -2.088    0.037    -0.070   -0.155
  MatMen_health =~                                                        
    collapsd_mnthl     0.306    0.052    5.927    0.000     0.310    0.329
    acescore          -0.925    0.151   -6.112    0.000    -0.937   -0.339
    Dep_Score         -7.966    0.427  -18.676    0.000    -8.068   -0.901
    Anx_Score         -8.479    0.460  -18.446    0.000    -8.587   -0.805
    Anger_Score       -6.787    0.563  -12.052    0.000    -6.874   -0.704
    Supp_Score         5.325    0.477   11.157    0.000     5.393    0.652
    Meaning_Score      5.294    0.535    9.889    0.000     5.362    0.588
  Infant =~                                                               
    imhbirthwt         0.349    0.333    1.046    0.296     0.416    0.917
    imh_birthlt        1.437    1.379    1.042    0.298     1.713    0.725
    imh_birthhcr       0.796    0.768    1.036    0.300     0.949    0.667
    gawks              0.283    0.273    1.038    0.299     0.338    0.337
    sex                0.071    0.071    0.995    0.320     0.084    0.169
  SocioDem =~                                                             
    MatAge             0.940    0.375    2.509    0.012     0.940    0.185
    mmins_combined    -0.154    0.038   -4.031    0.000    -0.154   -0.314
    mrace_combined     0.381    0.080    4.742    0.000     0.381    0.326
    pcedlevel          0.851    0.115    7.408    0.000     0.851    0.550
    MomOnlyFSIQ        8.774    1.122    7.818    0.000     8.774    0.628
    any_subuse_y_n    -0.180    0.039   -4.653    0.000    -0.180   -0.397
    hseincom          -6.867    5.085   -1.350    0.177    -6.867   -0.059

Regressions:
                   Estimate   Std.Err  z-value  P(>|z|)   Std.lv   Std.all
  Mat_Health ~                                                            
    SocioDem   (a)    -0.297    0.228   -1.306    0.192    -0.285   -0.285
  MatMen_health ~                                                         
    SocioDem   (b)     0.160    0.075    2.144    0.032     0.158    0.158
  Infant ~                                                                
    Mat_Health (c)     1.642   21.383    0.077    0.939     1.436    1.436
    MatMn_hlth (d)    -1.444   21.170   -0.068    0.946    -1.226   -1.226
    SocioDem   (e)     1.219   10.375    0.117    0.906     1.022    1.022
  n2attention ~                                                           
    Infant     (f)    -0.006    0.066   -0.088    0.930    -0.007   -0.005
  n2regulation ~                                                          
    Infant     (g)     0.005    0.057    0.094    0.925     0.006    0.006
  n2arousal ~                                                             
    Infant     (h)     0.082    0.128    0.642    0.521     0.098    0.062
  n2tone ~                                                                
    Infant     (i)    -0.055    0.062   -0.886    0.376    -0.065   -0.118
  n2nonoptref ~                                                           
    Infant     (j)    -0.208    0.200   -1.040    0.298    -0.248   -0.220
  n2qmove ~                                                               
    Infant     (k)     0.106    0.121    0.880    0.379     0.127    0.106
  n2stress ~                                                              
    Infant     (l)    -0.042    0.051   -0.826    0.409    -0.050   -0.071

Covariances:
                    Estimate   Std.Err  z-value  P(>|z|)   Std.lv   Std.all
 .hepc ~~                                                                  
   .any_subuse_y_n      0.141    0.021    6.787    0.000     0.141    0.359
   .mrace_combined      0.387    0.050    7.721    0.000     0.387    0.374
 .any_subuse_y_n ~~                                                        
   .mrace_combined      0.177    0.033    5.313    0.000     0.177    0.381
 .Mat_Health ~~                                                            
   .MatMen_health       0.972    0.330    2.946    0.003     0.972    0.972
 .n2attention ~~                                                           
   .n2regulation        0.297    0.084    3.523    0.000     0.297    0.215
   .n2arousal          -0.519    0.110   -4.738    0.000    -0.519   -0.255
   .n2tone              0.010    0.040    0.246    0.806     0.010    0.014
   .n2nonoptref         0.123    0.077    1.612    0.107     0.123    0.088
   .n2qmove             0.186    0.077    2.407    0.016     0.186    0.122
   .n2stress            0.058    0.044    1.306    0.192     0.058    0.064
 .n2regulation ~~                                                          
   .n2arousal          -0.479    0.095   -5.037    0.000    -0.479   -0.279
   .n2tone             -0.019    0.034   -0.554    0.579    -0.019   -0.032
   .n2nonoptref        -0.038    0.080   -0.477    0.633    -0.038   -0.032
   .n2qmove             0.136    0.075    1.806    0.071     0.136    0.106
   .n2stress           -0.077    0.047   -1.653    0.098    -0.077   -0.102
 .n2arousal ~~                                                             
   .n2tone              0.322    0.063    5.117    0.000     0.322    0.369
   .n2nonoptref         0.030    0.105    0.287    0.774     0.030    0.017
   .n2qmove            -0.378    0.131   -2.878    0.004    -0.378   -0.200
   .n2stress            0.429    0.074    5.786    0.000     0.429    0.386
 .n2tone ~~                                                                
   .n2nonoptref        -0.044    0.048   -0.899    0.369    -0.044   -0.072
   .n2qmove            -0.088    0.055   -1.584    0.113    -0.088   -0.134
   .n2stress            0.155    0.037    4.232    0.000     0.155    0.403
 .n2nonoptref ~~                                                           
   .n2qmove            -0.281    0.085   -3.330    0.001    -0.281   -0.215
   .n2stress            0.178    0.048    3.755    0.000     0.178    0.232
 .n2qmove ~~                                                               
   .n2stress           -0.383    0.062   -6.133    0.000    -0.383   -0.462

Intercepts:
                   Estimate   Std.Err  z-value  P(>|z|)   Std.lv   Std.all
   .diabpprg           1.011    0.006  170.092    0.000     1.011    9.884
   .gestdiab           1.057    0.013   78.931    0.000     1.057    4.546
   .hyp                1.230    0.024   50.396    0.000     1.230    2.918
   .prenatl_cllpsd     1.165    0.021   54.550    0.000     1.165    3.131
   .hepc               1.732    0.055   31.448    0.000     1.732    1.847
   .hiv                1.024    0.012   82.905    0.000     1.024    4.868
   .syph               1.034    0.014   75.810    0.000     1.034    4.452
   .chlmyd             1.100    0.023   46.963    0.000     1.100    2.758
   .any_subuse_y_n     1.711    0.027   64.203    0.000     1.711    3.770
   .collapsd_mnthl     2.014    0.055   36.503    0.000     2.014    2.144
   .acescore           2.758    0.160   17.267    0.000     2.758    0.996
   .Dep_Score         47.667    0.491   97.043    0.000    47.667    5.323
   .Anx_Score         52.164    0.586   88.958    0.000    52.164    4.889
   .Anger_Score       51.645    0.536   96.264    0.000    51.645    5.290
   .Supp_Score        56.181    0.455  123.360    0.000    56.181    6.793
   .Meaning_Score     59.531    0.501  118.714    0.000    59.531    6.524
   .imhbirthwt         3.261    0.027  122.529    0.000     3.261    7.195
   .imh_birthlt       50.265    0.138  363.413    0.000    50.265   21.267
   .imh_birthhcr      34.200    0.083  410.346    0.000    34.200   24.013
   .gawks             38.729    0.059  657.764    0.000    38.729   38.625
   .sex                1.564    0.029   53.597    0.000     1.564    3.147
   .MatAge            29.753    0.299   99.470    0.000    29.753    5.841
   .mmins_combined     3.835    0.029  132.851    0.000     3.835    7.801
   .mrace_combined     3.423    0.069   49.815    0.000     3.423    2.925
   .pcedlevel          4.054    0.089   45.476    0.000     4.054    2.619
   .MomOnlyFSIQ       94.385    0.778  121.311    0.000    94.385    6.758
   .hseincom          20.643    6.465    3.193    0.001    20.643    0.177
   .n2attention        4.627    0.071   65.274    0.000     4.627    3.622
   .n2regulation       4.201    0.063   66.678    0.000     4.201    3.895
   .n2arousal          4.640    0.093   49.658    0.000     4.640    2.911
   .n2tone             4.940    0.033  152.002    0.000     4.940    8.926
   .n2nonoptref        3.122    0.066   47.107    0.000     3.122    2.761
   .n2qmove            6.697    0.070   95.993    0.000     6.697    5.608
   .n2stress           1.637    0.041   39.871    0.000     1.637    2.337

Variances:
                   Estimate   Std.Err  z-value  P(>|z|)   Std.lv   Std.all
   .diabpprg           0.010    0.006    1.798    0.072     0.010    0.999
   .gestdiab           0.054    0.012    4.558    0.000     0.054    1.000
   .hyp                0.171    0.013   12.706    0.000     0.171    0.961
   .prenatl_cllpsd     0.135    0.014    9.557    0.000     0.135    0.971
   .hepc               0.875    0.032   27.228    0.000     0.875    0.994
   .hiv                0.044    0.023    1.915    0.056     0.044    0.990
   .syph               0.054    0.024    2.261    0.024     0.054    0.993
   .chlmyd             0.157    0.039    4.048    0.000     0.157    0.985
   .any_subuse_y_n     0.176    0.015   11.711    0.000     0.176    0.854
   .collapsd_mnthl     0.787    0.035   22.477    0.000     0.787    0.891
   .acescore           6.785    0.548   12.383    0.000     6.785    0.885
   .Dep_Score         15.114    2.949    5.125    0.000    15.114    0.188
   .Anx_Score         40.115    4.706    8.524    0.000    40.115    0.352
   .Anger_Score       48.053    6.229    7.715    0.000    48.053    0.504
   .Supp_Score        39.320    4.347    9.046    0.000    39.320    0.575
   .Meaning_Score     54.511    5.443   10.015    0.000    54.511    0.655
   .imhbirthwt         0.033    0.014    2.419    0.016     0.033    0.159
   .imh_birthlt        2.653    0.430    6.170    0.000     2.653    0.475
   .imh_birthhcr       1.127    0.133    8.456    0.000     1.127    0.556
   .gawks              0.891    0.077   11.639    0.000     0.891    0.886
   .sex                0.240    0.006   38.349    0.000     0.240    0.971
   .MatAge            25.062    1.955   12.818    0.000    25.062    0.966
   .mmins_combined     0.218    0.058    3.732    0.000     0.218    0.901
   .mrace_combined     1.224    0.114   10.693    0.000     1.224    0.894
   .pcedlevel          1.670    0.182    9.162    0.000     1.670    0.697
   .MomOnlyFSIQ      118.081   16.911    6.983    0.000   118.081    0.605
   .hseincom       13629.398 4742.471    2.874    0.004 13629.398    0.997
   .n2attention        1.632    0.133   12.292    0.000     1.632    1.000
   .n2regulation       1.163    0.098   11.873    0.000     1.163    1.000
   .n2arousal          2.531    0.165   15.333    0.000     2.531    0.996
   .n2tone             0.302    0.042    7.139    0.000     0.302    0.986
   .n2nonoptref        1.217    0.128    9.494    0.000     1.217    0.952
   .n2qmove            1.410    0.127   11.087    0.000     1.410    0.989
   .n2stress           0.488    0.056    8.747    0.000     0.488    0.995
   .Mat_Health         1.000                                0.919    0.919
   .MatMen_health      1.000                                0.975    0.975
   .Infant             1.000                                0.703    0.703
    SocioDem           1.000                                1.000    1.000
parameterEstimates(SEM_model_fit_2, standardized=TRUE) %>%
  filter(op == "=~") %>%
  select('Latent Factor'=lhs, Indicator=rhs, B=est, SE=se, Z=z, 'p-value'=pvalue, Beta=std.all,CI_Lower=ci.lower, CI_Upper=ci.upper) %>%
  knitr::kable(digits = 3, format="html", booktabs=TRUE, caption="Total Sample Factor Loadings")%>%
  kable_classic(full_width = F, html_font = "Cambria")
Total Sample Factor Loadings
Latent Factor Indicator B SE Z p-value Beta CI_Lower CI_Upper
Mat_Health diabpprg -0.003 0.003 -0.881 0.378 -0.028 -0.009 0.003
Mat_Health gestdiab -0.003 0.011 -0.281 0.778 -0.014 -0.026 0.019
Mat_Health hyp -0.079 0.034 -2.344 0.019 -0.196 -0.146 -0.013
Mat_Health prenatal_collapsed -0.060 0.029 -2.094 0.036 -0.169 -0.117 -0.004
Mat_Health hepc 0.067 0.064 1.046 0.296 0.074 -0.058 0.192
Mat_Health hiv 0.020 0.016 1.267 0.205 0.099 -0.011 0.051
Mat_Health syph -0.018 0.015 -1.190 0.234 -0.082 -0.048 0.012
Mat_Health chlmyd -0.048 0.032 -1.475 0.140 -0.124 -0.111 0.016
Mat_Health any_subuse_y_n -0.067 0.032 -2.088 0.037 -0.155 -0.130 -0.004
MatMen_health collapsed_mentheal 0.306 0.052 5.927 0.000 0.329 0.205 0.407
MatMen_health acescore -0.925 0.151 -6.112 0.000 -0.339 -1.222 -0.629
MatMen_health Dep_Score -7.966 0.427 -18.676 0.000 -0.901 -8.802 -7.130
MatMen_health Anx_Score -8.479 0.460 -18.446 0.000 -0.805 -9.380 -7.578
MatMen_health Anger_Score -6.787 0.563 -12.052 0.000 -0.704 -7.891 -5.683
MatMen_health Supp_Score 5.325 0.477 11.157 0.000 0.652 4.390 6.260
MatMen_health Meaning_Score 5.294 0.535 9.889 0.000 0.588 4.245 6.344
Infant imhbirthwt 0.349 0.333 1.046 0.296 0.917 -0.305 1.002
Infant imh_birthlt 1.437 1.379 1.042 0.298 0.725 -1.266 4.139
Infant imh_birthhcr 0.796 0.768 1.036 0.300 0.667 -0.710 2.302
Infant gawks 0.283 0.273 1.038 0.299 0.337 -0.252 0.819
Infant sex 0.071 0.071 0.995 0.320 0.169 -0.068 0.210
SocioDem MatAge 0.940 0.375 2.509 0.012 0.185 0.206 1.674
SocioDem mmins_combined -0.154 0.038 -4.031 0.000 -0.314 -0.229 -0.079
SocioDem mrace_combined 0.381 0.080 4.742 0.000 0.326 0.224 0.539
SocioDem pcedlevel 0.851 0.115 7.408 0.000 0.550 0.626 1.077
SocioDem MomOnlyFSIQ 8.774 1.122 7.818 0.000 0.628 6.574 10.973
SocioDem any_subuse_y_n -0.180 0.039 -4.653 0.000 -0.397 -0.256 -0.104
SocioDem hseincom -6.867 5.085 -1.350 0.177 -0.059 -16.835 3.100
##Regression Table
parameterEstimates(SEM_model_fit_2, standardized=TRUE) %>%
  filter(op == "~") %>%
  select('LV1'=lhs, 'LV2'=rhs, B=est, SE=se, Z=z, 'p-value'=pvalue, Beta=std.all,CI_Lower=ci.lower, CI_Upper=ci.upper) %>%
  knitr::kable(digits = 3, format="html", booktabs=TRUE, caption="Total Sample Regressions")%>%
  kable_classic(full_width = F, html_font = "Cambria")
Total Sample Regressions
LV1 LV2 B SE Z p-value Beta CI_Lower CI_Upper
Mat_Health SocioDem -0.297 0.228 -1.306 0.192 -0.285 -0.743 0.149
MatMen_health SocioDem 0.160 0.075 2.144 0.032 0.158 0.014 0.307
Infant Mat_Health 1.642 21.383 0.077 0.939 1.436 -40.268 43.552
Infant MatMen_health -1.444 21.170 -0.068 0.946 -1.226 -42.937 40.049
Infant SocioDem 1.219 10.375 0.117 0.906 1.022 -19.116 21.554
n2attention Infant -0.006 0.066 -0.088 0.930 -0.005 -0.135 0.123
n2regulation Infant 0.005 0.057 0.094 0.925 0.006 -0.106 0.117
n2arousal Infant 0.082 0.128 0.642 0.521 0.062 -0.169 0.334
n2tone Infant -0.055 0.062 -0.886 0.376 -0.118 -0.176 0.066
n2nonoptref Infant -0.208 0.200 -1.040 0.298 -0.220 -0.601 0.184
n2qmove Infant 0.106 0.121 0.880 0.379 0.106 -0.130 0.343
n2stress Infant -0.042 0.051 -0.826 0.409 -0.071 -0.141 0.057

Sandbox Block:

This block is just for diagnostics and data management strategies post model:

str(cleaned_data_final2.1$final_nnns_class)
 int [1:291] 3 1 1 2 1 2 1 2 1 1 ...

Measurement Model Tests:

M_model_2 <- '
SocioDem =~ MatAge + mmins_combined +  pcedlevel + MomOnlyFSIQ + any_subuse_y_n + hseincom

'



M_model_fit_2 <- sem(M_model_2, estimator= "WLSMV", data=cleaned_data_final2.1, std.lv=TRUE, mimic = "Mplus")
Warning: lavaan->lav_options_est_dwls():  
   estimator "DWLS" is not recommended for continuous data. Did you forget to 
   set the ordered= argument?
Warning: lavaan->lav_data_full():  
   some observed variances are (at least) a factor 1000 times larger than 
   others; use varTable(fit) to investigate
summary(M_model_fit_2, fit.measures = TRUE, standardized=TRUE)
lavaan 0.6-19 ended normally after 44 iterations

  Estimator                                       DWLS
  Optimization method                           NLMINB
  Number of model parameters                        18

                                                  Used       Total
  Number of observations                           233         291

Model Test User Model:
                                              Standard      Scaled
  Test Statistic                                17.877      21.145
  Degrees of freedom                                 9           9
  P-value (Chi-square)                           0.037       0.012
  Scaling correction factor                                  0.925
  Shift parameter                                            1.815
    simple second-order correction (WLSMV)                        

Model Test Baseline Model:

  Test statistic                               120.492      94.355
  Degrees of freedom                                15          15
  P-value                                        0.000       0.000
  Scaling correction factor                                  1.329

User Model versus Baseline Model:

  Comparative Fit Index (CFI)                    0.916       0.847
  Tucker-Lewis Index (TLI)                       0.860       0.745
                                                                  
  Robust Comparative Fit Index (CFI)                         0.894
  Robust Tucker-Lewis Index (TLI)                            0.823

Root Mean Square Error of Approximation:

  RMSEA                                          0.065       0.076
  90 Percent confidence interval - lower         0.016       0.034
  90 Percent confidence interval - upper         0.109       0.119
  P-value H_0: RMSEA <= 0.050                    0.249       0.134
  P-value H_0: RMSEA >= 0.080                    0.326       0.486
                                                                  
  Robust RMSEA                                               0.073
  90 Percent confidence interval - lower                     0.033
  90 Percent confidence interval - upper                     0.114
  P-value H_0: Robust RMSEA <= 0.050                         0.150
  P-value H_0: Robust RMSEA >= 0.080                         0.435

Standardized Root Mean Square Residual:

  SRMR                                           0.058       0.058

Parameter Estimates:

  Standard errors                           Robust.sem
  Information                                 Expected
  Information saturated (h1) model        Unstructured

Latent Variables:
                   Estimate   Std.Err  z-value  P(>|z|)   Std.lv   Std.all
  SocioDem =~                                                             
    MatAge             1.165    0.377    3.094    0.002     1.165    0.232
    mmins_combined    -0.237    0.041   -5.830    0.000    -0.237   -0.531
    pcedlevel          1.117    0.123    9.081    0.000     1.117    0.726
    MomOnlyFSIQ        7.280    1.149    6.336    0.000     7.280    0.524
    any_subuse_y_n    -0.127    0.037   -3.418    0.001    -0.127   -0.286
    hseincom          -7.398    4.122   -1.795    0.073    -7.398   -0.066

Intercepts:
                   Estimate   Std.Err  z-value  P(>|z|)   Std.lv   Std.all
   .MatAge            29.918    0.329   90.801    0.000    29.918    5.961
   .mmins_combined     3.845    0.029  130.920    0.000     3.845    8.595
   .pcedlevel          4.017    0.101   39.742    0.000     4.017    2.609
   .MomOnlyFSIQ       95.107    0.911  104.375    0.000    95.107    6.853
   .any_subuse_y_n     1.730    0.029   59.186    0.000     1.730    3.886
   .hseincom          19.120    7.385    2.589    0.010    19.120    0.170

Variances:
                   Estimate   Std.Err  z-value  P(>|z|)   Std.lv   Std.all
   .MatAge            23.830    2.044   11.659    0.000    23.830    0.946
   .mmins_combined     0.144    0.049    2.915    0.004     0.144    0.718
   .pcedlevel          1.122    0.253    4.428    0.000     1.122    0.473
   .MomOnlyFSIQ      139.639   15.873    8.797    0.000   139.639    0.725
   .any_subuse_y_n     0.182    0.015   12.086    0.000     0.182    0.918
   .hseincom       12597.856 5418.906    2.325    0.020 12597.856    0.996
    SocioDem           1.000                                1.000    1.000
  • Maternal Health LV is a mess when run as a single factor CFA
  • Maternal Mental Health is ok as a single factor CFA (CFI = .92, TLI = .89, robust RMSEA = .05, SRMR = .043 ) ~ using scaled chi-sq because of the data issues
  • infant sex has to be left out of the lv I think - it works ok with and without but maybe leave out and use as a control or run as a multigroup
  • SocioDem has modest fit but could consider running separate

SEM Mixed Version

SEM_model_3 <- '
MatMen_health =~ collapsed_mentheal + acescore + Dep_Score + Anx_Score + Anger_Score + Supp_Score + Meaning_Score

Infant =~ imhbirthwt + imh_birthlt + imh_birthhcr + gawks + sex

SocioDem =~ MatAge + mmins_combined + mrace_combined + pcedlevel + MomOnlyFSIQ + any_subuse_y_n + hseincom

#Regressions
diabpprg ~ SocioDem
gestdiab ~ SocioDem
hyp ~ SocioDem
prenatal_collapsed ~ SocioDem
hepc ~ SocioDem
hiv ~ SocioDem
syph ~ SocioDem
chlmyd ~ SocioDem
any_subuse_y_n ~ SocioDem

MatMen_health ~ SocioDem

Infant ~ diabpprg + gestdiab + hyp + prenatal_collapsed + hepc + hiv + syph + chlmyd + any_subuse_y_n + MatMen_health + SocioDem



final_nnns_class ~ Infant  

'


SEM_model_fit_3 <- sem(SEM_model_3, estimator= "WLSMV", data=cleaned_data_final2.1, std.lv=TRUE, missing = "pairwise", mimic = "Mplus")
Warning: lavaan->lav_options_est_dwls():  
   estimator "DWLS" is not recommended for continuous data. Did you forget to 
   set the ordered= argument?
Warning: lavaan->lav_data_full():  
   some observed variances are (at least) a factor 1000 times larger than 
   others; use varTable(fit) to investigate
Warning: lavaan->lav_samplestats_from_data():  
   number of observations (291) too small to compute Gamma
Warning: lavaan->lav_model_vcov():  
   Could not compute standard errors! The information matrix could not be 
   inverted. This may be a symptom that the model is not identified.
Warning: lavaan->lav_test_satorra_bentler():  
   could not invert information matrix needed for robust test statistic
summary(SEM_model_fit_3, fit.measures = TRUE, standardized=TRUE)
lavaan 0.6-19 ended normally after 143 iterations

  Estimator                                       DWLS
  Optimization method                           NLMINB
  Number of model parameters                        97

  Number of observations                           291
  Number of missing patterns                        27

Model Test User Model:
                                              Standard      Scaled
  Test Statistic                               669.249          NA
  Degrees of freedom                               337         337
  P-value (Chi-square)                           0.000          NA
  Scaling correction factor                                     NA
  Shift parameter                                               NA
                                                                  

Model Test Baseline Model:

  Test statistic                              2225.862    1129.246
  Degrees of freedom                               378         378
  P-value                                        0.000       0.000
  Scaling correction factor                                  2.460

User Model versus Baseline Model:

  Comparative Fit Index (CFI)                    0.820          NA
  Tucker-Lewis Index (TLI)                       0.798          NA
                                                                  
  Robust Comparative Fit Index (CFI)                            NA
  Robust Tucker-Lewis Index (TLI)                               NA

Root Mean Square Error of Approximation:

  RMSEA                                          0.058          NA
  90 Percent confidence interval - lower         0.052          NA
  90 Percent confidence interval - upper         0.065          NA
  P-value H_0: RMSEA <= 0.050                    0.018          NA
  P-value H_0: RMSEA >= 0.080                    0.000          NA
                                                                  
  Robust RMSEA                                                  NA
  90 Percent confidence interval - lower                        NA
  90 Percent confidence interval - upper                        NA
  P-value H_0: Robust RMSEA <= 0.050                            NA
  P-value H_0: Robust RMSEA >= 0.080                            NA

Standardized Root Mean Square Residual:

  SRMR                                           0.069       0.069

Parameter Estimates:

  Standard errors                           Robust.sem
  Information                                 Expected
  Information saturated (h1) model        Unstructured

Latent Variables:
                   Estimate   Std.Err  z-value  P(>|z|)   Std.lv   Std.all
  MatMen_health =~                                                        
    collapsd_mnthl     0.292       NA                       0.302    0.321
    acescore          -0.908       NA                      -0.940   -0.339
    Dep_Score         -7.920       NA                      -8.192   -0.915
    Anx_Score         -8.311       NA                      -8.597   -0.806
    Anger_Score       -6.587       NA                      -6.813   -0.698
    Supp_Score         5.245       NA                       5.425    0.656
    Meaning_Score      5.110       NA                       5.285    0.579
  Infant =~                                                               
    imhbirthwt         0.383       NA                       0.431    0.950
    imh_birthlt        1.495       NA                       1.682    0.712
    imh_birthhcr       0.883       NA                       0.993    0.697
    gawks              0.337       NA                       0.380    0.379
    sex                0.075       NA                       0.084    0.169
  SocioDem =~                                                             
    MatAge             0.876       NA                       0.876    0.172
    mmins_combined    -0.182       NA                      -0.182   -0.370
    mrace_combined     0.250       NA                       0.250    0.213
    pcedlevel          0.860       NA                       0.860    0.555
    MomOnlyFSIQ        7.275       NA                       7.275    0.521
    any_subuse_y_n     0.000       NA                       0.000    0.000
    hseincom          -3.596       NA                      -3.596   -0.031

Regressions:
                       Estimate   Std.Err  z-value  P(>|z|)   Std.lv   Std.all
  diabpprg ~                                                                  
    SocioDem              -0.001       NA                      -0.001   -0.009
  gestdiab ~                                                                  
    SocioDem               0.029       NA                       0.029    0.124
  hyp ~                                                                       
    SocioDem              -0.013       NA                      -0.013   -0.030
  prenatal_collapsed ~                                                        
    SocioDem              -0.071       NA                      -0.071   -0.190
  hepc ~                                                                      
    SocioDem              -0.063       NA                      -0.063   -0.067
  hiv ~                                                                       
    SocioDem              -0.012       NA                      -0.012   -0.056
  syph ~                                                                      
    SocioDem              -0.000       NA                      -0.000   -0.002
  chlmyd ~                                                                    
    SocioDem              -0.040       NA                      -0.040   -0.102
  any_subuse_y_n ~                                                            
    SocioDem              -0.188       NA                      -0.188   -0.414
  MatMen_health ~                                                             
    SocioDem               0.264       NA                       0.256    0.256
  Infant ~                                                                    
    diabpprg              -1.039       NA                      -0.924   -0.094
    gestdiab              -0.141       NA                      -0.125   -0.029
    hyp                   -0.324       NA                      -0.288   -0.121
    prenatl_cllpsd         0.281       NA                       0.250    0.093
    hepc                   0.053       NA                       0.047    0.044
    hiv                   -0.129       NA                      -0.115   -0.024
    syph                   0.046       NA                       0.041    0.010
    chlmyd                 0.283       NA                       0.252    0.100
    any_subuse_y_n        -0.115       NA                      -0.102   -0.046
    MatMen_health          0.056       NA                       0.051    0.051
    SocioDem               0.446       NA                       0.397    0.397
  final_nnns_class ~                                                          
    Infant                -0.014       NA                      -0.016   -0.015

Intercepts:
                   Estimate   Std.Err  z-value  P(>|z|)   Std.lv   Std.all
   .collapsd_mnthl     2.014       NA                       2.014    2.144
   .acescore           2.758       NA                       2.758    0.996
   .Dep_Score         47.667       NA                      47.667    5.323
   .Anx_Score         52.164       NA                      52.164    4.889
   .Anger_Score       51.645       NA                      51.645    5.290
   .Supp_Score        56.181       NA                      56.181    6.793
   .Meaning_Score     59.531       NA                      59.531    6.524
   .imhbirthwt         3.701       NA                       3.701    8.164
   .imh_birthlt       51.981       NA                      51.981   21.992
   .imh_birthhcr      35.212       NA                      35.212   24.724
   .gawks             39.116       NA                      39.116   39.011
   .sex                1.649       NA                       1.649    3.320
   .MatAge            29.753       NA                      29.753    5.841
   .mmins_combined     3.835       NA                       3.835    7.801
   .mrace_combined     3.423       NA                       3.423    2.925
   .pcedlevel          4.054       NA                       4.054    2.619
   .MomOnlyFSIQ       94.385       NA                      94.385    6.758
   .any_subuse_y_n     1.711       NA                       1.711    3.770
   .hseincom          20.643       NA                      20.643    0.177
   .diabpprg           1.011       NA                       1.011    9.884
   .gestdiab           1.057       NA                       1.057    4.546
   .hyp                1.230       NA                       1.230    2.918
   .prenatl_cllpsd     1.165       NA                       1.165    3.131
   .hepc               1.732       NA                       1.732    1.847
   .hiv                1.024       NA                       1.024    4.868
   .syph               1.034       NA                       1.034    4.452
   .chlmyd             1.100       NA                       1.100    2.758
   .finl_nnns_clss     2.121       NA                       2.121    2.070

Variances:
                   Estimate   Std.Err  z-value  P(>|z|)   Std.lv   Std.all
   .collapsd_mnthl     0.791       NA                       0.791    0.897
   .acescore           6.780       NA                       6.780    0.885
   .Dep_Score         13.099       NA                      13.099    0.163
   .Anx_Score         39.947       NA                      39.947    0.351
   .Anger_Score       48.881       NA                      48.881    0.513
   .Supp_Score        38.969       NA                      38.969    0.570
   .Meaning_Score     55.328       NA                      55.328    0.665
   .imhbirthwt         0.020       NA                       0.020    0.098
   .imh_birthlt        2.757       NA                       2.757    0.494
   .imh_birthhcr       1.042       NA                       1.042    0.514
   .gawks              0.861       NA                       0.861    0.857
   .sex                0.240       NA                       0.240    0.971
   .MatAge            25.178       NA                      25.178    0.970
   .mmins_combined     0.208       NA                       0.208    0.863
   .mrace_combined     1.307       NA                       1.307    0.955
   .pcedlevel          1.656       NA                       1.656    0.691
   .MomOnlyFSIQ      142.128       NA                     142.128    0.729
   .any_subuse_y_n     0.171       NA                       0.171    0.828
   .hseincom       13663.523       NA                   13663.523    0.999
   .diabpprg           0.010       NA                       0.010    1.000
   .gestdiab           0.053       NA                       0.053    0.985
   .hyp                0.177       NA                       0.177    0.999
   .prenatl_cllpsd     0.134       NA                       0.134    0.964
   .hepc               0.876       NA                       0.876    0.996
   .hiv                0.044       NA                       0.044    0.997
   .syph               0.054       NA                       0.054    1.000
   .chlmyd             0.157       NA                       0.157    0.990
   .finl_nnns_clss     1.050       NA                       1.050    1.000
   .MatMen_health      1.000                                0.935    0.935
   .Infant             1.000                                0.790    0.790
    SocioDem           1.000                                1.000    1.000

sociodemographic model

SEM_model_4<- '

Infant =~ imhbirthwt + imh_birthlt + imh_birthhcr + gawks + sex

SocioDem =~ MatAge + mmins_combined + mrace_combined + pcedlevel + MomOnlyFSIQ + any_subuse_y_n + hseincom

#Regressions

Infant ~ SocioDem

final_nnns_class ~ Infant  

'


SEM_model_fit_4 <- sem(SEM_model_4, estimator= "WLSMV", data=cleaned_data_final2.1, std.lv=TRUE, missing = "pairwise", mimic = "Mplus")
Warning: lavaan->lav_options_est_dwls():  
   estimator "DWLS" is not recommended for continuous data. Did you forget to 
   set the ordered= argument?
Warning: lavaan->lav_data_full():  
   some observed variances are (at least) a factor 1000 times larger than 
   others; use varTable(fit) to investigate
Warning: lavaan->lav_model_vcov():  
   The variance-covariance matrix of the estimated parameters (vcov) does not 
   appear to be positive definite! The smallest eigenvalue (= -2.350048e-06) 
   is smaller than zero. This may be a symptom that the model is not 
   identified.
summary(SEM_model_fit_4, fit.measures = TRUE, standardized=TRUE)
lavaan 0.6-19 ended normally after 64 iterations

  Estimator                                       DWLS
  Optimization method                           NLMINB
  Number of model parameters                        40

  Number of observations                           291
  Number of missing patterns                         7

Model Test User Model:
                                              Standard      Scaled
  Test Statistic                               101.769     112.186
  Degrees of freedom                                64          64
  P-value (Chi-square)                           0.002       0.000
  Scaling correction factor                                  1.079
  Shift parameter                                           17.836
    simple second-order correction (WLSMV)                        

Model Test Baseline Model:

  Test statistic                               663.986     464.573
  Degrees of freedom                                78          78
  P-value                                        0.000       0.000
  Scaling correction factor                                  1.516

User Model versus Baseline Model:

  Comparative Fit Index (CFI)                    0.936       0.875
  Tucker-Lewis Index (TLI)                       0.921       0.848
                                                                  
  Robust Comparative Fit Index (CFI)                         0.936
  Robust Tucker-Lewis Index (TLI)                            0.921

Root Mean Square Error of Approximation:

  RMSEA                                          0.045       0.051
  90 Percent confidence interval - lower         0.028       0.035
  90 Percent confidence interval - upper         0.061       0.066
  P-value H_0: RMSEA <= 0.050                    0.674       0.441
  P-value H_0: RMSEA >= 0.080                    0.000       0.001
                                                                  
  Robust RMSEA                                               0.053
  90 Percent confidence interval - lower                     0.036
  90 Percent confidence interval - upper                     0.069
  P-value H_0: Robust RMSEA <= 0.050                         0.366
  P-value H_0: Robust RMSEA >= 0.080                         0.002

Standardized Root Mean Square Residual:

  SRMR                                           0.057       0.057

Parameter Estimates:

  Standard errors                           Robust.sem
  Information                                 Expected
  Information saturated (h1) model        Unstructured

Latent Variables:
                   Estimate   Std.Err  z-value  P(>|z|)   Std.lv   Std.all
  Infant =~                                                               
    imhbirthwt         0.390    0.026   14.873    0.000     0.423    0.933
    imh_birthlt        1.538    0.133   11.539    0.000     1.670    0.706
    imh_birthhcr       0.937    0.076   12.355    0.000     1.017    0.714
    gawks              0.351    0.060    5.814    0.000     0.381    0.380
    sex                0.080    0.028    2.864    0.004     0.087    0.175
  SocioDem =~                                                             
    MatAge             0.833    0.363    2.294    0.022     0.833    0.164
    mmins_combined    -0.165    0.036   -4.562    0.000    -0.165   -0.337
    mrace_combined     0.272    0.073    3.745    0.000     0.272    0.233
    pcedlevel          0.895    0.112    7.961    0.000     0.895    0.578
    MomOnlyFSIQ        9.476    1.159    8.178    0.000     9.476    0.679
    any_subuse_y_n    -0.137    0.035   -3.945    0.000    -0.137   -0.303
    hseincom          -4.737    4.356   -1.088    0.277    -4.737   -0.041

Regressions:
                     Estimate   Std.Err  z-value  P(>|z|)   Std.lv   Std.all
  Infant ~                                                                  
    SocioDem             0.424    0.090    4.722    0.000     0.390    0.390
  final_nnns_class ~                                                        
    Infant               0.011    0.058    0.192    0.848     0.012    0.012

Intercepts:
                   Estimate   Std.Err  z-value  P(>|z|)   Std.lv   Std.all
   .imhbirthwt         3.261    0.027  122.529    0.000     3.261    7.195
   .imh_birthlt       50.265    0.138  363.413    0.000    50.265   21.267
   .imh_birthhcr      34.200    0.083  410.346    0.000    34.200   24.013
   .gawks             38.729    0.059  657.764    0.000    38.729   38.625
   .sex                1.564    0.029   53.597    0.000     1.564    3.147
   .MatAge            29.753    0.299   99.470    0.000    29.753    5.841
   .mmins_combined     3.835    0.029  132.851    0.000     3.835    7.801
   .mrace_combined     3.423    0.069   49.815    0.000     3.423    2.925
   .pcedlevel          4.054    0.089   45.476    0.000     4.054    2.619
   .MomOnlyFSIQ       94.385    0.778  121.311    0.000    94.385    6.758
   .any_subuse_y_n     1.711    0.027   64.203    0.000     1.711    3.770
   .hseincom          20.643    6.465    3.193    0.001    20.643    0.177
   .finl_nnns_clss     2.137    0.060   35.522    0.000     2.137    2.086

Variances:
                   Estimate   Std.Err  z-value  P(>|z|)   Std.lv   Std.all
   .imhbirthwt         0.026    0.011    2.368    0.018     0.026    0.129
   .imh_birthlt        2.798    0.380    7.358    0.000     2.798    0.501
   .imh_birthhcr       0.993    0.123    8.052    0.000     0.993    0.490
   .gawks              0.860    0.073   11.719    0.000     0.860    0.856
   .sex                0.239    0.006   38.472    0.000     0.239    0.969
   .MatAge            25.251    1.935   13.049    0.000    25.251    0.973
   .mmins_combined     0.214    0.058    3.716    0.000     0.214    0.887
   .mrace_combined     1.295    0.118   10.934    0.000     1.295    0.946
   .pcedlevel          1.594    0.184    8.671    0.000     1.594    0.666
   .MomOnlyFSIQ      105.255   18.256    5.765    0.000   105.255    0.540
   .any_subuse_y_n     0.187    0.014   13.862    0.000     0.187    0.908
   .hseincom       13653.979 4758.063    2.870    0.004 13653.979    0.998
   .finl_nnns_clss     1.050    0.060   17.405    0.000     1.050    1.000
   .Infant             1.000                                0.848    0.848
    SocioDem           1.000                                1.000    1.000

Sociodemographic model tables

parameterEstimates(SEM_model_fit_4, standardized=TRUE) %>%
  filter(op == "=~") %>%
  select('Latent Factor'=lhs, Indicator=rhs, B=est, SE=se, Z=z, 'p-value'=pvalue, Beta=std.all,CI_Lower=ci.lower, CI_Upper=ci.upper) %>%
  knitr::kable(digits = 3, format="html", booktabs=TRUE, caption="Total Sample Factor Loadings")%>%
  kable_classic(full_width = F, html_font = "Cambria")
Total Sample Factor Loadings
Latent Factor Indicator B SE Z p-value Beta CI_Lower CI_Upper
Infant imhbirthwt 0.390 0.026 14.873 0.000 0.933 0.338 0.441
Infant imh_birthlt 1.538 0.133 11.539 0.000 0.706 1.276 1.799
Infant imh_birthhcr 0.937 0.076 12.355 0.000 0.714 0.788 1.085
Infant gawks 0.351 0.060 5.814 0.000 0.380 0.232 0.469
Infant sex 0.080 0.028 2.864 0.004 0.175 0.025 0.135
SocioDem MatAge 0.833 0.363 2.294 0.022 0.164 0.121 1.545
SocioDem mmins_combined -0.165 0.036 -4.562 0.000 -0.337 -0.237 -0.094
SocioDem mrace_combined 0.272 0.073 3.745 0.000 0.233 0.130 0.415
SocioDem pcedlevel 0.895 0.112 7.961 0.000 0.578 0.674 1.115
SocioDem MomOnlyFSIQ 9.476 1.159 8.178 0.000 0.679 7.205 11.748
SocioDem any_subuse_y_n -0.137 0.035 -3.945 0.000 -0.303 -0.206 -0.069
SocioDem hseincom -4.737 4.356 -1.088 0.277 -0.041 -13.274 3.800
##Regression Table
parameterEstimates(SEM_model_fit_4, standardized=TRUE) %>%
  filter(op == "~") %>%
  select('LV1'=lhs, 'LV2'=rhs, B=est, SE=se, Z=z, 'p-value'=pvalue, Beta=std.all,CI_Lower=ci.lower, CI_Upper=ci.upper) %>%
  knitr::kable(digits = 3, format="html", booktabs=TRUE, caption="Total Sample Regressions")%>%
  kable_classic(full_width = F, html_font = "Cambria")
Total Sample Regressions
LV1 LV2 B SE Z p-value Beta CI_Lower CI_Upper
Infant SocioDem 0.424 0.090 4.722 0.000 0.390 0.248 0.600
final_nnns_class Infant 0.011 0.058 0.192 0.848 0.012 -0.102 0.124

Maternal Health Model

SEM_model_5 <- '

Infant =~ imhbirthwt + imh_birthlt + imh_birthhcr + gawks + sex

#Regressions

Infant ~ diabpprg + gestdiab + hyp + prenatal_collapsed + hepc + hiv + syph + chlmyd + any_subuse_y_n 

final_nnns_class ~ Infant  

'


SEM_model_fit_5 <- sem(SEM_model_5, estimator= "WLSMV", data=cleaned_data_final2.1, std.lv=TRUE, missing = "pairwise", mimic = "Mplus")
Warning: lavaan->lav_options_est_dwls():  
   estimator "DWLS" is not recommended for continuous data. Did you forget to 
   set the ordered= argument?
Warning: lavaan->lav_model_vcov():  
   The variance-covariance matrix of the estimated parameters (vcov) does not 
   appear to be positive definite! The smallest eigenvalue (= -3.451017e-06) 
   is smaller than zero. This may be a symptom that the model is not 
   identified.
summary(SEM_model_fit_5, fit.measures = TRUE, standardized=TRUE)
lavaan 0.6-19 ended normally after 211 iterations

  Estimator                                       DWLS
  Optimization method                           NLMINB
  Number of model parameters                        81

  Number of observations                           291
  Number of missing patterns                         7

Model Test User Model:
                                              Standard      Scaled
  Test Statistic                                57.277      76.047
  Degrees of freedom                                54          54
  P-value (Chi-square)                           0.355       0.026
  Scaling correction factor                                  0.923
  Shift parameter                                           13.987
    simple second-order correction (WLSMV)                        

Model Test Baseline Model:

  Test statistic                               431.877     311.036
  Degrees of freedom                                69          69
  P-value                                        0.000       0.000
  Scaling correction factor                                  1.499

User Model versus Baseline Model:

  Comparative Fit Index (CFI)                    0.991       0.909
  Tucker-Lewis Index (TLI)                       0.988       0.884
                                                                  
  Robust Comparative Fit Index (CFI)                         0.991
  Robust Tucker-Lewis Index (TLI)                            0.988

Root Mean Square Error of Approximation:

  RMSEA                                          0.014       0.038
  90 Percent confidence interval - lower         0.000       0.014
  90 Percent confidence interval - upper         0.040       0.056
  P-value H_0: RMSEA <= 0.050                    0.993       0.856
  P-value H_0: RMSEA >= 0.080                    0.000       0.000
                                                                  
  Robust RMSEA                                               0.036
  90 Percent confidence interval - lower                     0.013
  90 Percent confidence interval - upper                     0.054
  P-value H_0: Robust RMSEA <= 0.050                         0.896
  P-value H_0: Robust RMSEA >= 0.080                         0.000

Standardized Root Mean Square Residual:

  SRMR                                           0.038       0.038

Parameter Estimates:

  Standard errors                           Robust.sem
  Information                                 Expected
  Information saturated (h1) model        Unstructured

Latent Variables:
                   Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
  Infant =~                                                             
    imhbirthwt        0.419    0.024   17.179    0.000    0.438    0.966
    imh_birthlt       1.547    0.131   11.791    0.000    1.618    0.685
    imh_birthhcr      0.924    0.074   12.554    0.000    0.966    0.678
    gawks             0.405    0.062    6.548    0.000    0.423    0.422
    sex               0.081    0.029    2.781    0.005    0.084    0.170

Regressions:
                     Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
  Infant ~                                                                
    diabpprg           -0.861    0.259   -3.323    0.001   -0.823   -0.084
    gestdiab            0.155    0.209    0.743    0.457    0.148    0.034
    hyp                -0.347    0.150   -2.304    0.021   -0.331   -0.140
    prenatl_cllpsd      0.074    0.196    0.379    0.704    0.071    0.027
    hepc                0.112    0.082    1.367    0.172    0.107    0.100
    hiv                -0.269    0.118   -2.280    0.023   -0.257   -0.054
    syph               -0.121    0.168   -0.721    0.471   -0.116   -0.027
    chlmyd              0.213    0.133    1.599    0.110    0.204    0.081
    any_subuse_y_n     -0.548    0.165   -3.314    0.001   -0.524   -0.238
  final_nnns_class ~                                                      
    Infant              0.001    0.060    0.014    0.989    0.001    0.001

Covariances:
                        Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
  diabpprg ~~                                                                
    gestdiab              -0.001    0.000   -1.687    0.092   -0.001   -0.026
    hyp                    0.005    0.004    1.224    0.221    0.005    0.108
    prenatl_cllpsd        -0.002    0.001   -1.783    0.075   -0.002   -0.047
    hepc                  -0.001    0.006   -0.112    0.911   -0.001   -0.007
    hiv                   -0.000    0.000   -1.351    0.177   -0.000   -0.012
    syph                  -0.000    0.000   -1.359    0.174   -0.000   -0.014
    chlmyd                -0.001    0.001   -1.635    0.102   -0.001   -0.025
    any_subuse_y_n        -0.000    0.003   -0.171    0.864   -0.000   -0.010
  gestdiab ~~                                                                
    hyp                    0.009    0.007    1.282    0.200    0.009    0.087
    prenatl_cllpsd         0.007    0.006    1.136    0.256    0.007    0.076
    hepc                  -0.013    0.012   -1.057    0.291   -0.013   -0.058
    hiv                    0.009    0.007    1.299    0.194    0.009    0.191
    syph                   0.002    0.003    0.600    0.549    0.002    0.036
    chlmyd                -0.002    0.003   -0.566    0.571   -0.002   -0.021
    any_subuse_y_n        -0.005    0.007   -0.750    0.453   -0.005   -0.047
  hyp ~~                                                                     
    prenatl_cllpsd         0.010    0.009    1.083    0.279    0.010    0.065
    hepc                  -0.023    0.022   -1.052    0.293   -0.023   -0.059
    hiv                   -0.006    0.003   -1.994    0.046   -0.006   -0.064
    syph                  -0.000    0.006   -0.040    0.968   -0.000   -0.002
    chlmyd                 0.009    0.011    0.799    0.424    0.009    0.054
    any_subuse_y_n        -0.004    0.011   -0.369    0.712   -0.004   -0.022
  prenatal_collapsed ~~                                                      
    hepc                   0.010    0.020    0.487    0.626    0.010    0.028
    hiv                   -0.001    0.003   -0.165    0.869   -0.001   -0.007
    syph                   0.014    0.008    1.849    0.065    0.014    0.160
    chlmyd                 0.005    0.009    0.580    0.562    0.005    0.033
    any_subuse_y_n         0.007    0.009    0.808    0.419    0.007    0.044
  hepc ~~                                                                    
    hiv                    0.017    0.014    1.210    0.226    0.017    0.085
    syph                   0.026    0.015    1.755    0.079    0.026    0.122
    chlmyd                -0.021    0.021   -1.045    0.296   -0.021   -0.057
    any_subuse_y_n         0.140    0.021    6.710    0.000    0.140    0.328
  hiv ~~                                                                     
    syph                   0.003    0.003    0.797    0.426    0.003    0.054
    chlmyd                 0.001    0.003    0.316    0.752    0.001    0.012
    any_subuse_y_n         0.007    0.004    1.948    0.051    0.007    0.073
  syph ~~                                                                    
    chlmyd                 0.021    0.014    1.490    0.136    0.021    0.223
    any_subuse_y_n        -0.000    0.006   -0.062    0.951   -0.000   -0.004
  chlmyd ~~                                                                  
    any_subuse_y_n         0.005    0.010    0.455    0.649    0.005    0.026

Intercepts:
                   Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
   .imhbirthwt        4.081    0.219   18.632    0.000    4.081    9.002
   .imh_birthlt      53.292    0.857   62.188    0.000   53.292   22.547
   .imh_birthhcr     36.006    0.496   72.662    0.000   36.006   25.281
   .gawks            39.520    0.239  165.664    0.000   39.520   39.414
   .sex               1.721    0.078   22.095    0.000    1.721    3.465
   .finl_nnns_clss    2.139    0.135   15.833    0.000    2.139    2.088
    diabpprg          1.011    0.006  170.092    0.000    1.011    9.884
    gestdiab          1.057    0.013   78.931    0.000    1.057    4.546
    hyp               1.230    0.024   50.396    0.000    1.230    2.918
    prenatl_cllpsd    1.165    0.021   54.550    0.000    1.165    3.131
    hepc              1.732    0.055   31.448    0.000    1.732    1.847
    hiv               1.024    0.012   82.905    0.000    1.024    4.868
    syph              1.034    0.014   75.810    0.000    1.034    4.452
    chlmyd            1.100    0.023   46.963    0.000    1.100    2.758
    any_subuse_y_n    1.711    0.027   64.203    0.000    1.711    3.770

Variances:
                   Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
   .imhbirthwt        0.014    0.011    1.293    0.196    0.014    0.066
   .imh_birthlt       2.968    0.392    7.572    0.000    2.968    0.531
   .imh_birthhcr      1.096    0.113    9.675    0.000    1.096    0.540
   .gawks             0.826    0.072   11.401    0.000    0.826    0.822
   .sex               0.240    0.006   39.572    0.000    0.240    0.971
   .finl_nnns_clss    1.050    0.060   17.392    0.000    1.050    1.000
   .Infant            1.000                               0.914    0.914
    diabpprg          0.010    0.006    1.797    0.072    0.010    1.000
    gestdiab          0.054    0.012    4.559    0.000    0.054    1.000
    hyp               0.178    0.013   13.489    0.000    0.178    1.000
    prenatl_cllpsd    0.139    0.014    9.706    0.000    0.139    1.000
    hepc              0.880    0.031   28.225    0.000    0.880    1.000
    hiv               0.044    0.023    1.890    0.059    0.044    1.000
    syph              0.054    0.024    2.274    0.023    0.054    1.000
    chlmyd            0.159    0.039    4.060    0.000    0.159    1.000
    any_subuse_y_n    0.206    0.011   18.361    0.000    0.206    1.000

Maternal Health Tables

parameterEstimates(SEM_model_fit_5, standardized=TRUE) %>%
  filter(op == "=~") %>%
  select('Latent Factor'=lhs, Indicator=rhs, B=est, SE=se, Z=z, 'p-value'=pvalue, Beta=std.all,CI_Lower=ci.lower, CI_Upper=ci.upper) %>%
  knitr::kable(digits = 3, format="html", booktabs=TRUE, caption="Total Sample Factor Loadings")%>%
  kable_classic(full_width = F, html_font = "Cambria")
Total Sample Factor Loadings
Latent Factor Indicator B SE Z p-value Beta CI_Lower CI_Upper
Infant imhbirthwt 0.419 0.024 17.179 0.000 0.966 0.371 0.467
Infant imh_birthlt 1.547 0.131 11.791 0.000 0.685 1.290 1.805
Infant imh_birthhcr 0.924 0.074 12.554 0.000 0.678 0.779 1.068
Infant gawks 0.405 0.062 6.548 0.000 0.422 0.283 0.526
Infant sex 0.081 0.029 2.781 0.005 0.170 0.024 0.137
##Regression Table
parameterEstimates(SEM_model_fit_5, standardized=TRUE) %>%
  filter(op == "~") %>%
  select('LV1'=lhs, 'LV2'=rhs, B=est, SE=se, Z=z, 'p-value'=pvalue, Beta=std.all,CI_Lower=ci.lower, CI_Upper=ci.upper) %>%
  knitr::kable(digits = 3, format="html", booktabs=TRUE, caption="Total Sample Regressions")%>%
  kable_classic(full_width = F, html_font = "Cambria")
Total Sample Regressions
LV1 LV2 B SE Z p-value Beta CI_Lower CI_Upper
Infant diabpprg -0.861 0.259 -3.323 0.001 -0.084 -1.368 -0.353
Infant gestdiab 0.155 0.209 0.743 0.457 0.034 -0.254 0.564
Infant hyp -0.347 0.150 -2.304 0.021 -0.140 -0.642 -0.052
Infant prenatal_collapsed 0.074 0.196 0.379 0.704 0.027 -0.310 0.459
Infant hepc 0.112 0.082 1.367 0.172 0.100 -0.048 0.272
Infant hiv -0.269 0.118 -2.280 0.023 -0.054 -0.500 -0.038
Infant syph -0.121 0.168 -0.721 0.471 -0.027 -0.451 0.208
Infant chlmyd 0.213 0.133 1.599 0.110 0.081 -0.048 0.475
Infant any_subuse_y_n -0.548 0.165 -3.314 0.001 -0.238 -0.872 -0.224
final_nnns_class Infant 0.001 0.060 0.014 0.989 0.001 -0.117 0.119

Maternal Mental Health Model

SEM_model_6 <- '
MatMen_health =~ collapsed_mentheal + acescore + Dep_Score + Anx_Score + Anger_Score + Supp_Score + Meaning_Score

Infant =~ imhbirthwt + imh_birthlt + imh_birthhcr + gawks + sex


#Regressions

Infant ~ MatMen_health



final_nnns_class ~ Infant  

'


SEM_model_fit_6 <- sem(SEM_model_6, estimator= "WLSMV", data=cleaned_data_final2.1, std.lv=TRUE, missing = "pairwise", mimic = "Mplus")
Warning: lavaan->lav_options_est_dwls():  
   estimator "DWLS" is not recommended for continuous data. Did you forget to 
   set the ordered= argument?
Warning: lavaan->lav_model_vcov():  
   The variance-covariance matrix of the estimated parameters (vcov) does not 
   appear to be positive definite! The smallest eigenvalue (= -1.465163e-06) 
   is smaller than zero. This may be a symptom that the model is not 
   identified.
summary(SEM_model_fit_6, fit.measures = TRUE, standardized=TRUE)
lavaan 0.6-19 ended normally after 46 iterations

  Estimator                                       DWLS
  Optimization method                           NLMINB
  Number of model parameters                        40

  Number of observations                           291
  Number of missing patterns                         6

Model Test User Model:
                                              Standard      Scaled
  Test Statistic                                62.508      83.798
  Degrees of freedom                                64          64
  P-value (Chi-square)                           0.529       0.049
  Scaling correction factor                                  1.024
  Shift parameter                                           22.740
    simple second-order correction (WLSMV)                        

Model Test Baseline Model:

  Test statistic                              1278.477     705.814
  Degrees of freedom                                78          78
  P-value                                        0.000       0.000
  Scaling correction factor                                  1.912

User Model versus Baseline Model:

  Comparative Fit Index (CFI)                    1.000       0.968
  Tucker-Lewis Index (TLI)                       1.002       0.962
                                                                  
  Robust Comparative Fit Index (CFI)                         1.000
  Robust Tucker-Lewis Index (TLI)                            1.002

Root Mean Square Error of Approximation:

  RMSEA                                          0.000       0.033
  90 Percent confidence interval - lower         0.000       0.002
  90 Percent confidence interval - upper         0.034       0.051
  P-value H_0: RMSEA <= 0.050                    0.999       0.943
  P-value H_0: RMSEA >= 0.080                    0.000       0.000
                                                                  
  Robust RMSEA                                               0.033
  90 Percent confidence interval - lower                     0.002
  90 Percent confidence interval - upper                     0.051
  P-value H_0: Robust RMSEA <= 0.050                         0.936
  P-value H_0: Robust RMSEA >= 0.080                         0.000

Standardized Root Mean Square Residual:

  SRMR                                           0.044       0.044

Parameter Estimates:

  Standard errors                           Robust.sem
  Information                                 Expected
  Information saturated (h1) model        Unstructured

Latent Variables:
                   Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
  MatMen_health =~                                                      
    collapsd_mnthl    0.303    0.051    5.908    0.000    0.303    0.322
    acescore         -0.912    0.154   -5.910    0.000   -0.912   -0.330
    Dep_Score        -8.099    0.419  -19.342    0.000   -8.099   -0.904
    Anx_Score        -8.571    0.441  -19.444    0.000   -8.571   -0.803
    Anger_Score      -6.904    0.578  -11.935    0.000   -6.904   -0.707
    Supp_Score        5.386    0.478   11.277    0.000    5.386    0.651
    Meaning_Score     5.452    0.519   10.495    0.000    5.452    0.597
  Infant =~                                                             
    imhbirthwt        0.440    0.026   16.645    0.000    0.445    0.981
    imh_birthlt       1.704    0.139   12.261    0.000    1.723    0.729
    imh_birthhcr      0.909    0.080   11.347    0.000    0.919    0.645
    gawks             0.385    0.063    6.064    0.000    0.389    0.388
    sex               0.085    0.030    2.807    0.005    0.086    0.172

Regressions:
                     Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
  Infant ~                                                                
    MatMen_health       0.151    0.066    2.300    0.021    0.150    0.150
  final_nnns_class ~                                                      
    Infant             -0.002    0.062   -0.034    0.973   -0.002   -0.002

Intercepts:
                   Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
   .collapsd_mnthl    2.014    0.055   36.503    0.000    2.014    2.144
   .acescore          2.758    0.160   17.267    0.000    2.758    0.996
   .Dep_Score        47.667    0.491   97.043    0.000   47.667    5.323
   .Anx_Score        52.164    0.586   88.958    0.000   52.164    4.889
   .Anger_Score      51.645    0.536   96.264    0.000   51.645    5.290
   .Supp_Score       56.181    0.455  123.360    0.000   56.181    6.793
   .Meaning_Score    59.531    0.501  118.714    0.000   59.531    6.524
   .imhbirthwt        3.261    0.027  122.529    0.000    3.261    7.195
   .imh_birthlt      50.265    0.138  363.413    0.000   50.265   21.267
   .imh_birthhcr     34.200    0.083  410.346    0.000   34.200   24.013
   .gawks            38.729    0.059  657.764    0.000   38.729   38.625
   .sex               1.564    0.029   53.597    0.000    1.564    3.147
   .finl_nnns_clss    2.137    0.060   35.522    0.000    2.137    2.086

Variances:
                   Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
   .collapsd_mnthl    0.791    0.034   23.069    0.000    0.791    0.896
   .acescore          6.831    0.550   12.418    0.000    6.831    0.891
   .Dep_Score        14.601    2.828    5.164    0.000   14.601    0.182
   .Anx_Score        40.394    4.696    8.602    0.000   40.394    0.355
   .Anger_Score      47.635    6.287    7.577    0.000   47.635    0.500
   .Supp_Score       39.400    3.999    9.853    0.000   39.400    0.576
   .Meaning_Score    53.537    5.239   10.218    0.000   53.537    0.643
   .imhbirthwt        0.008    0.014    0.546    0.585    0.008    0.038
   .imh_birthlt       2.618    0.412    6.355    0.000    2.618    0.469
   .imh_birthhcr      1.184    0.117   10.126    0.000    1.184    0.584
   .gawks             0.854    0.073   11.693    0.000    0.854    0.849
   .sex               0.239    0.006   39.039    0.000    0.239    0.970
   .finl_nnns_clss    1.050    0.060   17.392    0.000    1.050    1.000
    MatMen_health     1.000                               1.000    1.000
   .Infant            1.000                               0.978    0.978

Maternal Mental Health Tables

parameterEstimates(SEM_model_fit_6, standardized=TRUE) %>%
  filter(op == "=~") %>%
  select('Latent Factor'=lhs, Indicator=rhs, B=est, SE=se, Z=z, 'p-value'=pvalue, Beta=std.all,CI_Lower=ci.lower, CI_Upper=ci.upper) %>%
  knitr::kable(digits = 3, format="html", booktabs=TRUE, caption="Total Sample Factor Loadings")%>%
  kable_classic(full_width = F, html_font = "Cambria")
Total Sample Factor Loadings
Latent Factor Indicator B SE Z p-value Beta CI_Lower CI_Upper
MatMen_health collapsed_mentheal 0.303 0.051 5.908 0.000 0.322 0.202 0.403
MatMen_health acescore -0.912 0.154 -5.910 0.000 -0.330 -1.215 -0.610
MatMen_health Dep_Score -8.099 0.419 -19.342 0.000 -0.904 -8.920 -7.279
MatMen_health Anx_Score -8.571 0.441 -19.444 0.000 -0.803 -9.434 -7.707
MatMen_health Anger_Score -6.904 0.578 -11.935 0.000 -0.707 -8.038 -5.770
MatMen_health Supp_Score 5.386 0.478 11.277 0.000 0.651 4.450 6.322
MatMen_health Meaning_Score 5.452 0.519 10.495 0.000 0.597 4.434 6.470
Infant imhbirthwt 0.440 0.026 16.645 0.000 0.981 0.388 0.491
Infant imh_birthlt 1.704 0.139 12.261 0.000 0.729 1.431 1.976
Infant imh_birthhcr 0.909 0.080 11.347 0.000 0.645 0.752 1.066
Infant gawks 0.385 0.063 6.064 0.000 0.388 0.260 0.509
Infant sex 0.085 0.030 2.807 0.005 0.172 0.026 0.144
##Regression Table
parameterEstimates(SEM_model_fit_6, standardized=TRUE) %>%
  filter(op == "~") %>%
  select('LV1'=lhs, 'LV2'=rhs, B=est, SE=se, Z=z, 'p-value'=pvalue, Beta=std.all,CI_Lower=ci.lower, CI_Upper=ci.upper) %>%
  knitr::kable(digits = 3, format="html", booktabs=TRUE, caption="Total Sample Regressions")%>%
  kable_classic(full_width = F, html_font = "Cambria")
Total Sample Regressions
LV1 LV2 B SE Z p-value Beta CI_Lower CI_Upper
Infant MatMen_health 0.151 0.066 2.300 0.021 0.150 0.022 0.280
final_nnns_class Infant -0.002 0.062 -0.034 0.973 -0.002 -0.123 0.119