Loading libraries

library(tidyverse)
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr     1.1.3     ✔ readr     2.1.4
## ✔ forcats   1.0.0     ✔ stringr   1.5.1
## ✔ ggplot2   3.4.4     ✔ tibble    3.2.1
## ✔ lubridate 1.9.3     ✔ tidyr     1.3.0
## ✔ purrr     1.0.2     
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag()    masks stats::lag()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
library(lavaan)
## This is lavaan 0.6-18
## lavaan is FREE software! Please report any bugs.
#install.packages("semPlot")
library(semPlot)

Loading data

db <- read.csv("dairymean_bone.csv")
db2 <-read.csv("dairy_TBS_BMD_cov.csv")

#look at variance of inflammation biomarkers

#lapply(db,function(x)var(x,na.rm=T))#variance of each is high; log transform
db$log_crp <- log(db$CRP)
db$log_tnf <-log(db$TNFa)
db$log_IL6 <-log(db$IL6)
db$log_il1B <-log(db$IL1B)
db$log_skim <-log(db$skim)
db2 <-read.csv("dairy_TBS_BMD_cov.csv")
db2$log_crp <-log(db2$CRP)
db2$log_tnf <-log(db2$TNFa)
db2$log_IL6 <-log(db2$IL6)
db2$log_il1B <-log(db2$IL1B)
db2$log_skim <-log(db2$skim + 0.01)

Eliminate bone columns 3a, 5a, 5c, 5f because of high NA content

db$bone3a_b2 <- NULL
db$bone5a_b2 <- NULL
db$bone5c_b2 <- NULL
db$bone5f_b2 <- NULL
db2$bone3a_b2 <- NULL
db2$bone5a_b2 <- NULL
db2$bone5c_b2 <- NULL
db2$bone5f_b2 <- NULL

Eliminate dichotomized variables

# db <- db %>% dplyr::select(!contains("dichot"))
# db2 <- db2 %>% dplyr::select(!contains("dichot"))

SEM milk as predictor var, BMSi as response, and IL6, TNFa, IL1B as individual mediators

model_milk <- ' # direct effect
             BMSi ~ i*milk
           # mediator
             IL6 ~ a*milk
             TNFa ~ c*milk
             IL1B ~ e*milk
             CRP ~ g*milk             
             BMSi ~ b*IL6
             BMSi ~ d*TNFa
             BMSi ~ f*IL1B
             BMSi~ h*CRP
           # indirect effect (a*b)
             ab := a*b
             cd := c*d
             ef := e*f
             gh :=g*h
           # total effect
             total := i + (a*b) +(c*d) +(e*f) +(g*h)
         '
fit <- sem(model_milk, data = db)
summary(fit)
## lavaan 0.6-18 ended normally after 1 iteration
## 
##   Estimator                                         ML
##   Optimization method                           NLMINB
##   Number of model parameters                        14
## 
##                                                   Used       Total
##   Number of observations                           151         163
## 
## Model Test User Model:
##                                                       
##   Test statistic                                 8.559
##   Degrees of freedom                                 6
##   P-value (Chi-square)                           0.200
## 
## Parameter Estimates:
## 
##   Standard errors                             Standard
##   Information                                 Expected
##   Information saturated (h1) model          Structured
## 
## Regressions:
##                    Estimate  Std.Err  z-value  P(>|z|)
##   BMSi ~                                              
##     milk       (i)    0.958    0.852    1.125    0.261
##   IL6 ~                                               
##     milk       (a)   -0.588    0.474   -1.241    0.215
##   TNFa ~                                              
##     milk       (c)    0.682    0.743    0.919    0.358
##   IL1B ~                                              
##     milk       (e)   -1.824    2.794   -0.653    0.514
##   CRP ~                                               
##     milk       (g)   -1.618    0.658   -2.458    0.014
##   BMSi ~                                              
##     IL6        (b)   -0.120    0.142   -0.847    0.397
##     TNFa       (d)   -0.029    0.091   -0.319    0.750
##     IL1B       (f)   -0.019    0.024   -0.768    0.442
##     CRP        (h)   -0.079    0.102   -0.774    0.439
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|)
##    .BMSi             64.811    7.459    8.689    0.000
##    .IL6              21.222    2.442    8.689    0.000
##    .TNFa             52.186    6.006    8.689    0.000
##    .IL1B            738.733   85.019    8.689    0.000
##    .CRP              40.972    4.715    8.689    0.000
## 
## Defined Parameters:
##                    Estimate  Std.Err  z-value  P(>|z|)
##     ab                0.071    0.101    0.699    0.484
##     cd               -0.020    0.066   -0.301    0.763
##     ef                0.034    0.068    0.497    0.619
##     gh                0.128    0.174    0.739    0.460
##     total             1.171    0.833    1.405    0.160
semPaths(fit)

Fluid dairy

model_fluid <- ' # direct effect
             BMSi ~ i*fluid
           # mediator
             IL6 ~ a*fluid
             TNFa ~ c*fluid
             IL1B ~ e*fluid
             CRP ~ g*fluid             
             BMSi ~ b*IL6
             BMSi ~ d*TNFa
             BMSi ~ f*IL1B
             BMSi~ h*CRP
           # indirect effect (a*b)
             ab := a*b
             cd := c*d
             ef := e*f
             gh :=g*h
           # total effect
             total := i + (a*b) +(c*d) +(e*f) +(g*h)
         '
fit <- sem(model_fluid, data = db)
summary(fit)
## lavaan 0.6-18 ended normally after 1 iteration
## 
##   Estimator                                         ML
##   Optimization method                           NLMINB
##   Number of model parameters                        14
## 
##                                                   Used       Total
##   Number of observations                           151         163
## 
## Model Test User Model:
##                                                       
##   Test statistic                                 8.524
##   Degrees of freedom                                 6
##   P-value (Chi-square)                           0.202
## 
## Parameter Estimates:
## 
##   Standard errors                             Standard
##   Information                                 Expected
##   Information saturated (h1) model          Structured
## 
## Regressions:
##                    Estimate  Std.Err  z-value  P(>|z|)
##   BMSi ~                                              
##     fluid      (i)    0.871    0.800    1.089    0.276
##   IL6 ~                                               
##     fluid      (a)   -0.509    0.446   -1.142    0.253
##   TNFa ~                                              
##     fluid      (c)    0.655    0.698    0.938    0.348
##   IL1B ~                                              
##     fluid      (e)   -1.745    2.628   -0.664    0.507
##   CRP ~                                               
##     fluid      (g)   -1.470    0.620   -2.371    0.018
##   BMSi ~                                              
##     IL6        (b)   -0.122    0.142   -0.860    0.390
##     TNFa       (d)   -0.029    0.091   -0.316    0.752
##     IL1B       (f)   -0.019    0.024   -0.770    0.442
##     CRP        (h)   -0.081    0.102   -0.790    0.430
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|)
##    .BMSi             64.845    7.463    8.689    0.000
##    .IL6              21.255    2.446    8.689    0.000
##    .TNFa             52.173    6.004    8.689    0.000
##    .IL1B            738.660   85.010    8.689    0.000
##    .CRP              41.082    4.728    8.689    0.000
## 
## Defined Parameters:
##                    Estimate  Std.Err  z-value  P(>|z|)
##     ab                0.062    0.091    0.687    0.492
##     cd               -0.019    0.063   -0.299    0.765
##     ef                0.032    0.064    0.503    0.615
##     gh                0.119    0.158    0.749    0.454
##     total             1.066    0.784    1.359    0.174
semPaths(fit)

Total dairy

model_total <- ' # direct effect
              BMSi ~ i*mod
           # mediator
             IL6 ~ a*mod
             TNFa ~ c*mod
             IL1B ~ e*mod
             CRP ~ g*mod             
             BMSi ~ b*IL6
             BMSi ~ d*TNFa
             BMSi ~ f*IL1B
             BMSi~ h*CRP
           # indirect effect (a*b)
             ab := a*b
             cd := c*d
             ef := e*f
             gh :=g*h
           # total effect
             total := i + (a*b) +(c*d) +(e*f) +(g*h)
          '
fit <- sem(model_total, data = db)
summary(fit,  fit.measures=TRUE, standardized=TRUE)
## lavaan 0.6-18 ended normally after 1 iteration
## 
##   Estimator                                         ML
##   Optimization method                           NLMINB
##   Number of model parameters                        14
## 
##                                                   Used       Total
##   Number of observations                           151         163
## 
## Model Test User Model:
##                                                       
##   Test statistic                                 8.443
##   Degrees of freedom                                 6
##   P-value (Chi-square)                           0.207
## 
## Model Test Baseline Model:
## 
##   Test statistic                                21.448
##   Degrees of freedom                                15
##   P-value                                        0.123
## 
## User Model versus Baseline Model:
## 
##   Comparative Fit Index (CFI)                    0.621
##   Tucker-Lewis Index (TLI)                       0.053
## 
## Loglikelihood and Information Criteria:
## 
##   Loglikelihood user model (H0)              -2694.331
##   Loglikelihood unrestricted model (H1)      -2690.110
##                                                       
##   Akaike (AIC)                                5416.662
##   Bayesian (BIC)                              5458.904
##   Sample-size adjusted Bayesian (SABIC)       5414.596
## 
## Root Mean Square Error of Approximation:
## 
##   RMSEA                                          0.052
##   90 Percent confidence interval - lower         0.000
##   90 Percent confidence interval - upper         0.126
##   P-value H_0: RMSEA <= 0.050                    0.414
##   P-value H_0: RMSEA >= 0.080                    0.322
## 
## Standardized Root Mean Square Residual:
## 
##   SRMR                                           0.050
## 
## Parameter Estimates:
## 
##   Standard errors                             Standard
##   Information                                 Expected
##   Information saturated (h1) model          Structured
## 
## Regressions:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##   BMSi ~                                                                
##     mod        (i)    1.110    0.797    1.393    0.164    1.110    0.115
##   IL6 ~                                                                 
##     mod        (a)   -0.424    0.446   -0.951    0.341   -0.424   -0.077
##   TNFa ~                                                                
##     mod        (c)    0.407    0.698    0.583    0.560    0.407    0.047
##   IL1B ~                                                                
##     mod        (e)   -1.858    2.622   -0.708    0.479   -1.858   -0.058
##   CRP ~                                                                 
##     mod        (g)   -1.603    0.616   -2.602    0.009   -1.603   -0.207
##   BMSi ~                                                                
##     IL6        (b)   -0.122    0.142   -0.864    0.388   -0.122   -0.069
##     TNFa       (d)   -0.027    0.090   -0.295    0.768   -0.027   -0.024
##     IL1B       (f)   -0.018    0.024   -0.740    0.459   -0.018   -0.059
##     CRP        (h)   -0.072    0.102   -0.703    0.482   -0.072   -0.058
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##    .BMSi             64.525    7.426    8.689    0.000   64.525    0.970
##    .IL6              21.311    2.453    8.689    0.000   21.311    0.994
##    .TNFa             52.360    6.026    8.689    0.000   52.360    0.998
##    .IL1B            738.363   84.976    8.689    0.000  738.363    0.997
##    .CRP              40.784    4.694    8.689    0.000   40.784    0.957
## 
## Defined Parameters:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##     ab                0.052    0.081    0.640    0.522    0.052    0.005
##     cd               -0.011    0.041   -0.263    0.792   -0.011   -0.001
##     ef                0.033    0.065    0.512    0.609    0.033    0.003
##     gh                0.115    0.170    0.679    0.497    0.115    0.012
##     total             1.300    0.780    1.666    0.096    1.300    0.134
semPaths(fit)

Adjusted milk as predictor, BMSi as response; IL6, TNFa, IL1B, CRP as individual mediators

model_milk_adj <- ' # direct effect
             BMSi ~ i*milk + age_final + female_b2 + PA_SCORE_b2 + vitd_top + BMI_b2 + alcohol_freq_8yr
           # mediator
             IL6 ~ a*milk + diabetes_bone2
             TNFa ~ c*milk + diabetes_bone2
             IL1B ~ e*milk + diabetes_bone2
             CRP ~ g*milk + diabetes_bone2
             BMSi ~ b*IL6 
             BMSi ~ d*TNFa 
             BMSi ~ f*IL1B
             BMSi ~ h*CRP
           # indirect effect (a*b)
             ab := a*b
             cd := c*d
             ef := e*f
             gh := g*h
           # total effect
             total := i + (a*b) +(c*d) +(e*f) +(g*h)
         '
fit_milk_adj <- sem(model_milk_adj, data = db)
summary(fit_milk_adj, fit.measures=TRUE, standardized=TRUE, ci=TRUE)
## lavaan 0.6-18 ended normally after 1 iteration
## 
##   Estimator                                         ML
##   Optimization method                           NLMINB
##   Number of model parameters                        24
## 
##                                                   Used       Total
##   Number of observations                           135         163
## 
## Model Test User Model:
##                                                       
##   Test statistic                                58.634
##   Degrees of freedom                                31
##   P-value (Chi-square)                           0.002
## 
## Model Test Baseline Model:
## 
##   Test statistic                                85.289
##   Degrees of freedom                                50
##   P-value                                        0.001
## 
## User Model versus Baseline Model:
## 
##   Comparative Fit Index (CFI)                    0.217
##   Tucker-Lewis Index (TLI)                      -0.263
## 
## Loglikelihood and Information Criteria:
## 
##   Loglikelihood user model (H0)              -2418.221
##   Loglikelihood unrestricted model (H1)      -2388.904
##                                                       
##   Akaike (AIC)                                4884.442
##   Bayesian (BIC)                              4954.169
##   Sample-size adjusted Bayesian (SABIC)       4878.249
## 
## Root Mean Square Error of Approximation:
## 
##   RMSEA                                          0.081
##   90 Percent confidence interval - lower         0.048
##   90 Percent confidence interval - upper         0.113
##   P-value H_0: RMSEA <= 0.050                    0.057
##   P-value H_0: RMSEA >= 0.080                    0.553
## 
## Standardized Root Mean Square Residual:
## 
##   SRMR                                           0.067
## 
## Parameter Estimates:
## 
##   Standard errors                             Standard
##   Information                                 Expected
##   Information saturated (h1) model          Structured
## 
## Regressions:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower ci.upper
##   BMSi ~                                                                
##     milk       (i)    1.854    0.925    2.005    0.045    0.042    3.667
##     age_final        -0.193    0.108   -1.794    0.073   -0.404    0.018
##     female_b2        -0.056    1.603   -0.035    0.972   -3.197    3.086
##     PA_SCORE_2        0.173    0.118    1.468    0.142   -0.058    0.404
##     vitd_top         -0.072    0.124   -0.578    0.564   -0.316    0.172
##     BMI_b2           -0.274    0.125   -2.190    0.029   -0.520   -0.029
##     alchl_fr_8       -0.154    1.272   -0.121    0.904   -2.646    2.339
##   IL6 ~                                                                 
##     milk       (a)   -0.613    0.522   -1.174    0.240   -1.636    0.410
##     diabts_bn2       -0.430    0.834   -0.515    0.606   -2.065    1.206
##   TNFa ~                                                                
##     milk       (c)    0.770    0.794    0.970    0.332   -0.787    2.327
##     diabts_bn2        1.568    1.270    1.234    0.217   -0.922    4.057
##   IL1B ~                                                                
##     milk       (e)   -1.630    2.986   -0.546    0.585   -7.482    4.223
##     diabts_bn2       -5.674    4.774   -1.189    0.235  -15.031    3.683
##   CRP ~                                                                 
##     milk       (g)   -1.569    0.702   -2.234    0.025   -2.945   -0.192
##     diabts_bn2        1.145    1.123    1.020    0.308   -1.055    3.345
##   BMSi ~                                                                
##     IL6        (b)   -0.165    0.138   -1.191    0.234   -0.435    0.106
##     TNFa       (d)   -0.056    0.090   -0.623    0.533   -0.234    0.121
##     IL1B       (f)   -0.027    0.024   -1.130    0.259   -0.074    0.020
##     CRP        (h)   -0.003    0.102   -0.031    0.975   -0.204    0.198
##    Std.lv  Std.all
##                   
##     1.854    0.179
##    -0.193   -0.154
##    -0.056   -0.003
##     0.173    0.124
##    -0.072   -0.049
##    -0.274   -0.188
##    -0.154   -0.010
##                   
##    -0.613   -0.101
##    -0.430   -0.044
##                   
##     0.770    0.083
##     1.568    0.105
##                   
##    -1.630   -0.047
##    -5.674   -0.102
##                   
##    -1.569   -0.188
##     1.145    0.086
##                   
##    -0.165   -0.097
##    -0.056   -0.051
##    -0.027   -0.092
##    -0.003   -0.003
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower ci.upper
##    .BMSi             60.451    7.358    8.216    0.000   46.030   74.872
##    .IL6              23.406    2.849    8.216    0.000   17.822   28.990
##    .TNFa             54.234    6.601    8.216    0.000   41.296   67.172
##    .IL1B            766.231   93.263    8.216    0.000  583.440  949.022
##    .CRP              42.373    5.157    8.216    0.000   32.264   52.481
##    Std.lv  Std.all
##    60.451    0.889
##    23.406    0.988
##    54.234    0.983
##   766.231    0.988
##    42.373    0.956
## 
## Defined Parameters:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower ci.upper
##     ab                0.101    0.121    0.836    0.403   -0.136    0.337
##     cd               -0.043    0.083   -0.524    0.600   -0.206    0.119
##     ef                0.044    0.090    0.491    0.623   -0.132    0.221
##     gh                0.005    0.161    0.031    0.975   -0.310    0.320
##     total             1.961    0.912    2.150    0.032    0.174    3.748
##    Std.lv  Std.all
##     0.101    0.010
##    -0.043   -0.004
##     0.044    0.004
##     0.005    0.000
##     1.961    0.190
semPaths(fit_milk_adj)

Adjusted milk with log tranformed mediators(without this tranformation, the variances are extremely high)

model_milk_adj_log <- ' # direct effect
             BMSi ~ i*milk + age_final + female_b2 + PA_SCORE_b2 + vitd_top + BMI_b2 + alcohol_freq_8yr
           # mediator
             log_IL6 ~ a*milk + diabetes_bone2
             log_tnf ~ c*milk + diabetes_bone2
             log_il1B ~ e*milk + diabetes_bone2
             log_crp ~ g*milk + diabetes_bone2
             BMSi ~ b*log_IL6 
             BMSi ~ d*log_tnf
             BMSi ~ f*log_il1B
             BMSi ~ h*log_crp
           # indirect effect (a*b)
             ab := a*b
             cd := c*d
             ef := e*f
             gh := g*h
           # total effect
             total := i + (a*b) +(c*d) +(e*f) +(g*h)
         '
fit_milk_adj_log <- sem(model_milk_adj_log, data = db)
summary(fit_milk_adj_log, fit.measures=TRUE, standardized=TRUE, ci=TRUE)
## lavaan 0.6-18 ended normally after 1 iteration
## 
##   Estimator                                         ML
##   Optimization method                           NLMINB
##   Number of model parameters                        24
## 
##                                                   Used       Total
##   Number of observations                           135         163
## 
## Model Test User Model:
##                                                       
##   Test statistic                                53.804
##   Degrees of freedom                                31
##   P-value (Chi-square)                           0.007
## 
## Model Test Baseline Model:
## 
##   Test statistic                                89.444
##   Degrees of freedom                                50
##   P-value                                        0.001
## 
## User Model versus Baseline Model:
## 
##   Comparative Fit Index (CFI)                    0.422
##   Tucker-Lewis Index (TLI)                       0.068
## 
## Loglikelihood and Information Criteria:
## 
##   Loglikelihood user model (H0)              -1158.566
##   Loglikelihood unrestricted model (H1)      -1131.664
##                                                       
##   Akaike (AIC)                                2365.133
##   Bayesian (BIC)                              2434.859
##   Sample-size adjusted Bayesian (SABIC)       2358.939
## 
## Root Mean Square Error of Approximation:
## 
##   RMSEA                                          0.074
##   90 Percent confidence interval - lower         0.039
##   90 Percent confidence interval - upper         0.106
##   P-value H_0: RMSEA <= 0.050                    0.117
##   P-value H_0: RMSEA >= 0.080                    0.404
## 
## Standardized Root Mean Square Residual:
## 
##   SRMR                                           0.068
## 
## Parameter Estimates:
## 
##   Standard errors                             Standard
##   Information                                 Expected
##   Information saturated (h1) model          Structured
## 
## Regressions:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower ci.upper
##   BMSi ~                                                                
##     milk       (i)    1.811    0.911    1.988    0.047    0.025    3.596
##     age_final        -0.216    0.105   -2.048    0.041   -0.422   -0.009
##     female_b2         0.260    1.566    0.166    0.868   -2.810    3.330
##     PA_SCORE_2        0.209    0.115    1.818    0.069   -0.016    0.435
##     vitd_top         -0.055    0.122   -0.454    0.650   -0.293    0.183
##     BMI_b2           -0.317    0.122   -2.590    0.010   -0.557   -0.077
##     alchl_fr_8       -0.532    1.243   -0.428    0.668   -2.968    1.903
##   log_IL6 ~                                                             
##     milk       (a)   -0.158    0.100   -1.584    0.113   -0.354    0.038
##     diabts_bn2       -0.066    0.160   -0.416    0.678   -0.379    0.246
##   log_tnf ~                                                             
##     milk       (c)    0.061    0.056    1.092    0.275   -0.049    0.171
##     diabts_bn2        0.151    0.090    1.688    0.091   -0.024    0.327
##   log_il1B ~                                                            
##     milk       (e)   -0.145    0.100   -1.447    0.148   -0.341    0.051
##     diabts_bn2       -0.187    0.160   -1.168    0.243   -0.501    0.127
##   log_crp ~                                                             
##     milk       (g)   -0.304    0.141   -2.159    0.031   -0.580   -0.028
##     diabts_bn2        0.035    0.225    0.154    0.877   -0.407    0.476
##   BMSi ~                                                                
##     log_IL6    (b)   -1.630    0.706   -2.308    0.021   -3.014   -0.246
##     log_tnf    (d)   -1.040    1.246   -0.835    0.404   -3.483    1.402
##     log_il1B   (f)   -1.136    0.701   -1.619    0.105   -2.511    0.239
##     log_crp    (h)    0.828    0.501    1.652    0.098   -0.154    1.809
##    Std.lv  Std.all
##                   
##     1.811    0.172
##    -0.216   -0.169
##     0.260    0.014
##     0.209    0.147
##    -0.055   -0.037
##    -0.317   -0.214
##    -0.532   -0.035
##                   
##    -0.158   -0.135
##    -0.066   -0.035
##                   
##     0.061    0.093
##     0.151    0.143
##                   
##    -0.145   -0.123
##    -0.187   -0.099
##                   
##    -0.304   -0.183
##     0.035    0.013
##                   
##    -1.630   -0.182
##    -1.040   -0.065
##    -1.136   -0.127
##     0.828    0.131
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower ci.upper
##    .BMSi             57.719    7.025    8.216    0.000   43.950   71.489
##    .log_IL6           0.856    0.104    8.216    0.000    0.652    1.060
##    .log_tnf           0.270    0.033    8.216    0.000    0.206    0.335
##    .log_il1B          0.861    0.105    8.216    0.000    0.656    1.066
##    .log_crp           1.704    0.207    8.216    0.000    1.297    2.110
##    Std.lv  Std.all
##    57.719    0.821
##     0.856    0.981
##     0.270    0.972
##     0.861    0.976
##     1.704    0.966
## 
## Defined Parameters:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower ci.upper
##     ab                0.258    0.197    1.306    0.192   -0.129    0.644
##     cd               -0.064    0.096   -0.663    0.507   -0.252    0.125
##     ef                0.164    0.152    1.079    0.281   -0.134    0.463
##     gh               -0.252    0.192   -1.312    0.189   -0.628    0.124
##     total             1.918    0.914    2.098    0.036    0.126    3.709
##    Std.lv  Std.all
##     0.258    0.025
##    -0.064   -0.006
##     0.164    0.016
##    -0.252   -0.024
##     1.918    0.183
semPaths(fit_milk_adj_log)

Fluid dairy adjusted

model_fluid_adj <- ' # direct effect
             BMSi ~ i*fluid + age_final + female_b2 + PA_SCORE_b2 + vitd_top + BMI_b2 + alcohol_freq_8yr
           # mediator
             IL6 ~ a*fluid + diabetes_bone2
             TNFa ~ c*fluid + diabetes_bone2
             IL1B ~ e*fluid + diabetes_bone2
             CRP ~ g*fluid + diabetes_bone2
             BMSi ~ b*IL6 
             BMSi ~ d*TNFa 
             BMSi ~ f*IL1B
             BMSi ~ h*CRP
           # indirect effect (a*b)
             ab := a*b
             cd := c*d
             ef := e*f
             gh := g*h
           # total effect
             total := i + (a*b) +(c*d) +(e*f) +(g*h)
         '
fit_fluid_adj <- sem(model_fluid_adj, data = db)
summary(fit_fluid_adj, fit.measures=TRUE, standardized=TRUE, ci=TRUE)
## lavaan 0.6-18 ended normally after 1 iteration
## 
##   Estimator                                         ML
##   Optimization method                           NLMINB
##   Number of model parameters                        24
## 
##                                                   Used       Total
##   Number of observations                           135         163
## 
## Model Test User Model:
##                                                       
##   Test statistic                                58.940
##   Degrees of freedom                                31
##   P-value (Chi-square)                           0.002
## 
## Model Test Baseline Model:
## 
##   Test statistic                                85.243
##   Degrees of freedom                                50
##   P-value                                        0.001
## 
## User Model versus Baseline Model:
## 
##   Comparative Fit Index (CFI)                    0.207
##   Tucker-Lewis Index (TLI)                      -0.279
## 
## Loglikelihood and Information Criteria:
## 
##   Loglikelihood user model (H0)              -2418.397
##   Loglikelihood unrestricted model (H1)      -2388.927
##                                                       
##   Akaike (AIC)                                4884.794
##   Bayesian (BIC)                              4954.521
##   Sample-size adjusted Bayesian (SABIC)       4878.601
## 
## Root Mean Square Error of Approximation:
## 
##   RMSEA                                          0.082
##   90 Percent confidence interval - lower         0.049
##   90 Percent confidence interval - upper         0.113
##   P-value H_0: RMSEA <= 0.050                    0.055
##   P-value H_0: RMSEA >= 0.080                    0.562
## 
## Standardized Root Mean Square Residual:
## 
##   SRMR                                           0.067
## 
## Parameter Estimates:
## 
##   Standard errors                             Standard
##   Information                                 Expected
##   Information saturated (h1) model          Structured
## 
## Regressions:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower ci.upper
##   BMSi ~                                                                
##     fluid      (i)    1.733    0.872    1.988    0.047    0.024    3.442
##     age_final        -0.196    0.108   -1.817    0.069   -0.408    0.015
##     female_b2        -0.154    1.609   -0.096    0.924   -3.307    2.998
##     PA_SCORE_2        0.170    0.118    1.445    0.148   -0.061    0.401
##     vitd_top         -0.075    0.125   -0.598    0.550   -0.319    0.170
##     BMI_b2           -0.278    0.125   -2.222    0.026   -0.524   -0.033
##     alchl_fr_8       -0.135    1.274   -0.106    0.915   -2.633    2.362
##   IL6 ~                                                                 
##     fluid      (a)   -0.546    0.489   -1.118    0.264   -1.504    0.412
##     diabts_bn2       -0.443    0.835   -0.530    0.596   -2.080    1.195
##   TNFa ~                                                                
##     fluid      (c)    0.777    0.743    1.045    0.296   -0.680    2.233
##     diabts_bn2        1.591    1.270    1.253    0.210   -0.898    4.081
##   IL1B ~                                                                
##     fluid      (e)   -1.519    2.795   -0.543    0.587   -6.996    3.959
##     diabts_bn2       -5.714    4.777   -1.196    0.232  -15.077    3.649
##   CRP ~                                                                 
##     fluid      (g)   -1.424    0.658   -2.165    0.030   -2.714   -0.135
##     diabts_bn2        1.110    1.125    0.987    0.324   -1.094    3.314
##   BMSi ~                                                                
##     IL6        (b)   -0.166    0.138   -1.199    0.230   -0.437    0.105
##     TNFa       (d)   -0.057    0.090   -0.635    0.526   -0.235    0.120
##     IL1B       (f)   -0.028    0.024   -1.143    0.253   -0.075    0.020
##     CRP        (h)   -0.004    0.102   -0.035    0.972   -0.204    0.197
##    Std.lv  Std.all
##                   
##     1.733    0.179
##    -0.196   -0.157
##    -0.154   -0.008
##     0.170    0.122
##    -0.075   -0.051
##    -0.278   -0.191
##    -0.135   -0.009
##                   
##    -0.546   -0.096
##    -0.443   -0.045
##                   
##     0.777    0.089
##     1.591    0.107
##                   
##    -1.519   -0.047
##    -5.714   -0.102
##                   
##    -1.424   -0.183
##     1.110    0.083
##                   
##    -0.166   -0.098
##    -0.057   -0.052
##    -0.028   -0.093
##    -0.004   -0.003
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower ci.upper
##    .BMSi             60.485    7.362    8.216    0.000   46.056   74.915
##    .IL6              23.428    2.852    8.216    0.000   17.839   29.017
##    .TNFa             54.173    6.594    8.216    0.000   41.250   67.097
##    .IL1B            766.246   93.264    8.216    0.000  583.451  949.041
##    .CRP              42.465    5.169    8.216    0.000   32.335   52.596
##    Std.lv  Std.all
##    60.485    0.889
##    23.428    0.989
##    54.173    0.982
##   766.246    0.988
##    42.465    0.958
## 
## Defined Parameters:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower ci.upper
##     ab                0.090    0.111    0.818    0.414   -0.126    0.307
##     cd               -0.045    0.082   -0.542    0.587   -0.206    0.117
##     ef                0.042    0.085    0.491    0.624   -0.125    0.209
##     gh                0.005    0.146    0.035    0.972   -0.281    0.291
##     total             1.826    0.861    2.121    0.034    0.139    3.514
##    Std.lv  Std.all
##     0.090    0.009
##    -0.045   -0.005
##     0.042    0.004
##     0.005    0.001
##     1.826    0.189
semPaths(fit_fluid_adj)

Fluid dairy adjusted w/ log transformed mediators

model_fluid_adj_log <- ' # direct effect
             BMSi ~ i*fluid + age_final + female_b2 + PA_SCORE_b2 + vitd_top + BMI_b2 + alcohol_freq_8yr
           # mediator
             log_IL6 ~ a*fluid + diabetes_bone2
             log_tnf ~ c*fluid + diabetes_bone2
             log_il1B ~ e*fluid + diabetes_bone2
             log_crp ~ g*fluid + diabetes_bone2
             BMSi ~ b*log_IL6 
             BMSi ~ d*log_tnf
             BMSi ~ f*log_il1B
             BMSi ~ h*log_crp
           # indirect effect (a*b)
             ab := a*b
             cd := c*d
             ef := e*f
             gh := g*h
           # total effect
             total := i + (a*b) +(c*d) +(e*f) +(g*h)
         '
fit_fluid_adj_log <- sem(model_fluid_adj_log, data = db)
summary(fit_fluid_adj_log, fit.measures=TRUE, standardized=TRUE, ci=TRUE)
## lavaan 0.6-18 ended normally after 1 iteration
## 
##   Estimator                                         ML
##   Optimization method                           NLMINB
##   Number of model parameters                        24
## 
##                                                   Used       Total
##   Number of observations                           135         163
## 
## Model Test User Model:
##                                                       
##   Test statistic                                54.397
##   Degrees of freedom                                31
##   P-value (Chi-square)                           0.006
## 
## Model Test Baseline Model:
## 
##   Test statistic                                89.182
##   Degrees of freedom                                50
##   P-value                                        0.001
## 
## User Model versus Baseline Model:
## 
##   Comparative Fit Index (CFI)                    0.403
##   Tucker-Lewis Index (TLI)                       0.037
## 
## Loglikelihood and Information Criteria:
## 
##   Loglikelihood user model (H0)              -1158.994
##   Loglikelihood unrestricted model (H1)      -1131.795
##                                                       
##   Akaike (AIC)                                2365.988
##   Bayesian (BIC)                              2435.714
##   Sample-size adjusted Bayesian (SABIC)       2359.794
## 
## Root Mean Square Error of Approximation:
## 
##   RMSEA                                          0.075
##   90 Percent confidence interval - lower         0.040
##   90 Percent confidence interval - upper         0.107
##   P-value H_0: RMSEA <= 0.050                    0.108
##   P-value H_0: RMSEA >= 0.080                    0.422
## 
## Standardized Root Mean Square Residual:
## 
##   SRMR                                           0.069
## 
## Parameter Estimates:
## 
##   Standard errors                             Standard
##   Information                                 Expected
##   Information saturated (h1) model          Structured
## 
## Regressions:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower ci.upper
##   BMSi ~                                                                
##     fluid      (i)    1.730    0.856    2.021    0.043    0.052    3.407
##     age_final        -0.220    0.105   -2.084    0.037   -0.426   -0.013
##     female_b2         0.158    1.571    0.100    0.920   -2.921    3.237
##     PA_SCORE_2        0.207    0.115    1.804    0.071   -0.018    0.432
##     vitd_top         -0.059    0.122   -0.482    0.630   -0.297    0.180
##     BMI_b2           -0.321    0.122   -2.628    0.009   -0.561   -0.082
##     alchl_fr_8       -0.505    1.244   -0.406    0.685   -2.943    1.934
##   log_IL6 ~                                                             
##     fluid      (a)   -0.130    0.094   -1.391    0.164   -0.314    0.053
##     diabts_bn2       -0.069    0.160   -0.429    0.668   -0.382    0.245
##   log_tnf ~                                                             
##     fluid      (c)    0.064    0.052    1.226    0.220   -0.038    0.167
##     diabts_bn2        0.153    0.090    1.712    0.087   -0.022    0.329
##   log_il1B ~                                                            
##     fluid      (e)   -0.122    0.094   -1.303    0.193   -0.306    0.062
##     diabts_bn2       -0.189    0.160   -1.181    0.238   -0.504    0.125
##   log_crp ~                                                             
##     fluid      (g)   -0.275    0.132   -2.082    0.037   -0.533   -0.016
##     diabts_bn2        0.028    0.226    0.124    0.901   -0.414    0.470
##   BMSi ~                                                                
##     log_IL6    (b)   -1.641    0.704   -2.330    0.020   -3.022   -0.261
##     log_tnf    (d)   -1.072    1.247   -0.860    0.390   -3.516    1.372
##     log_il1B   (f)   -1.163    0.700   -1.661    0.097   -2.535    0.209
##     log_crp    (h)    0.832    0.500    1.664    0.096   -0.148    1.813
##    Std.lv  Std.all
##                   
##     1.730    0.176
##    -0.220   -0.172
##     0.158    0.008
##     0.207    0.146
##    -0.059   -0.040
##    -0.321   -0.217
##    -0.505   -0.033
##                   
##    -0.130   -0.119
##    -0.069   -0.037
##                   
##     0.064    0.104
##     0.153    0.145
##                   
##    -0.122   -0.111
##    -0.189   -0.101
##                   
##    -0.275   -0.177
##     0.028    0.011
##                   
##    -1.641   -0.183
##    -1.072   -0.067
##    -1.163   -0.130
##     0.832    0.132
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower ci.upper
##    .BMSi             57.673    7.020    8.216    0.000   43.914   71.431
##    .log_IL6           0.860    0.105    8.216    0.000    0.655    1.065
##    .log_tnf           0.269    0.033    8.216    0.000    0.205    0.334
##    .log_il1B          0.864    0.105    8.216    0.000    0.658    1.070
##    .log_crp           1.708    0.208    8.216    0.000    1.300    2.115
##    Std.lv  Std.all
##    57.673    0.820
##     0.860    0.985
##     0.269    0.970
##     0.864    0.979
##     1.708    0.969
## 
## Defined Parameters:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower ci.upper
##     ab                0.214    0.179    1.194    0.232   -0.137    0.565
##     cd               -0.069    0.098   -0.704    0.481   -0.261    0.123
##     ef                0.142    0.139    1.025    0.305   -0.130    0.414
##     gh               -0.229    0.176   -1.300    0.194   -0.573    0.116
##     total             1.788    0.863    2.073    0.038    0.098    3.479
##    Std.lv  Std.all
##     0.214    0.022
##    -0.069   -0.007
##     0.142    0.014
##    -0.229   -0.023
##     1.788    0.182
semPaths(fit_fluid_adj_log)

Total dairy adjusted

model_total_adj <- ' # direct effect
             BMSi ~ i*mod + age_final + female_b2 + PA_SCORE_b2 + vitd_top + BMI_b2 + alcohol_freq_8yr
           # mediator
             IL6 ~ a*mod + diabetes_bone2
             TNFa ~ c*mod + diabetes_bone2
             IL1B ~ e*mod + diabetes_bone2
             CRP ~ g*mod + diabetes_bone2
             BMSi ~ b*IL6 
             BMSi ~ d*TNFa 
             BMSi ~ f*IL1B
             BMSi ~ h*CRP
           # indirect effect (a*b)
             ab := a*b
             cd := c*d
             ef := e*f
             gh := g*h
           # total effect
             total := i + (a*b) +(c*d) +(e*f) +(g*h)
         '
fit_total_adj <- sem(model_total_adj, data = db)
summary(fit_total_adj,fit.measures=TRUE, standardized=TRUE, ci=TRUE)
## lavaan 0.6-18 ended normally after 1 iteration
## 
##   Estimator                                         ML
##   Optimization method                           NLMINB
##   Number of model parameters                        24
## 
##                                                   Used       Total
##   Number of observations                           135         163
## 
## Model Test User Model:
##                                                       
##   Test statistic                                57.896
##   Degrees of freedom                                31
##   P-value (Chi-square)                           0.002
## 
## Model Test Baseline Model:
## 
##   Test statistic                                84.737
##   Degrees of freedom                                50
##   P-value                                        0.002
## 
## User Model versus Baseline Model:
## 
##   Comparative Fit Index (CFI)                    0.226
##   Tucker-Lewis Index (TLI)                      -0.249
## 
## Loglikelihood and Information Criteria:
## 
##   Loglikelihood user model (H0)              -2418.128
##   Loglikelihood unrestricted model (H1)      -2389.180
##                                                       
##   Akaike (AIC)                                4884.256
##   Bayesian (BIC)                              4953.983
##   Sample-size adjusted Bayesian (SABIC)       4878.062
## 
## Root Mean Square Error of Approximation:
## 
##   RMSEA                                          0.080
##   90 Percent confidence interval - lower         0.047
##   90 Percent confidence interval - upper         0.112
##   P-value H_0: RMSEA <= 0.050                    0.064
##   P-value H_0: RMSEA >= 0.080                    0.530
## 
## Standardized Root Mean Square Residual:
## 
##   SRMR                                           0.066
## 
## Parameter Estimates:
## 
##   Standard errors                             Standard
##   Information                                 Expected
##   Information saturated (h1) model          Structured
## 
## Regressions:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower ci.upper
##   BMSi ~                                                                
##     mod        (i)    1.817    0.885    2.052    0.040    0.081    3.552
##     age_final        -0.189    0.107   -1.767    0.077   -0.400    0.021
##     female_b2        -0.232    1.612   -0.144    0.886   -3.391    2.928
##     PA_SCORE_2        0.162    0.117    1.382    0.167   -0.068    0.391
##     vitd_top         -0.087    0.126   -0.693    0.488   -0.333    0.159
##     BMI_b2           -0.270    0.125   -2.154    0.031   -0.515   -0.024
##     alchl_fr_8       -0.082    1.276   -0.064    0.949   -2.584    2.420
##   IL6 ~                                                                 
##     mod        (a)   -0.473    0.493   -0.959    0.337   -1.440    0.494
##     diabts_bn2       -0.441    0.837   -0.527    0.598   -2.081    1.199
##   TNFa ~                                                                
##     mod        (c)    0.535    0.751    0.712    0.476   -0.937    2.006
##     diabts_bn2        1.576    1.273    1.237    0.216   -0.920    4.071
##   IL1B ~                                                                
##     mod        (e)   -1.622    2.817   -0.576    0.565   -7.144    3.899
##     diabts_bn2       -5.738    4.778   -1.201    0.230  -15.102    3.627
##   CRP ~                                                                 
##     mod        (g)   -1.599    0.661   -2.421    0.015   -2.894   -0.305
##     diabts_bn2        1.080    1.120    0.964    0.335   -1.115    3.276
##   BMSi ~                                                                
##     IL6        (b)   -0.171    0.138   -1.238    0.216   -0.441    0.099
##     TNFa       (d)   -0.052    0.090   -0.573    0.566   -0.228    0.125
##     IL1B       (f)   -0.027    0.024   -1.114    0.265   -0.074    0.020
##     CRP        (h)   -0.002    0.103   -0.017    0.986   -0.203    0.200
##    Std.lv  Std.all
##                   
##     1.817    0.187
##    -0.189   -0.151
##    -0.232   -0.012
##     0.162    0.116
##    -0.087   -0.060
##    -0.270   -0.185
##    -0.082   -0.005
##                   
##    -0.473   -0.082
##    -0.441   -0.045
##                   
##     0.535    0.061
##     1.576    0.106
##                   
##    -1.622   -0.049
##    -5.738   -0.103
##                   
##    -1.599   -0.203
##     1.080    0.081
##                   
##    -0.171   -0.101
##    -0.052   -0.047
##    -0.027   -0.090
##    -0.002   -0.001
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower ci.upper
##    .BMSi             60.362    7.347    8.216    0.000   45.962   74.761
##    .IL6              23.485    2.858    8.216    0.000   17.882   29.088
##    .TNFa             54.407    6.622    8.216    0.000   41.428   67.386
##    .IL1B            766.040   93.239    8.216    0.000  583.294  948.785
##    .CRP              42.110    5.125    8.216    0.000   32.064   52.156
##    Std.lv  Std.all
##    60.362    0.887
##    23.485    0.992
##    54.407    0.986
##   766.040    0.988
##    42.110    0.950
## 
## Defined Parameters:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower ci.upper
##     ab                0.081    0.107    0.758    0.448   -0.128    0.290
##     cd               -0.028    0.062   -0.447    0.655   -0.149    0.094
##     ef                0.043    0.085    0.512    0.609   -0.123    0.210
##     gh                0.003    0.164    0.017    0.986   -0.319    0.325
##     total             1.916    0.873    2.194    0.028    0.204    3.628
##    Std.lv  Std.all
##     0.081    0.008
##    -0.028   -0.003
##     0.043    0.004
##     0.003    0.000
##     1.916    0.197
semPaths(fit_total_adj)

##total adjusted with log transformed mediators

model_total_adj_log <- ' # direct effect
             BMSi ~ i*mod + age_final + female_b2 + PA_SCORE_b2 + vitd_top + BMI_b2 + alcohol_freq_8yr
           # mediator
             log_IL6 ~ a*mod + diabetes_bone2
             log_tnf ~ c*mod + diabetes_bone2
             log_il1B ~ e*mod + diabetes_bone2
             log_crp ~ g*mod + diabetes_bone2
             BMSi ~ b*log_IL6 
             BMSi ~ d*log_tnf
             BMSi ~ f*log_il1B
             BMSi ~ h*log_crp
           # indirect effect (a*b)
             ab := a*b
             cd := c*d
             ef := e*f
             gh := g*h
           # total effect
             total := i + (a*b) +(c*d) +(e*f) +(g*h)
         '
fit_total_adj_log <- sem(model_total_adj_log, data = db)
summary(fit_total_adj_log,fit.measures=TRUE, standardized=TRUE, ci=TRUE)
## lavaan 0.6-18 ended normally after 1 iteration
## 
##   Estimator                                         ML
##   Optimization method                           NLMINB
##   Number of model parameters                        24
## 
##                                                   Used       Total
##   Number of observations                           135         163
## 
## Model Test User Model:
##                                                       
##   Test statistic                                53.392
##   Degrees of freedom                                31
##   P-value (Chi-square)                           0.007
## 
## Model Test Baseline Model:
## 
##   Test statistic                                89.359
##   Degrees of freedom                                50
##   P-value                                        0.001
## 
## User Model versus Baseline Model:
## 
##   Comparative Fit Index (CFI)                    0.431
##   Tucker-Lewis Index (TLI)                       0.082
## 
## Loglikelihood and Information Criteria:
## 
##   Loglikelihood user model (H0)              -1158.403
##   Loglikelihood unrestricted model (H1)      -1131.707
##                                                       
##   Akaike (AIC)                                2364.805
##   Bayesian (BIC)                              2434.532
##   Sample-size adjusted Bayesian (SABIC)       2358.612
## 
## Root Mean Square Error of Approximation:
## 
##   RMSEA                                          0.073
##   90 Percent confidence interval - lower         0.038
##   90 Percent confidence interval - upper         0.106
##   P-value H_0: RMSEA <= 0.050                    0.124
##   P-value H_0: RMSEA >= 0.080                    0.391
## 
## Standardized Root Mean Square Residual:
## 
##   SRMR                                           0.068
## 
## Parameter Estimates:
## 
##   Standard errors                             Standard
##   Information                                 Expected
##   Information saturated (h1) model          Structured
## 
## Regressions:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower ci.upper
##   BMSi ~                                                                
##     mod        (i)    1.796    0.871    2.062    0.039    0.089    3.504
##     age_final        -0.211    0.105   -2.019    0.043   -0.417   -0.006
##     female_b2         0.068    1.575    0.043    0.965   -3.018    3.155
##     PA_SCORE_2        0.198    0.114    1.736    0.082   -0.026    0.423
##     vitd_top         -0.070    0.123   -0.573    0.567   -0.311    0.170
##     BMI_b2           -0.312    0.122   -2.553    0.011   -0.552   -0.073
##     alchl_fr_8       -0.458    1.247   -0.368    0.713   -2.902    1.985
##   log_IL6 ~                                                             
##     mod        (a)   -0.130    0.094   -1.381    0.167   -0.315    0.055
##     diabts_bn2       -0.070    0.160   -0.437    0.662   -0.384    0.244
##   log_tnf ~                                                             
##     mod        (c)    0.055    0.053    1.036    0.300   -0.049    0.159
##     diabts_bn2        0.153    0.090    1.705    0.088   -0.023    0.329
##   log_il1B ~                                                            
##     mod        (e)   -0.131    0.095   -1.391    0.164   -0.317    0.054
##     diabts_bn2       -0.191    0.160   -1.194    0.233   -0.505    0.123
##   log_crp ~                                                             
##     mod        (g)   -0.313    0.132   -2.366    0.018   -0.573   -0.054
##     diabts_bn2        0.022    0.225    0.097    0.922   -0.418    0.462
##   BMSi ~                                                                
##     log_IL6    (b)   -1.638    0.704   -2.327    0.020   -3.018   -0.258
##     log_tnf    (d)   -1.035    1.244   -0.832    0.405   -3.474    1.403
##     log_il1B   (f)   -1.137    0.700   -1.624    0.104   -2.509    0.235
##     log_crp    (h)    0.837    0.502    1.667    0.096   -0.147    1.821
##    Std.lv  Std.all
##                   
##     1.796    0.182
##    -0.211   -0.166
##     0.068    0.004
##     0.198    0.140
##    -0.070   -0.048
##    -0.312   -0.211
##    -0.458   -0.030
##                   
##    -0.130   -0.118
##    -0.070   -0.037
##                   
##     0.055    0.088
##     0.153    0.145
##                   
##    -0.131   -0.119
##    -0.191   -0.102
##                   
##    -0.313   -0.200
##     0.022    0.008
##                   
##    -1.638   -0.183
##    -1.035   -0.065
##    -1.137   -0.127
##     0.837    0.133
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower ci.upper
##    .BMSi             57.594    7.010    8.216    0.000   43.854   71.333
##    .log_IL6           0.860    0.105    8.216    0.000    0.655    1.065
##    .log_tnf           0.270    0.033    8.216    0.000    0.206    0.335
##    .log_il1B          0.862    0.105    8.216    0.000    0.656    1.068
##    .log_crp           1.693    0.206    8.216    0.000    1.289    2.096
##    Std.lv  Std.all
##    57.594    0.820
##     0.860    0.985
##     0.270    0.973
##     0.862    0.977
##     1.693    0.960
## 
## Defined Parameters:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower ci.upper
##     ab                0.214    0.180    1.188    0.235   -0.139    0.566
##     cd               -0.057    0.087   -0.649    0.517   -0.228    0.115
##     ef                0.149    0.141    1.056    0.291   -0.128    0.427
##     gh               -0.262    0.192   -1.363    0.173   -0.639    0.115
##     total             1.841    0.875    2.104    0.035    0.126    3.555
##    Std.lv  Std.all
##     0.214    0.022
##    -0.057   -0.006
##     0.149    0.015
##    -0.262   -0.026
##     1.841    0.186
semPaths(fit_total_adj_log)

No-fat as predictor var, TBS as response var; IL6, TNFa, IL1B, CRP as individual mediators

model_skim_TBS <- ' # direct effect
             TBSL1L2L3L4_final ~ i*skim 
           # mediator
             IL6 ~ a*skim
             TNFa ~ c*skim
             IL1B ~ e*skim
             CRP ~ g*skim
             TBSL1L2L3L4_final ~ b*IL6 
             TBSL1L2L3L4_final ~ d*TNFa 
             TBSL1L2L3L4_final ~ f*IL1B
             TBSL1L2L3L4_final ~ h*CRP
           # indirect effect (a*b)
             ab := a*b
             cd := c*d
             ef := e*f
             gh := g*h
           # total effect
             total := i + (a*b) +(c*d) +(e*f) +(g*h)
         '
fit2 <- sem(model_skim_TBS, data = db2)
## Warning: lavaan->lav_data_full():  
##    some observed variances are (at least) a factor 1000 times larger than 
##    others; use varTable(fit) to investigate
summary(fit2,fit.measures=TRUE, standardized=TRUE, ci=TRUE )
## lavaan 0.6-18 ended normally after 34 iterations
## 
##   Estimator                                         ML
##   Optimization method                           NLMINB
##   Number of model parameters                        14
## 
##                                                   Used       Total
##   Number of observations                           396         445
## 
## Model Test User Model:
##                                                       
##   Test statistic                                81.283
##   Degrees of freedom                                 6
##   P-value (Chi-square)                           0.000
## 
## Model Test Baseline Model:
## 
##   Test statistic                                93.077
##   Degrees of freedom                                15
##   P-value                                        0.000
## 
## User Model versus Baseline Model:
## 
##   Comparative Fit Index (CFI)                    0.036
##   Tucker-Lewis Index (TLI)                      -1.411
## 
## Loglikelihood and Information Criteria:
## 
##   Loglikelihood user model (H0)              -5940.723
##   Loglikelihood unrestricted model (H1)      -5900.081
##                                                       
##   Akaike (AIC)                               11909.445
##   Bayesian (BIC)                             11965.185
##   Sample-size adjusted Bayesian (SABIC)      11920.763
## 
## Root Mean Square Error of Approximation:
## 
##   RMSEA                                          0.178
##   90 Percent confidence interval - lower         0.145
##   90 Percent confidence interval - upper         0.213
##   P-value H_0: RMSEA <= 0.050                    0.000
##   P-value H_0: RMSEA >= 0.080                    1.000
## 
## Standardized Root Mean Square Residual:
## 
##   SRMR                                           0.099
## 
## Parameter Estimates:
## 
##   Standard errors                             Standard
##   Information                                 Expected
##   Information saturated (h1) model          Structured
## 
## Regressions:
##                       Estimate  Std.Err  z-value  P(>|z|) ci.lower ci.upper
##   TBSL1L2L3L4_final ~                                                      
##     skim       (i)      -0.046    0.018   -2.518    0.012   -0.081   -0.010
##   IL6 ~                                                                    
##     skim       (a)       0.642    0.693    0.927    0.354   -0.716    2.000
##   TNFa ~                                                                   
##     skim       (c)       0.241    0.871    0.277    0.782   -1.466    1.948
##   IL1B ~                                                                   
##     skim       (e)       0.231    4.620    0.050    0.960   -8.824    9.287
##   CRP ~                                                                    
##     skim       (g)      -1.894    1.344   -1.409    0.159   -4.528    0.741
##   TBSL1L2L3L4_final ~                                                      
##     IL6        (b)       0.000    0.001    0.314    0.753   -0.002    0.003
##     TNFa       (d)      -0.001    0.001   -0.567    0.571   -0.003    0.001
##     IL1B       (f)       0.000    0.000    1.465    0.143   -0.000    0.001
##     CRP        (h)      -0.000    0.001   -0.647    0.518   -0.002    0.001
##    Std.lv  Std.all
##                   
##    -0.046   -0.126
##                   
##     0.642    0.047
##                   
##     0.241    0.014
##                   
##     0.231    0.003
##                   
##    -1.894   -0.071
##                   
##     0.000    0.016
##    -0.001   -0.028
##     0.000    0.073
##    -0.000   -0.032
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower ci.upper
##    .TBSL1L2L3L4_fn    0.023    0.002   14.071    0.000    0.020    0.026
##    .IL6              33.309    2.367   14.071    0.000   28.669   37.949
##    .TNFa             52.641    3.741   14.071    0.000   45.308   59.973
##    .IL1B           1481.066  105.255   14.071    0.000 1274.770 1687.361
##    .CRP             125.373    8.910   14.071    0.000  107.910  142.836
##    Std.lv  Std.all
##     0.023    0.978
##    33.309    0.998
##    52.641    1.000
##  1481.066    1.000
##   125.373    0.995
## 
## Defined Parameters:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower ci.upper
##     ab                0.000    0.001    0.298    0.766   -0.001    0.002
##     cd               -0.000    0.001   -0.249    0.804   -0.001    0.001
##     ef                0.000    0.001    0.050    0.960   -0.003    0.003
##     gh                0.001    0.001    0.588    0.557   -0.002    0.004
##     total            -0.045    0.018   -2.462    0.014   -0.080   -0.009
##    Std.lv  Std.all
##     0.000    0.001
##    -0.000   -0.000
##     0.000    0.000
##     0.001    0.002
##    -0.045   -0.123
semPaths(fit2)

#Adjusted skim

model_skim_adj_TBS <- ' # direct effect
             TBSL1L2L3L4_final ~ i*skim + age_final + female_b2 + PA_SCORE_b2 + vitd_top + BMI_b2 + alcohol_freq_8yr
           # mediator
             IL6 ~ a*skim + diabetes_bone2
             TNFa ~ c*skim + diabetes_bone2
             IL1B ~ e*skim + diabetes_bone2
             CRP ~ g*skim + diabetes_bone2
             TBSL1L2L3L4_final ~ b*IL6 
             TBSL1L2L3L4_final ~ d*TNFa 
             TBSL1L2L3L4_final ~ f*IL1B
             TBSL1L2L3L4_final ~ h*CRP
           # indirect effect (a*b)
             ab := a*b
             cd := c*d
             ef := e*f
             gh := g*h
           # total effect
             total := i + (a*b) +(c*d) +(e*f) +(g*h)
         '
fit2_adj <- sem(model_skim_adj_TBS, data = db2)
## Warning: lavaan->lav_data_full():  
##    some observed variances are (at least) a factor 1000 times larger than 
##    others; use varTable(fit) to investigate
summary(fit2_adj,fit.measures=TRUE, standardized=TRUE, ci=TRUE )
## lavaan 0.6-18 ended normally after 1 iteration
## 
##   Estimator                                         ML
##   Optimization method                           NLMINB
##   Number of model parameters                        24
## 
##                                                   Used       Total
##   Number of observations                           362         445
## 
## Model Test User Model:
##                                                       
##   Test statistic                               105.593
##   Degrees of freedom                                31
##   P-value (Chi-square)                           0.000
## 
## Model Test Baseline Model:
## 
##   Test statistic                               133.730
##   Degrees of freedom                                50
##   P-value                                        0.000
## 
## User Model versus Baseline Model:
## 
##   Comparative Fit Index (CFI)                    0.109
##   Tucker-Lewis Index (TLI)                      -0.437
## 
## Loglikelihood and Information Criteria:
## 
##   Loglikelihood user model (H0)              -5446.680
##   Loglikelihood unrestricted model (H1)             NA
##                                                       
##   Akaike (AIC)                               10941.359
##   Bayesian (BIC)                             11034.759
##   Sample-size adjusted Bayesian (SABIC)      10958.618
## 
## Root Mean Square Error of Approximation:
## 
##   RMSEA                                          0.082
##   90 Percent confidence interval - lower         0.065
##   90 Percent confidence interval - upper         0.099
##   P-value H_0: RMSEA <= 0.050                    0.001
##   P-value H_0: RMSEA >= 0.080                    0.578
## 
## Standardized Root Mean Square Residual:
## 
##   SRMR                                           0.058
## 
## Parameter Estimates:
## 
##   Standard errors                             Standard
##   Information                                 Expected
##   Information saturated (h1) model          Structured
## 
## Regressions:
##                       Estimate  Std.Err  z-value  P(>|z|) ci.lower ci.upper
##   TBSL1L2L3L4_final ~                                                      
##     skim       (i)      -0.045    0.019   -2.409    0.016   -0.082   -0.008
##     age_final           -0.001    0.001   -0.452    0.652   -0.003    0.002
##     female_b2           -0.017    0.020   -0.875    0.381   -0.055    0.021
##     PA_SCORE_2           0.000    0.001    0.137    0.891   -0.002    0.003
##     vitd_top            -0.000    0.001   -0.313    0.754   -0.003    0.002
##     BMI_b2              -0.002    0.001   -1.912    0.056   -0.005    0.000
##     alchl_fr_8           0.003    0.015    0.217    0.828   -0.027    0.033
##   IL6 ~                                                                    
##     skim       (a)       0.529    0.743    0.711    0.477   -0.929    1.986
##     diabts_bn2           0.789    0.645    1.224    0.221   -0.475    2.053
##   TNFa ~                                                                   
##     skim       (c)       0.116    0.919    0.126    0.900   -1.686    1.917
##     diabts_bn2           1.541    0.797    1.934    0.053   -0.021    3.103
##   IL1B ~                                                                   
##     skim       (e)       2.011    4.616    0.436    0.663   -7.035   11.057
##     diabts_bn2          -6.216    4.003   -1.553    0.120  -14.061    1.629
##   CRP ~                                                                    
##     skim       (g)      -2.216    1.415   -1.566    0.117   -4.988    0.557
##     diabts_bn2           2.382    1.227    1.942    0.052   -0.022    4.787
##   TBSL1L2L3L4_final ~                                                      
##     IL6        (b)       0.000    0.001    0.296    0.767   -0.002    0.003
##     TNFa       (d)      -0.001    0.001   -0.564    0.573   -0.003    0.001
##     IL1B       (f)       0.000    0.000    1.130    0.259   -0.000    0.001
##     CRP        (h)      -0.000    0.001   -0.215    0.830   -0.002    0.001
##    Std.lv  Std.all
##                   
##    -0.045   -0.125
##    -0.001   -0.024
##    -0.017   -0.047
##     0.000    0.007
##    -0.000   -0.016
##    -0.002   -0.104
##     0.003    0.011
##                   
##     0.529    0.038
##     0.789    0.065
##                   
##     0.116    0.007
##     1.541    0.102
##                   
##     2.011    0.023
##    -6.216   -0.082
##                   
##    -2.216   -0.082
##     2.382    0.102
##                   
##     0.000    0.015
##    -0.001   -0.029
##     0.000    0.058
##    -0.000   -0.011
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower ci.upper
##    .TBSL1L2L3L4_fn    0.023    0.002   13.454    0.000    0.020    0.026
##    .IL6              35.848    2.665   13.454    0.000   30.625   41.070
##    .TNFa             54.779    4.072   13.454    0.000   46.799   62.760
##    .IL1B           1381.734  102.703   13.454    0.000 1180.439 1583.029
##    .CRP             129.789    9.647   13.454    0.000  110.881  148.697
##    Std.lv  Std.all
##     0.023    0.963
##    35.848    0.994
##    54.779    0.989
##  1381.734    0.993
##   129.789    0.985
## 
## Defined Parameters:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower ci.upper
##     ab                0.000    0.001    0.273    0.785   -0.001    0.002
##     cd               -0.000    0.001   -0.123    0.902   -0.001    0.001
##     ef                0.000    0.001    0.406    0.684   -0.002    0.003
##     gh                0.000    0.002    0.213    0.831   -0.003    0.003
##     total            -0.044    0.019   -2.361    0.018   -0.081   -0.008
##    Std.lv  Std.all
##     0.000    0.001
##    -0.000   -0.000
##     0.000    0.001
##     0.000    0.001
##    -0.044   -0.123
semPaths(fit2_adj)

skim & tbs adjusted with log tranformed inflammatory cytokines

model_skim_TBS_log <- ' # direct effect
             TBSL1L2L3L4_final ~ i*skim + age_final + female_b2 + PA_SCORE_b2 + vitd_top + BMI_b2 + alcohol_freq_8yr
           # mediator
             log_IL6 ~ a*skim + diabetes_bone2
             log_tnf ~ c*skim + diabetes_bone2
             log_il1B ~ e*skim + diabetes_bone2
             log_crp ~ g*skim + diabetes_bone2
             TBSL1L2L3L4_final ~ b*log_IL6 
             TBSL1L2L3L4_final ~ d*log_tnf 
             TBSL1L2L3L4_final ~ f*log_il1B 
             TBSL1L2L3L4_final ~ h*log_crp 
           # indirect effect (a*b)
             ab := a*b
             cd := c*d
             ef := e*f
           # total effect
             total := i + (a*b) +(c*d) +(e*f) +(g*h)
         '
fit_skim_log <- sem(model_skim_TBS_log, data = db2)
summary(fit_skim_log,fit.measures=TRUE, standardized=TRUE, ci=TRUE)
## lavaan 0.6-18 ended normally after 44 iterations
## 
##   Estimator                                         ML
##   Optimization method                           NLMINB
##   Number of model parameters                        24
## 
##                                                   Used       Total
##   Number of observations                           362         445
## 
## Model Test User Model:
##                                                       
##   Test statistic                               120.811
##   Degrees of freedom                                31
##   P-value (Chi-square)                           0.000
## 
## Model Test Baseline Model:
## 
##   Test statistic                               155.833
##   Degrees of freedom                                50
##   P-value                                        0.000
## 
## User Model versus Baseline Model:
## 
##   Comparative Fit Index (CFI)                    0.151
##   Tucker-Lewis Index (TLI)                      -0.369
## 
## Loglikelihood and Information Criteria:
## 
##   Loglikelihood user model (H0)              -1717.652
##   Loglikelihood unrestricted model (H1)             NA
##                                                       
##   Akaike (AIC)                                3483.305
##   Bayesian (BIC)                              3576.704
##   Sample-size adjusted Bayesian (SABIC)       3500.563
## 
## Root Mean Square Error of Approximation:
## 
##   RMSEA                                          0.089
##   90 Percent confidence interval - lower         0.073
##   90 Percent confidence interval - upper         0.107
##   P-value H_0: RMSEA <= 0.050                    0.000
##   P-value H_0: RMSEA >= 0.080                    0.834
## 
## Standardized Root Mean Square Residual:
## 
##   SRMR                                           0.066
## 
## Parameter Estimates:
## 
##   Standard errors                             Standard
##   Information                                 Expected
##   Information saturated (h1) model          Structured
## 
## Regressions:
##                       Estimate  Std.Err  z-value  P(>|z|) ci.lower ci.upper
##   TBSL1L2L3L4_final ~                                                      
##     skim       (i)      -0.047    0.019   -2.488    0.013   -0.083   -0.010
##     age_final           -0.000    0.001   -0.410    0.682   -0.003    0.002
##     female_b2           -0.017    0.019   -0.850    0.396   -0.055    0.022
##     PA_SCORE_2           0.000    0.001    0.022    0.982   -0.002    0.003
##     vitd_top            -0.000    0.001   -0.329    0.742   -0.003    0.002
##     BMI_b2              -0.002    0.001   -1.467    0.142   -0.004    0.001
##     alchl_fr_8           0.006    0.015    0.420    0.675   -0.023    0.036
##   log_IL6 ~                                                                
##     skim       (a)       0.028    0.137    0.203    0.839   -0.240    0.295
##     diabts_bn2           0.062    0.118    0.523    0.601   -0.170    0.294
##   log_tnf ~                                                                
##     skim       (c)       0.039    0.062    0.638    0.524   -0.082    0.161
##     diabts_bn2           0.167    0.054    3.105    0.002    0.061    0.272
##   log_il1B ~                                                               
##     skim       (e)      -0.031    0.111   -0.283    0.777   -0.248    0.185
##     diabts_bn2          -0.145    0.096   -1.512    0.131   -0.333    0.043
##   log_crp ~                                                                
##     skim       (g)      -0.239    0.161   -1.481    0.139   -0.555    0.077
##     diabts_bn2           0.182    0.140    1.305    0.192   -0.092    0.456
##   TBSL1L2L3L4_final ~                                                      
##     log_IL6    (b)       0.010    0.007    1.355    0.175   -0.004    0.024
##     log_tnf    (d)      -0.013    0.016   -0.824    0.410   -0.044    0.018
##     log_il1B   (f)       0.006    0.009    0.657    0.511   -0.012    0.023
##     log_crp    (h)      -0.013    0.006   -2.206    0.027   -0.025   -0.001
##    Std.lv  Std.all
##                   
##    -0.047   -0.129
##    -0.000   -0.022
##    -0.017   -0.045
##     0.000    0.001
##    -0.000   -0.017
##    -0.002   -0.080
##     0.006    0.022
##                   
##     0.028    0.011
##     0.062    0.028
##                   
##     0.039    0.033
##     0.167    0.162
##                   
##    -0.031   -0.015
##    -0.145   -0.080
##                   
##    -0.239   -0.078
##     0.182    0.069
##                   
##     0.010    0.070
##    -0.013   -0.042
##     0.006    0.034
##    -0.013   -0.113
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower ci.upper
##    .TBSL1L2L3L4_fn    0.023    0.002   13.454    0.000    0.019    0.026
##    .log_IL6           1.210    0.090   13.454    0.000    1.033    1.386
##    .log_tnf           0.249    0.018   13.454    0.000    0.212    0.285
##    .log_il1B          0.793    0.059   13.454    0.000    0.678    0.909
##    .log_crp           1.685    0.125   13.454    0.000    1.440    1.931
##    Std.lv  Std.all
##     0.023    0.952
##     1.210    0.999
##     0.249    0.971
##     0.793    0.993
##     1.685    0.990
## 
## Defined Parameters:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower ci.upper
##     ab                0.000    0.001    0.201    0.841   -0.002    0.003
##     cd               -0.001    0.001   -0.504    0.614   -0.002    0.001
##     ef               -0.000    0.001   -0.260    0.795   -0.002    0.001
##     total            -0.044    0.019   -2.324    0.020   -0.081   -0.007
##    Std.lv  Std.all
##     0.000    0.001
##    -0.001   -0.001
##    -0.000   -0.001
##    -0.044   -0.121
semPaths(fit_skim_log)

Full fat as predictor, TBS as response, and log transformed mediators

model_fat_TBS <- ' # direct effect
             TBSL1L2L3L4_final ~ i*fat 
           # mediator
             log_IL6 ~ a*fat
             log_tnf ~ c*fat
             log_il1B ~ e*fat
             log_crp ~ g*fat
             TBSL1L2L3L4_final ~ b*log_IL6
             TBSL1L2L3L4_final ~ d*log_tnf
             TBSL1L2L3L4_final ~ f*log_il1B
             TBSL1L2L3L4_final ~ h*log_crp
           # indirect effect (a*b)
             ab := a*b
             cd := c*d
             ef := e*f
           # total effect
             total := i + (a*b) +(c*d) +(e*f) +(g*h)
         '
fit_fat <- sem(model_fat_TBS, data = db2)
summary(fit_fat)
## lavaan 0.6-18 ended normally after 31 iterations
## 
##   Estimator                                         ML
##   Optimization method                           NLMINB
##   Number of model parameters                        14
## 
##                                                   Used       Total
##   Number of observations                           396         445
## 
## Model Test User Model:
##                                                       
##   Test statistic                                53.030
##   Degrees of freedom                                 6
##   P-value (Chi-square)                           0.000
## 
## Parameter Estimates:
## 
##   Standard errors                             Standard
##   Information                                 Expected
##   Information saturated (h1) model          Structured
## 
## Regressions:
##                       Estimate  Std.Err  z-value  P(>|z|)
##   TBSL1L2L3L4_final ~                                    
##     fat        (i)       0.014    0.008    1.706    0.088
##   log_IL6 ~                                              
##     fat        (a)      -0.123    0.061   -2.032    0.042
##   log_tnf ~                                              
##     fat        (c)      -0.013    0.028   -0.458    0.647
##   log_il1B ~                                             
##     fat        (e)      -0.017    0.049   -0.356    0.722
##   log_crp ~                                              
##     fat        (g)      -0.054    0.071   -0.760    0.447
##   TBSL1L2L3L4_final ~                                    
##     log_IL6    (b)       0.006    0.007    0.911    0.362
##     log_tnf    (d)      -0.013    0.015   -0.860    0.390
##     log_il1B   (f)       0.009    0.009    1.038    0.299
##     log_crp    (h)      -0.014    0.006   -2.392    0.017
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|)
##    .TBSL1L2L3L4_fn    0.023    0.002   14.071    0.000
##    .log_IL6           1.197    0.085   14.071    0.000
##    .log_tnf           0.250    0.018   14.071    0.000
##    .log_il1B          0.780    0.055   14.071    0.000
##    .log_crp           1.639    0.116   14.071    0.000
## 
## Defined Parameters:
##                    Estimate  Std.Err  z-value  P(>|z|)
##     ab               -0.001    0.001   -0.831    0.406
##     cd                0.000    0.000    0.404    0.686
##     ef               -0.000    0.000   -0.337    0.736
##     total             0.014    0.008    1.698    0.089
semPaths(fit2)

#adjusted

model_fat_adj_TBS_log <- ' # direct effect
             TBSL1L2L3L4_final ~ i*fat + age_final + female_b2 + PA_SCORE_b2 + vitd_top + BMI_b2 + alcohol_freq_8yr
           # mediator
             log_IL6 ~ a*fat + diabetes_bone2
             log_tnf ~ c*fat + diabetes_bone2
             log_il1B ~ e*fat + diabetes_bone2
             log_crp ~ g*fat + diabetes_bone2
             TBSL1L2L3L4_final ~ b*log_IL6 
             TBSL1L2L3L4_final ~ d*log_tnf 
             TBSL1L2L3L4_final ~ f*log_il1B 
             TBSL1L2L3L4_final ~ h*log_crp 
           # indirect effect (a*b)
             ab := a*b
             cd := c*d
             ef := e*f
           # total effect
             total := i + (a*b) +(c*d) +(e*f) +(g*h)
         '
fit_fat_log <- sem(model_fat_adj_TBS_log, data = db2)
summary(fit_fat_log,fit.measures=TRUE, standardized=TRUE, ci=TRUE)
## lavaan 0.6-18 ended normally after 2 iterations
## 
##   Estimator                                         ML
##   Optimization method                           NLMINB
##   Number of model parameters                        24
## 
##                                                   Used       Total
##   Number of observations                           362         445
## 
## Model Test User Model:
##                                                       
##   Test statistic                               122.450
##   Degrees of freedom                                31
##   P-value (Chi-square)                           0.000
## 
## Model Test Baseline Model:
## 
##   Test statistic                               158.033
##   Degrees of freedom                                50
##   P-value                                        0.000
## 
## User Model versus Baseline Model:
## 
##   Comparative Fit Index (CFI)                    0.153
##   Tucker-Lewis Index (TLI)                      -0.365
## 
## Loglikelihood and Information Criteria:
## 
##   Loglikelihood user model (H0)              -1717.372
##   Loglikelihood unrestricted model (H1)             NA
##                                                       
##   Akaike (AIC)                                3482.744
##   Bayesian (BIC)                              3576.144
##   Sample-size adjusted Bayesian (SABIC)       3500.003
## 
## Root Mean Square Error of Approximation:
## 
##   RMSEA                                          0.090
##   90 Percent confidence interval - lower         0.074
##   90 Percent confidence interval - upper         0.107
##   P-value H_0: RMSEA <= 0.050                    0.000
##   P-value H_0: RMSEA >= 0.080                    0.853
## 
## Standardized Root Mean Square Residual:
## 
##   SRMR                                           0.066
## 
## Parameter Estimates:
## 
##   Standard errors                             Standard
##   Information                                 Expected
##   Information saturated (h1) model          Structured
## 
## Regressions:
##                       Estimate  Std.Err  z-value  P(>|z|) ci.lower ci.upper
##   TBSL1L2L3L4_final ~                                                      
##     fat        (i)       0.021    0.009    2.271    0.023    0.003    0.039
##     age_final           -0.001    0.001   -0.667    0.505   -0.003    0.002
##     female_b2           -0.022    0.019   -1.110    0.267   -0.060    0.017
##     PA_SCORE_2           0.000    0.001    0.054    0.957   -0.002    0.003
##     vitd_top            -0.002    0.001   -1.082    0.279   -0.004    0.001
##     BMI_b2              -0.002    0.001   -1.537    0.124   -0.004    0.001
##     alchl_fr_8           0.014    0.015    0.932    0.351   -0.016    0.045
##   log_IL6 ~                                                                
##     fat        (a)      -0.119    0.063   -1.895    0.058   -0.242    0.004
##     diabts_bn2           0.057    0.117    0.490    0.624   -0.172    0.287
##   log_tnf ~                                                                
##     fat        (c)      -0.012    0.029   -0.412    0.680   -0.068    0.044
##     diabts_bn2           0.170    0.053    3.188    0.001    0.066    0.275
##   log_il1B ~                                                               
##     fat        (e)      -0.022    0.051   -0.429    0.668   -0.122    0.078
##     diabts_bn2          -0.150    0.095   -1.571    0.116   -0.336    0.037
##   log_crp ~                                                                
##     fat        (g)      -0.046    0.075   -0.618    0.537   -0.192    0.100
##     diabts_bn2           0.155    0.139    1.112    0.266   -0.118    0.428
##   TBSL1L2L3L4_final ~                                                      
##     log_IL6    (b)       0.011    0.007    1.530    0.126   -0.003    0.025
##     log_tnf    (d)      -0.013    0.016   -0.857    0.392   -0.044    0.017
##     log_il1B   (f)       0.007    0.009    0.765    0.444   -0.011    0.024
##     log_crp    (h)      -0.013    0.006   -2.079    0.038   -0.025   -0.001
##    Std.lv  Std.all
##                   
##     0.021    0.126
##    -0.001   -0.036
##    -0.022   -0.059
##     0.000    0.003
##    -0.002   -0.059
##    -0.002   -0.083
##     0.014    0.049
##                   
##    -0.119   -0.099
##     0.057    0.026
##                   
##    -0.012   -0.021
##     0.170    0.165
##                   
##    -0.022   -0.022
##    -0.150   -0.082
##                   
##    -0.046   -0.032
##     0.155    0.058
##                   
##     0.011    0.079
##    -0.013   -0.044
##     0.007    0.039
##    -0.013   -0.107
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower ci.upper
##    .TBSL1L2L3L4_fn    0.023    0.002   13.454    0.000    0.019    0.026
##    .log_IL6           1.198    0.089   13.454    0.000    1.023    1.372
##    .log_tnf           0.249    0.018   13.454    0.000    0.213    0.285
##    .log_il1B          0.793    0.059   13.454    0.000    0.677    0.908
##    .log_crp           1.694    0.126   13.454    0.000    1.447    1.941
##    Std.lv  Std.all
##     0.023    0.953
##     1.198    0.989
##     0.249    0.972
##     0.793    0.993
##     1.694    0.995
## 
## Defined Parameters:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower ci.upper
##     ab               -0.001    0.001   -1.191    0.234   -0.003    0.001
##     cd                0.000    0.000    0.371    0.710   -0.001    0.001
##     ef               -0.000    0.000   -0.374    0.708   -0.001    0.001
##     total             0.020    0.009    2.184    0.029    0.002    0.039
##    Std.lv  Std.all
##    -0.001   -0.008
##     0.000    0.001
##    -0.000   -0.001
##     0.020    0.122
semPaths(fit_fat_log)

####Run adjusted models with “estimator = MLM” since 1 of the independent vars (skim) and all mediator vars aren’t normally distributed

model_milk_mlm <- ' # direct effect
             BMSi ~ i*milk 
           # mediator
             IL6 ~ a*milk
             TNFa ~ c*milk
             IL1B ~ e*milk
             CRP ~ g*milk
             BMSi ~ b*IL6
             BMSi ~ d*TNFa
             BMSi ~ f*IL1B
             BMSi ~ h*CRP
           # indirect effect (a*b)
             ab := a*b
             cd := c*d
             ef := e*f
             gh := g*h
           # total effect
             total := i + (a*b) +(c*d) +(e*f) +(g*h)
         '
fit_milk_adj_mlm <- sem(model_milk_mlm, data = db, estimator = "MLM")
summary(fit_milk_adj_mlm, fit.measures=TRUE, standardized=TRUE, ci=TRUE)
## lavaan 0.6-18 ended normally after 1 iteration
## 
##   Estimator                                         ML
##   Optimization method                           NLMINB
##   Number of model parameters                        14
## 
##                                                   Used       Total
##   Number of observations                           151         163
## 
## Model Test User Model:
##                                               Standard      Scaled
##   Test Statistic                                 8.559       8.020
##   Degrees of freedom                                 6           6
##   P-value (Chi-square)                           0.200       0.237
##   Scaling correction factor                                  1.067
##     Satorra-Bentler correction                                    
## 
## Model Test Baseline Model:
## 
##   Test statistic                                21.256      22.634
##   Degrees of freedom                                15          15
##   P-value                                        0.129       0.092
##   Scaling correction factor                                  0.939
## 
## User Model versus Baseline Model:
## 
##   Comparative Fit Index (CFI)                    0.591       0.735
##   Tucker-Lewis Index (TLI)                      -0.023       0.338
##                                                                   
##   Robust Comparative Fit Index (CFI)                         0.699
##   Robust Tucker-Lewis Index (TLI)                            0.248
## 
## Loglikelihood and Information Criteria:
## 
##   Loglikelihood user model (H0)              -2694.485   -2694.485
##   Loglikelihood unrestricted model (H1)      -2690.206   -2690.206
##                                                                   
##   Akaike (AIC)                                5416.970    5416.970
##   Bayesian (BIC)                              5459.212    5459.212
##   Sample-size adjusted Bayesian (SABIC)       5414.904    5414.904
## 
## Root Mean Square Error of Approximation:
## 
##   RMSEA                                          0.053       0.047
##   90 Percent confidence interval - lower         0.000       0.000
##   90 Percent confidence interval - upper         0.127       0.120
##   P-value H_0: RMSEA <= 0.050                    0.405       0.453
##   P-value H_0: RMSEA >= 0.080                    0.331       0.282
##                                                                   
##   Robust RMSEA                                               0.049
##   90 Percent confidence interval - lower                     0.000
##   90 Percent confidence interval - upper                     0.127
##   P-value H_0: Robust RMSEA <= 0.050                         0.437
##   P-value H_0: Robust RMSEA >= 0.080                         0.313
## 
## Standardized Root Mean Square Residual:
## 
##   SRMR                                           0.050       0.050
## 
## Parameter Estimates:
## 
##   Standard errors                           Robust.sem
##   Information                                 Expected
##   Information saturated (h1) model          Structured
## 
## Regressions:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower ci.upper
##   BMSi ~                                                                
##     milk       (i)    0.958    0.768    1.248    0.212   -0.547    2.462
##   IL6 ~                                                                 
##     milk       (a)   -0.588    0.262   -2.241    0.025   -1.102   -0.074
##   TNFa ~                                                                
##     milk       (c)    0.682    0.818    0.834    0.404   -0.921    2.286
##   IL1B ~                                                                
##     milk       (e)   -1.824    2.956   -0.617    0.537   -7.618    3.970
##   CRP ~                                                                 
##     milk       (g)   -1.618    0.600   -2.698    0.007   -2.793   -0.442
##   BMSi ~                                                                
##     IL6        (b)   -0.120    0.120   -1.007    0.314   -0.355    0.114
##     TNFa       (d)   -0.029    0.073   -0.398    0.691   -0.171    0.113
##     IL1B       (f)   -0.019    0.027   -0.689    0.491   -0.071    0.034
##     CRP        (h)   -0.079    0.086   -0.922    0.357   -0.248    0.089
##    Std.lv  Std.all
##                   
##     0.958    0.093
##                   
##    -0.588   -0.100
##                   
##     0.682    0.075
##                   
##    -1.824   -0.053
##                   
##    -1.618   -0.196
##                   
##    -0.120   -0.068
##    -0.029   -0.026
##    -0.019   -0.062
##    -0.079   -0.063
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower ci.upper
##    .BMSi             64.811    7.625    8.500    0.000   49.866   79.756
##    .IL6              21.222   13.536    1.568    0.117   -5.307   47.751
##    .TNFa             52.186   17.860    2.922    0.003   17.181   87.190
##    .IL1B            738.733  144.950    5.096    0.000  454.637 1022.829
##    .CRP              40.972   11.123    3.683    0.000   19.171   62.774
##    Std.lv  Std.all
##    64.811    0.974
##    21.222    0.990
##    52.186    0.994
##   738.733    0.997
##    40.972    0.962
## 
## Defined Parameters:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower ci.upper
##     ab                0.071    0.073    0.972    0.331   -0.072    0.213
##     cd               -0.020    0.049   -0.399    0.690   -0.117    0.077
##     ef                0.034    0.059    0.576    0.565   -0.081    0.149
##     gh                0.128    0.153    0.838    0.402   -0.172    0.428
##     total             1.171    0.747    1.567    0.117   -0.294    2.636
##    Std.lv  Std.all
##     0.071    0.007
##    -0.020   -0.002
##     0.034    0.003
##     0.128    0.012
##     1.171    0.114
semPaths(fit_milk_adj_mlm)

fluid adjusted MLM

model_fluid_mlm <- ' # direct effect
             BMSi ~ i*fluid + age_final + female_b2 + PA_SCORE_b2 + vitd_top + BMI_b2 + alcohol_freq_8yr
           # mediator
             IL6 ~ a*fluid + diabetes_bone2
             TNFa ~ c*fluid + diabetes_bone2
             IL1B ~ e*fluid + diabetes_bone2
             CRP ~ g*fluid + diabetes_bone2
             BMSi ~ b*IL6 
             BMSi ~ d*TNFa 
             BMSi ~ f*IL1B
             BMSi ~ h*CRP
           # indirect effect (a*b)
             ab := a*b
             cd := c*d
             ef := e*f
             gh := g*h
           # total effect
             total := i + (a*b) +(c*d) +(e*f) +(g*h)
         '
fit_fluid_adj_mlm <- sem(model_fluid_mlm, data = db, estimator = "MLM")
summary(fit_fluid_adj_mlm, fit.measures=TRUE, standardized=TRUE, ci=TRUE)
## lavaan 0.6-18 ended normally after 1 iteration
## 
##   Estimator                                         ML
##   Optimization method                           NLMINB
##   Number of model parameters                        24
## 
##                                                   Used       Total
##   Number of observations                           135         163
## 
## Model Test User Model:
##                                               Standard      Scaled
##   Test Statistic                                58.940      53.094
##   Degrees of freedom                                31          31
##   P-value (Chi-square)                           0.002       0.008
##   Scaling correction factor                                  1.110
##     Satorra-Bentler correction                                    
## 
## Model Test Baseline Model:
## 
##   Test statistic                                85.243      84.143
##   Degrees of freedom                                50          50
##   P-value                                        0.001       0.002
##   Scaling correction factor                                  1.013
## 
## User Model versus Baseline Model:
## 
##   Comparative Fit Index (CFI)                    0.207       0.353
##   Tucker-Lewis Index (TLI)                      -0.279      -0.044
##                                                                   
##   Robust Comparative Fit Index (CFI)                         0.291
##   Robust Tucker-Lewis Index (TLI)                           -0.144
## 
## Loglikelihood and Information Criteria:
## 
##   Loglikelihood user model (H0)              -2418.397   -2418.397
##   Loglikelihood unrestricted model (H1)      -2388.927   -2388.927
##                                                                   
##   Akaike (AIC)                                4884.794    4884.794
##   Bayesian (BIC)                              4954.521    4954.521
##   Sample-size adjusted Bayesian (SABIC)       4878.601    4878.601
## 
## Root Mean Square Error of Approximation:
## 
##   RMSEA                                          0.082       0.073
##   90 Percent confidence interval - lower         0.049       0.039
##   90 Percent confidence interval - upper         0.113       0.104
##   P-value H_0: RMSEA <= 0.050                    0.055       0.119
##   P-value H_0: RMSEA >= 0.080                    0.562       0.373
##                                                                   
##   Robust RMSEA                                               0.077
##   90 Percent confidence interval - lower                     0.039
##   90 Percent confidence interval - upper                     0.111
##   P-value H_0: Robust RMSEA <= 0.050                         0.108
##   P-value H_0: Robust RMSEA >= 0.080                         0.463
## 
## Standardized Root Mean Square Residual:
## 
##   SRMR                                           0.067       0.067
## 
## Parameter Estimates:
## 
##   Standard errors                           Robust.sem
##   Information                                 Expected
##   Information saturated (h1) model          Structured
## 
## Regressions:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower ci.upper
##   BMSi ~                                                                
##     fluid      (i)    1.733    0.783    2.215    0.027    0.199    3.267
##     age_final        -0.196    0.106   -1.852    0.064   -0.404    0.011
##     female_b2        -0.154    1.871   -0.083    0.934   -3.822    3.514
##     PA_SCORE_2        0.170    0.116    1.468    0.142   -0.057    0.397
##     vitd_top         -0.075    0.129   -0.578    0.564   -0.327    0.178
##     BMI_b2           -0.278    0.124   -2.244    0.025   -0.521   -0.035
##     alchl_fr_8       -0.135    1.466   -0.092    0.926   -3.009    2.739
##   IL6 ~                                                                 
##     fluid      (a)   -0.546    0.287   -1.904    0.057   -1.108    0.016
##     diabts_bn2       -0.443    0.818   -0.541    0.588   -2.045    1.160
##   TNFa ~                                                                
##     fluid      (c)    0.777    0.830    0.936    0.349   -0.849    2.403
##     diabts_bn2        1.591    1.281    1.242    0.214   -0.920    4.102
##   IL1B ~                                                                
##     fluid      (e)   -1.519    2.818   -0.539    0.590   -7.041    4.004
##     diabts_bn2       -5.714    4.680   -1.221    0.222  -14.885    3.458
##   CRP ~                                                                 
##     fluid      (g)   -1.424    0.494   -2.881    0.004   -2.393   -0.455
##     diabts_bn2        1.110    0.992    1.120    0.263   -0.833    3.053
##   BMSi ~                                                                
##     IL6        (b)   -0.166    0.106   -1.570    0.116   -0.373    0.041
##     TNFa       (d)   -0.057    0.061   -0.944    0.345   -0.177    0.062
##     IL1B       (f)   -0.028    0.029   -0.959    0.338   -0.084    0.029
##     CRP        (h)   -0.004    0.086   -0.041    0.967   -0.171    0.164
##    Std.lv  Std.all
##                   
##     1.733    0.179
##    -0.196   -0.157
##    -0.154   -0.008
##     0.170    0.122
##    -0.075   -0.051
##    -0.278   -0.191
##    -0.135   -0.009
##                   
##    -0.546   -0.096
##    -0.443   -0.045
##                   
##     0.777    0.089
##     1.591    0.107
##                   
##    -1.519   -0.047
##    -5.714   -0.102
##                   
##    -1.424   -0.183
##     1.110    0.083
##                   
##    -0.166   -0.098
##    -0.057   -0.052
##    -0.028   -0.093
##    -0.004   -0.003
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower ci.upper
##    .BMSi             60.485    7.626    7.931    0.000   45.538   75.433
##    .IL6              23.428   14.825    1.580    0.114   -5.629   52.486
##    .TNFa             54.173   20.270    2.673    0.008   14.445   93.901
##    .IL1B            766.246  161.047    4.758    0.000  450.600 1081.892
##    .CRP              42.465   11.570    3.670    0.000   19.789   65.141
##    Std.lv  Std.all
##    60.485    0.889
##    23.428    0.989
##    54.173    0.982
##   766.246    0.988
##    42.465    0.958
## 
## Defined Parameters:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower ci.upper
##     ab                0.090    0.062    1.465    0.143   -0.031    0.212
##     cd               -0.045    0.055   -0.813    0.416   -0.152    0.063
##     ef                0.042    0.073    0.571    0.568   -0.102    0.185
##     gh                0.005    0.122    0.041    0.967   -0.234    0.244
##     total             1.826    0.771    2.369    0.018    0.316    3.337
##    Std.lv  Std.all
##     0.090    0.009
##    -0.045   -0.005
##     0.042    0.004
##     0.005    0.001
##     1.826    0.189
semPaths(fit_fluid_adj_mlm)

total adjusted MLM

model_total_mlm <- ' # direct effect
             BMSi ~ i*mod + age_final + female_b2 + PA_SCORE_b2 + vitd_top + BMI_b2 + alcohol_freq_8yr
           # mediator
             IL6 ~ a*mod + diabetes_bone2
             TNFa ~ c*mod + diabetes_bone2
             IL1B ~ e*mod + diabetes_bone2
             CRP ~ g*mod + diabetes_bone2
             BMSi ~ b*IL6
             BMSi ~ d*TNFa
             BMSi ~ f*IL1B
             BMSi ~ h*CRP
           # indirect effect (a*b)
             ab := a*b
             cd := c*d
             ef := e*f
             gh := g*h
           # total effect
             total := i + (a*b) +(c*d) +(e*f) +(g*h)
         '
fit_total_adj_mlm <- sem(model_total_mlm, data = db, estimator="MLM")
summary(fit_total_adj_mlm,fit.measures=TRUE, standardized=TRUE,ci=TRUE)
## lavaan 0.6-18 ended normally after 1 iteration
## 
##   Estimator                                         ML
##   Optimization method                           NLMINB
##   Number of model parameters                        24
## 
##                                                   Used       Total
##   Number of observations                           135         163
## 
## Model Test User Model:
##                                               Standard      Scaled
##   Test Statistic                                57.896      52.391
##   Degrees of freedom                                31          31
##   P-value (Chi-square)                           0.002       0.010
##   Scaling correction factor                                  1.105
##     Satorra-Bentler correction                                    
## 
## Model Test Baseline Model:
## 
##   Test statistic                                84.737      83.749
##   Degrees of freedom                                50          50
##   P-value                                        0.002       0.002
##   Scaling correction factor                                  1.012
## 
## User Model versus Baseline Model:
## 
##   Comparative Fit Index (CFI)                    0.226       0.366
##   Tucker-Lewis Index (TLI)                      -0.249      -0.022
##                                                                   
##   Robust Comparative Fit Index (CFI)                         0.308
##   Robust Tucker-Lewis Index (TLI)                           -0.117
## 
## Loglikelihood and Information Criteria:
## 
##   Loglikelihood user model (H0)              -2418.128   -2418.128
##   Loglikelihood unrestricted model (H1)      -2389.180   -2389.180
##                                                                   
##   Akaike (AIC)                                4884.256    4884.256
##   Bayesian (BIC)                              4953.983    4953.983
##   Sample-size adjusted Bayesian (SABIC)       4878.062    4878.062
## 
## Root Mean Square Error of Approximation:
## 
##   RMSEA                                          0.080       0.071
##   90 Percent confidence interval - lower         0.047       0.037
##   90 Percent confidence interval - upper         0.112       0.103
##   P-value H_0: RMSEA <= 0.050                    0.064       0.132
##   P-value H_0: RMSEA >= 0.080                    0.530       0.351
##                                                                   
##   Robust RMSEA                                               0.075
##   90 Percent confidence interval - lower                     0.037
##   90 Percent confidence interval - upper                     0.110
##   P-value H_0: Robust RMSEA <= 0.050                         0.120
##   P-value H_0: Robust RMSEA >= 0.080                         0.437
## 
## Standardized Root Mean Square Residual:
## 
##   SRMR                                           0.066       0.066
## 
## Parameter Estimates:
## 
##   Standard errors                           Robust.sem
##   Information                                 Expected
##   Information saturated (h1) model          Structured
## 
## Regressions:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower ci.upper
##   BMSi ~                                                                
##     mod        (i)    1.817    0.776    2.342    0.019    0.296    3.337
##     age_final        -0.189    0.104   -1.819    0.069   -0.394    0.015
##     female_b2        -0.232    1.888   -0.123    0.902   -3.932    3.469
##     PA_SCORE_2        0.162    0.117    1.381    0.167   -0.068    0.391
##     vitd_top         -0.087    0.131   -0.665    0.506   -0.344    0.169
##     BMI_b2           -0.270    0.124   -2.181    0.029   -0.512   -0.027
##     alchl_fr_8       -0.082    1.499   -0.055    0.956   -3.020    2.856
##   IL6 ~                                                                 
##     mod        (a)   -0.473    0.300   -1.579    0.114   -1.061    0.114
##     diabts_bn2       -0.441    0.825   -0.534    0.593   -2.058    1.177
##   TNFa ~                                                                
##     mod        (c)    0.535    0.841    0.636    0.525   -1.113    2.183
##     diabts_bn2        1.576    1.299    1.213    0.225   -0.970    4.121
##   IL1B ~                                                                
##     mod        (e)   -1.622    2.851   -0.569    0.569   -7.210    3.965
##     diabts_bn2       -5.738    4.679   -1.226    0.220  -14.908    3.433
##   CRP ~                                                                 
##     mod        (g)   -1.599    0.501   -3.190    0.001   -2.582   -0.617
##     diabts_bn2        1.080    0.986    1.096    0.273   -0.852    3.012
##   BMSi ~                                                                
##     IL6        (b)   -0.171    0.111   -1.544    0.123   -0.387    0.046
##     TNFa       (d)   -0.052    0.062   -0.833    0.405   -0.173    0.070
##     IL1B       (f)   -0.027    0.029   -0.929    0.353   -0.083    0.030
##     CRP        (h)   -0.002    0.085   -0.021    0.984   -0.169    0.166
##    Std.lv  Std.all
##                   
##     1.817    0.187
##    -0.189   -0.151
##    -0.232   -0.012
##     0.162    0.116
##    -0.087   -0.060
##    -0.270   -0.185
##    -0.082   -0.005
##                   
##    -0.473   -0.082
##    -0.441   -0.045
##                   
##     0.535    0.061
##     1.576    0.106
##                   
##    -1.622   -0.049
##    -5.738   -0.103
##                   
##    -1.599   -0.203
##     1.080    0.081
##                   
##    -0.171   -0.101
##    -0.052   -0.047
##    -0.027   -0.090
##    -0.002   -0.001
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower ci.upper
##    .BMSi             60.362    7.525    8.021    0.000   45.613   75.111
##    .IL6              23.485   14.841    1.582    0.114   -5.604   52.574
##    .TNFa             54.407   20.368    2.671    0.008   14.487   94.327
##    .IL1B            766.040  160.722    4.766    0.000  451.031 1081.048
##    .CRP              42.110   11.469    3.672    0.000   19.632   64.588
##    Std.lv  Std.all
##    60.362    0.887
##    23.485    0.992
##    54.407    0.986
##   766.040    0.988
##    42.110    0.950
## 
## Defined Parameters:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower ci.upper
##     ab                0.081    0.052    1.561    0.118   -0.021    0.182
##     cd               -0.028    0.047   -0.588    0.557   -0.120    0.065
##     ef                0.043    0.072    0.603    0.547   -0.098    0.185
##     gh                0.003    0.137    0.021    0.984   -0.265    0.271
##     total             1.916    0.775    2.474    0.013    0.398    3.434
##    Std.lv  Std.all
##     0.081    0.008
##    -0.028   -0.003
##     0.043    0.004
##     0.003    0.000
##     1.916    0.197
semPaths(fit_total_adj_mlm)

skim adj MLM

model_skim_TBS_mlm <- ' # direct effect
             TBSL1L2L3L4_final ~ i*skim + age_final + female_b2 + PA_SCORE_b2 + vitd_top + BMI_b2 + alcohol_freq_8yr
           # mediator
             IL6 ~ a*skim + diabetes_bone2
             TNFa ~ c*skim + diabetes_bone2
             IL1B ~ e*skim + diabetes_bone2
             CRP ~ g*skim + diabetes_bone2
             TBSL1L2L3L4_final ~ b*IL6 
             TBSL1L2L3L4_final ~ d*TNFa
             TBSL1L2L3L4_final ~ f*IL1B
             TBSL1L2L3L4_final ~ h*CRP
           # indirect effect (a*b)
             ab := a*b
             cd := c*d
             ef := e*f
             gh :=g*h
           # total effect
             total := i + (a*b) +(c*d) +(e*f) +(g*h)
         '
fit_skim_adj_mlm <- sem(model_skim_TBS_mlm, data = db2, estimator="MLM")
## Warning: lavaan->lav_data_full():  
##    some observed variances are (at least) a factor 1000 times larger than 
##    others; use varTable(fit) to investigate
summary(fit_skim_adj_mlm,fit.measures=TRUE, standardized=TRUE,ci=TRUE)
## lavaan 0.6-18 ended normally after 1 iteration
## 
##   Estimator                                         ML
##   Optimization method                           NLMINB
##   Number of model parameters                        24
## 
##                                                   Used       Total
##   Number of observations                           362         445
## 
## Model Test User Model:
##                                               Standard      Scaled
##   Test Statistic                               105.593      71.423
##   Degrees of freedom                                31          31
##   P-value (Chi-square)                           0.000       0.000
##   Scaling correction factor                                  1.478
##     Satorra-Bentler correction                                    
## 
## Model Test Baseline Model:
## 
##   Test statistic                               133.730     106.042
##   Degrees of freedom                                50          50
##   P-value                                        0.000       0.000
##   Scaling correction factor                                  1.261
## 
## User Model versus Baseline Model:
## 
##   Comparative Fit Index (CFI)                    0.109       0.279
##   Tucker-Lewis Index (TLI)                      -0.437      -0.163
##                                                                   
##   Robust Comparative Fit Index (CFI)                         0.154
##   Robust Tucker-Lewis Index (TLI)                           -0.364
## 
## Loglikelihood and Information Criteria:
## 
##   Loglikelihood user model (H0)              -5446.680   -5446.680
##   Loglikelihood unrestricted model (H1)             NA          NA
##                                                                   
##   Akaike (AIC)                               10941.359   10941.359
##   Bayesian (BIC)                             11034.759   11034.759
##   Sample-size adjusted Bayesian (SABIC)      10958.618   10958.618
## 
## Root Mean Square Error of Approximation:
## 
##   RMSEA                                          0.082       0.060
##   90 Percent confidence interval - lower         0.065       0.045
##   90 Percent confidence interval - upper         0.099       0.075
##   P-value H_0: RMSEA <= 0.050                    0.001       0.130
##   P-value H_0: RMSEA >= 0.080                    0.578       0.014
##                                                                   
##   Robust RMSEA                                               0.073
##   90 Percent confidence interval - lower                     0.051
##   90 Percent confidence interval - upper                     0.095
##   P-value H_0: Robust RMSEA <= 0.050                         0.045
##   P-value H_0: Robust RMSEA >= 0.080                         0.320
## 
## Standardized Root Mean Square Residual:
## 
##   SRMR                                           0.058       0.058
## 
## Parameter Estimates:
## 
##   Standard errors                           Robust.sem
##   Information                                 Expected
##   Information saturated (h1) model          Structured
## 
## Regressions:
##                       Estimate  Std.Err  z-value  P(>|z|) ci.lower ci.upper
##   TBSL1L2L3L4_final ~                                                      
##     skim       (i)      -0.045    0.026   -1.725    0.085   -0.097    0.006
##     age_final           -0.001    0.001   -0.476    0.634   -0.003    0.002
##     female_b2           -0.017    0.019   -0.921    0.357   -0.054    0.019
##     PA_SCORE_2           0.000    0.001    0.168    0.867   -0.002    0.002
##     vitd_top            -0.000    0.001   -0.289    0.772   -0.003    0.002
##     BMI_b2              -0.002    0.001   -1.695    0.090   -0.005    0.000
##     alchl_fr_8           0.003    0.014    0.237    0.812   -0.024    0.031
##   IL6 ~                                                                    
##     skim       (a)       0.529    0.860    0.615    0.539   -1.156    2.213
##     diabts_bn2           0.789    0.578    1.365    0.172   -0.344    1.922
##   TNFa ~                                                                   
##     skim       (c)       0.116    0.659    0.175    0.861   -1.175    1.406
##     diabts_bn2           1.541    0.786    1.962    0.050    0.002    3.081
##   IL1B ~                                                                   
##     skim       (e)       2.011    4.313    0.466    0.641   -6.443   10.464
##     diabts_bn2          -6.216    4.112   -1.512    0.131  -14.275    1.843
##   CRP ~                                                                    
##     skim       (g)      -2.216    0.937   -2.364    0.018   -4.053   -0.379
##     diabts_bn2           2.382    1.106    2.153    0.031    0.214    4.551
##   TBSL1L2L3L4_final ~                                                      
##     IL6        (b)       0.000    0.001    0.315    0.752   -0.002    0.003
##     TNFa       (d)      -0.001    0.001   -0.646    0.518   -0.002    0.001
##     IL1B       (f)       0.000    0.000    1.563    0.118   -0.000    0.001
##     CRP        (h)      -0.000    0.001   -0.288    0.773   -0.001    0.001
##    Std.lv  Std.all
##                   
##    -0.045   -0.125
##    -0.001   -0.024
##    -0.017   -0.047
##     0.000    0.007
##    -0.000   -0.016
##    -0.002   -0.104
##     0.003    0.011
##                   
##     0.529    0.038
##     0.789    0.065
##                   
##     0.116    0.007
##     1.541    0.102
##                   
##     2.011    0.023
##    -6.216   -0.082
##                   
##    -2.216   -0.082
##     2.382    0.102
##                   
##     0.000    0.015
##    -0.001   -0.029
##     0.000    0.058
##    -0.000   -0.011
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower ci.upper
##    .TBSL1L2L3L4_fn    0.023    0.003    8.252    0.000    0.017    0.028
##    .IL6              35.848    9.605    3.732    0.000   17.022   54.674
##    .TNFa             54.779   16.514    3.317    0.001   22.412   87.146
##    .IL1B           1381.734  285.525    4.839    0.000  822.115 1941.353
##    .CRP             129.789   54.993    2.360    0.018   22.005  237.573
##    Std.lv  Std.all
##     0.023    0.963
##    35.848    0.994
##    54.779    0.989
##  1381.734    0.993
##   129.789    0.985
## 
## Defined Parameters:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower ci.upper
##     ab                0.000    0.001    0.299    0.765   -0.001    0.002
##     cd               -0.000    0.000   -0.164    0.870   -0.001    0.001
##     ef                0.000    0.001    0.441    0.659   -0.002    0.003
##     gh                0.000    0.001    0.296    0.767   -0.002    0.003
##     total            -0.044    0.026   -1.707    0.088   -0.095    0.007
##    Std.lv  Std.all
##     0.000    0.001
##    -0.000   -0.000
##     0.000    0.001
##     0.000    0.001
##    -0.044   -0.123
semPaths(fit_skim_adj_mlm)