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 + diabetes_bone2 + PTH_8yr
           # 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 <- 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                        22
## 
##                                                   Used       Total
##   Number of observations                           129         163
## 
## Model Test User Model:
##                                                       
##   Test statistic                                66.495
##   Degrees of freedom                                38
##   P-value (Chi-square)                           0.003
## 
## Model Test Baseline Model:
## 
##   Test statistic                                89.665
##   Degrees of freedom                                55
##   P-value                                        0.002
## 
## User Model versus Baseline Model:
## 
##   Comparative Fit Index (CFI)                    0.178
##   Tucker-Lewis Index (TLI)                      -0.190
## 
## Loglikelihood and Information Criteria:
## 
##   Loglikelihood user model (H0)              -2310.245
##   Loglikelihood unrestricted model (H1)      -2276.997
##                                                       
##   Akaike (AIC)                                4664.489
##   Bayesian (BIC)                              4727.405
##   Sample-size adjusted Bayesian (SABIC)       4657.826
## 
## Root Mean Square Error of Approximation:
## 
##   RMSEA                                          0.076
##   90 Percent confidence interval - lower         0.044
##   90 Percent confidence interval - upper         0.106
##   P-value H_0: RMSEA <= 0.050                    0.082
##   P-value H_0: RMSEA >= 0.080                    0.443
## 
## 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 ~                                                                
##     milk       (i)    2.113    0.957    2.208    0.027    0.237    3.989
##     age_final        -0.188    0.115   -1.626    0.104   -0.414    0.039
##     female_b2        -0.090    1.690   -0.053    0.958   -3.403    3.223
##     PA_SCORE_2        0.139    0.130    1.071    0.284   -0.116    0.394
##     vitd_top         -0.067    0.125   -0.538    0.591   -0.313    0.178
##     BMI_b2           -0.284    0.129   -2.202    0.028   -0.536   -0.031
##     alchl_fr_8       -0.371    1.308   -0.284    0.777   -2.934    2.192
##     diabts_bn2       -0.057    1.429   -0.040    0.968   -2.859    2.744
##     PTH_8yr           0.015    0.018    0.870    0.384   -0.019    0.050
##   IL6 ~                                                                 
##     milk       (a)   -0.524    0.554   -0.946    0.344   -1.610    0.562
##   TNFa ~                                                                
##     milk       (c)    0.405    0.828    0.489    0.625   -1.219    2.029
##   IL1B ~                                                                
##     milk       (e)   -3.660    3.019   -1.212    0.225   -9.578    2.257
##   CRP ~                                                                 
##     milk       (g)   -1.429    0.734   -1.948    0.051   -2.867    0.009
##   BMSi ~                                                                
##     IL6        (b)   -0.167    0.139   -1.203    0.229   -0.439    0.105
##     TNFa       (d)   -0.063    0.093   -0.675    0.500   -0.244    0.119
##     IL1B       (f)   -0.012    0.025   -0.489    0.625   -0.062    0.037
##     CRP        (h)   -0.017    0.105   -0.163    0.870   -0.222    0.188
##    Std.lv  Std.all
##                   
##     2.113    0.199
##    -0.188   -0.146
##    -0.090   -0.005
##     0.139    0.097
##    -0.067   -0.047
##    -0.284   -0.194
##    -0.371   -0.025
##    -0.057   -0.003
##     0.015    0.080
##                   
##    -0.524   -0.083
##                   
##     0.405    0.043
##                   
##    -3.660   -0.106
##                   
##    -1.429   -0.169
##                   
##    -0.167   -0.099
##    -0.063   -0.056
##    -0.012   -0.041
##    -0.017   -0.014
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower ci.upper
##    .BMSi             60.442    7.526    8.031    0.000   45.692   75.193
##    .IL6              24.348    3.032    8.031    0.000   18.406   30.289
##    .TNFa             54.423    6.776    8.031    0.000   41.141   67.704
##    .IL1B            722.966   90.020    8.031    0.000  546.531  899.402
##    .CRP              42.696    5.316    8.031    0.000   32.276   53.115
##    Std.lv  Std.all
##    60.442    0.876
##    24.348    0.993
##    54.423    0.998
##   722.966    0.989
##    42.696    0.971
## 
## Defined Parameters:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower ci.upper
##     ab                0.087    0.118    0.744    0.457   -0.143    0.318
##     cd               -0.025    0.064   -0.396    0.692   -0.151    0.100
##     ef                0.046    0.100    0.454    0.650   -0.151    0.242
##     gh                0.024    0.150    0.162    0.871   -0.270    0.319
##     total             2.245    0.944    2.378    0.017    0.395    4.095
##    Std.lv  Std.all
##     0.087    0.008
##    -0.025   -0.002
##     0.046    0.004
##     0.024    0.002
##     2.245    0.212
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 + diabetes_bone2 + PTH_8yr
           # mediator
             log_IL6 ~ a*milk
             log_tnf ~ c*milk
             log_il1B ~ e*milk
             log_crp ~ g*milk
             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                        22
## 
##                                                   Used       Total
##   Number of observations                           129         163
## 
## Model Test User Model:
##                                                       
##   Test statistic                                64.192
##   Degrees of freedom                                38
##   P-value (Chi-square)                           0.005
## 
## Model Test Baseline Model:
## 
##   Test statistic                                94.414
##   Degrees of freedom                                55
##   P-value                                        0.001
## 
## User Model versus Baseline Model:
## 
##   Comparative Fit Index (CFI)                    0.335
##   Tucker-Lewis Index (TLI)                       0.038
## 
## Loglikelihood and Information Criteria:
## 
##   Loglikelihood user model (H0)              -1109.626
##   Loglikelihood unrestricted model (H1)      -1077.530
##                                                       
##   Akaike (AIC)                                2263.251
##   Bayesian (BIC)                              2326.167
##   Sample-size adjusted Bayesian (SABIC)       2256.588
## 
## Root Mean Square Error of Approximation:
## 
##   RMSEA                                          0.073
##   90 Percent confidence interval - lower         0.040
##   90 Percent confidence interval - upper         0.103
##   P-value H_0: RMSEA <= 0.050                    0.111
##   P-value H_0: RMSEA >= 0.080                    0.378
## 
## Standardized Root Mean Square Residual:
## 
##   SRMR                                           0.070
## 
## 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)    2.062    0.942    2.188    0.029    0.214    3.909
##     age_final        -0.215    0.113   -1.903    0.057   -0.436    0.006
##     female_b2         0.104    1.656    0.063    0.950   -3.141    3.348
##     PA_SCORE_2        0.177    0.127    1.391    0.164   -0.073    0.427
##     vitd_top         -0.046    0.123   -0.377    0.706   -0.287    0.194
##     BMI_b2           -0.315    0.126   -2.497    0.013   -0.562   -0.068
##     alchl_fr_8       -0.654    1.281   -0.510    0.610   -3.164    1.856
##     diabts_bn2       -0.105    1.400   -0.075    0.940   -2.848    2.639
##     PTH_8yr           0.010    0.017    0.590    0.555   -0.024    0.044
##   log_IL6 ~                                                             
##     milk       (a)   -0.104    0.104   -0.996    0.319   -0.307    0.100
##   log_tnf ~                                                             
##     milk       (c)    0.034    0.059    0.578    0.564   -0.081    0.149
##   log_il1B ~                                                            
##     milk       (e)   -0.190    0.105   -1.814    0.070   -0.395    0.015
##   log_crp ~                                                             
##     milk       (g)   -0.275    0.147   -1.864    0.062   -0.563    0.014
##   BMSi ~                                                                
##     log_IL6    (b)   -1.633    0.724   -2.257    0.024   -3.051   -0.215
##     log_tnf    (d)   -0.976    1.282   -0.762    0.446   -3.488    1.536
##     log_il1B   (f)   -0.931    0.719   -1.296    0.195   -2.340    0.478
##     log_crp    (h)    0.665    0.511    1.301    0.193   -0.337    1.667
##    Std.lv  Std.all
##                   
##     2.062    0.192
##    -0.215   -0.165
##     0.104    0.005
##     0.177    0.122
##    -0.046   -0.032
##    -0.315   -0.213
##    -0.654   -0.043
##    -0.105   -0.006
##     0.010    0.052
##                   
##    -0.104   -0.087
##                   
##     0.034    0.051
##                   
##    -0.190   -0.158
##                   
##    -0.275   -0.162
##                   
##    -1.633   -0.181
##    -0.976   -0.061
##    -0.931   -0.105
##     0.665    0.105
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower ci.upper
##    .BMSi             57.971    7.218    8.031    0.000   43.824   72.119
##    .log_IL6           0.858    0.107    8.031    0.000    0.649    1.068
##    .log_tnf           0.274    0.034    8.031    0.000    0.207    0.340
##    .log_il1B          0.870    0.108    8.031    0.000    0.657    1.082
##    .log_crp           1.721    0.214    8.031    0.000    1.301    2.141
##    Std.lv  Std.all
##    57.971    0.822
##     0.858    0.992
##     0.274    0.997
##     0.870    0.975
##     1.721    0.974
## 
## Defined Parameters:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower ci.upper
##     ab                0.169    0.186    0.911    0.362   -0.195    0.533
##     cd               -0.033    0.072   -0.460    0.645   -0.174    0.108
##     ef                0.177    0.168    1.054    0.292   -0.152    0.506
##     gh               -0.183    0.171   -1.067    0.286   -0.518    0.153
##     total             2.192    0.945    2.319    0.020    0.339    4.045
##    Std.lv  Std.all
##     0.169    0.016
##    -0.033   -0.003
##     0.177    0.017
##    -0.183   -0.017
##     2.192    0.205
semPaths(fit_milk_adj_log)

Fluid dairy adjusted

model_fluid_adj <- ' # direct effect
             BMSi ~ i*fluid + age_final + female_b2 + BMI_b2 + alcohol_freq_8yr + diabetes_bone2 + PTH_8yr
           # 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_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                        20
## 
##                                                   Used       Total
##   Number of observations                           130         163
## 
## Model Test User Model:
##                                                       
##   Test statistic                                45.777
##   Degrees of freedom                                30
##   P-value (Chi-square)                           0.033
## 
## Model Test Baseline Model:
## 
##   Test statistic                                66.074
##   Degrees of freedom                                45
##   P-value                                        0.022
## 
## User Model versus Baseline Model:
## 
##   Comparative Fit Index (CFI)                    0.251
##   Tucker-Lewis Index (TLI)                      -0.123
## 
## Loglikelihood and Information Criteria:
## 
##   Loglikelihood user model (H0)              -2329.073
##   Loglikelihood unrestricted model (H1)      -2306.185
##                                                       
##   Akaike (AIC)                                4698.146
##   Bayesian (BIC)                              4755.497
##   Sample-size adjusted Bayesian (SABIC)       4692.241
## 
## Root Mean Square Error of Approximation:
## 
##   RMSEA                                          0.064
##   90 Percent confidence interval - lower         0.019
##   90 Percent confidence interval - upper         0.099
##   P-value H_0: RMSEA <= 0.050                    0.255
##   P-value H_0: RMSEA >= 0.080                    0.244
## 
## Standardized Root Mean Square Residual:
## 
##   SRMR                                           0.065
## 
## 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.702    0.893    1.906    0.057   -0.048    3.452
##     age_final        -0.159    0.116   -1.371    0.170   -0.385    0.068
##     female_b2        -0.444    1.709   -0.260    0.795   -3.794    2.906
##     BMI_b2           -0.270    0.128   -2.115    0.034   -0.520   -0.020
##     alchl_fr_8       -0.482    1.288   -0.374    0.708   -3.007    2.043
##     diabts_bn2        0.269    1.443    0.186    0.852   -2.560    3.097
##     PTH_8yr           0.022    0.017    1.295    0.195   -0.011    0.056
##   IL6 ~                                                                 
##     fluid      (a)   -0.468    0.515   -0.910    0.363   -1.477    0.540
##   TNFa ~                                                                
##     fluid      (c)    0.437    0.772    0.566    0.572   -1.077    1.950
##   IL1B ~                                                                
##     fluid      (e)   -3.135    2.808   -1.116    0.264   -8.639    2.370
##   CRP ~                                                                 
##     fluid      (g)   -1.335    0.681   -1.959    0.050   -2.670    0.000
##   BMSi ~                                                                
##     IL6        (b)   -0.127    0.140   -0.906    0.365   -0.403    0.148
##     TNFa       (d)   -0.077    0.094   -0.822    0.411   -0.260    0.107
##     IL1B       (f)   -0.014    0.026   -0.550    0.582   -0.065    0.036
##     CRP        (h)   -0.045    0.106   -0.429    0.668   -0.253    0.162
##    Std.lv  Std.all
##                   
##     1.702    0.172
##    -0.159   -0.124
##    -0.444   -0.023
##    -0.270   -0.184
##    -0.482   -0.032
##     0.269    0.016
##     0.022    0.114
##                   
##    -0.468   -0.080
##                   
##     0.437    0.050
##                   
##    -3.135   -0.097
##                   
##    -1.335   -0.169
##                   
##    -0.127   -0.076
##    -0.077   -0.068
##    -0.014   -0.046
##    -0.045   -0.036
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower ci.upper
##    .BMSi             62.098    7.702    8.062    0.000   47.002   77.194
##    .IL6              24.209    3.003    8.062    0.000   18.324   30.095
##    .TNFa             54.502    6.760    8.062    0.000   41.252   67.752
##    .IL1B            721.090   89.440    8.062    0.000  545.791  896.390
##    .CRP              42.439    5.264    8.062    0.000   32.122   52.756
##    Std.lv  Std.all
##    62.098    0.900
##    24.209    0.994
##    54.502    0.998
##   721.090    0.991
##    42.439    0.971
## 
## Defined Parameters:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower ci.upper
##     ab                0.060    0.093    0.642    0.521   -0.122    0.242
##     cd               -0.034    0.072   -0.466    0.641   -0.175    0.108
##     ef                0.044    0.090    0.493    0.622   -0.132    0.221
##     gh                0.061    0.145    0.419    0.675   -0.223    0.345
##     total             1.833    0.880    2.082    0.037    0.107    3.559
##    Std.lv  Std.all
##     0.060    0.006
##    -0.034   -0.003
##     0.044    0.004
##     0.061    0.006
##     1.833    0.185
semPaths(fit_fluid_adj)

Fluid dairy adjusted w/ log transformed mediators

model_fluid_adj_log <- ' # direct effect
             BMSi ~ i*fluid + age_final + female_b2 + BMI_b2 + alcohol_freq_8yr + diabetes_bone2 + PTH_8yr
           # mediator
             log_IL6 ~ a*fluid
             log_tnf ~ c*fluid
             log_il1B ~ e*fluid
             log_crp ~ g*fluid
             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                        20
## 
##                                                   Used       Total
##   Number of observations                           130         163
## 
## Model Test User Model:
##                                                       
##   Test statistic                                52.080
##   Degrees of freedom                                30
##   P-value (Chi-square)                           0.007
## 
## Model Test Baseline Model:
## 
##   Test statistic                                77.604
##   Degrees of freedom                                45
##   P-value                                        0.002
## 
## User Model versus Baseline Model:
## 
##   Comparative Fit Index (CFI)                    0.323
##   Tucker-Lewis Index (TLI)                      -0.016
## 
## Loglikelihood and Information Criteria:
## 
##   Loglikelihood user model (H0)              -1121.111
##   Loglikelihood unrestricted model (H1)      -1095.071
##                                                       
##   Akaike (AIC)                                2282.222
##   Bayesian (BIC)                              2339.572
##   Sample-size adjusted Bayesian (SABIC)       2276.317
## 
## Root Mean Square Error of Approximation:
## 
##   RMSEA                                          0.075
##   90 Percent confidence interval - lower         0.039
##   90 Percent confidence interval - upper         0.109
##   P-value H_0: RMSEA <= 0.050                    0.113
##   P-value H_0: RMSEA >= 0.080                    0.436
## 
## Standardized Root Mean Square Residual:
## 
##   SRMR                                           0.072
## 
## 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.698    0.881    1.926    0.054   -0.030    3.425
##     age_final        -0.184    0.114   -1.614    0.107   -0.407    0.039
##     female_b2        -0.256    1.682   -0.152    0.879   -3.552    3.040
##     BMI_b2           -0.308    0.126   -2.450    0.014   -0.554   -0.061
##     alchl_fr_8       -0.755    1.267   -0.595    0.552   -3.239    1.729
##     diabts_bn2        0.264    1.420    0.186    0.853   -2.519    3.046
##     PTH_8yr           0.019    0.017    1.132    0.258   -0.014    0.052
##   log_IL6 ~                                                             
##     fluid      (a)   -0.083    0.097   -0.851    0.395   -0.273    0.108
##   log_tnf ~                                                             
##     fluid      (c)    0.039    0.055    0.710    0.478   -0.069    0.147
##   log_il1B ~                                                            
##     fluid      (e)   -0.158    0.097   -1.618    0.106   -0.349    0.033
##   log_crp ~                                                             
##     fluid      (g)   -0.251    0.137   -1.837    0.066   -0.519    0.017
##   BMSi ~                                                                
##     log_IL6    (b)   -1.345    0.732   -1.838    0.066   -2.779    0.089
##     log_tnf    (d)   -1.389    1.294   -1.073    0.283   -3.925    1.147
##     log_il1B   (f)   -0.976    0.730   -1.338    0.181   -2.406    0.454
##     log_crp    (h)    0.448    0.520    0.861    0.389   -0.572    1.467
##    Std.lv  Std.all
##                   
##     1.698    0.170
##    -0.184   -0.143
##    -0.256   -0.013
##    -0.308   -0.208
##    -0.755   -0.050
##     0.264    0.016
##     0.019    0.097
##                   
##    -0.083   -0.074
##                   
##     0.039    0.062
##                   
##    -0.158   -0.140
##                   
##    -0.251   -0.159
##                   
##    -1.345   -0.150
##    -1.389   -0.087
##    -0.976   -0.110
##     0.448    0.071
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower ci.upper
##    .BMSi             60.101    7.455    8.062    0.000   45.490   74.712
##    .log_IL6           0.864    0.107    8.062    0.000    0.654    1.074
##    .log_tnf           0.276    0.034    8.062    0.000    0.209    0.343
##    .log_il1B          0.869    0.108    8.062    0.000    0.658    1.080
##    .log_crp           1.710    0.212    8.062    0.000    1.294    2.125
##    Std.lv  Std.all
##    60.101    0.860
##     0.864    0.994
##     0.276    0.996
##     0.869    0.980
##     1.710    0.975
## 
## Defined Parameters:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower ci.upper
##     ab                0.111    0.144    0.772    0.440   -0.171    0.393
##     cd               -0.054    0.092   -0.592    0.554   -0.234    0.125
##     ef                0.154    0.149    1.031    0.302   -0.139    0.447
##     gh               -0.112    0.144   -0.779    0.436   -0.395    0.170
##     total             1.796    0.881    2.039    0.041    0.070    3.523
##    Std.lv  Std.all
##     0.111    0.011
##    -0.054   -0.005
##     0.154    0.015
##    -0.112   -0.011
##     1.796    0.180
semPaths(fit_fluid_adj_log)

Total dairy adjusted

model_total_adj <- ' # direct effect
             BMSi ~ i*mod + age_final + female_b2 + BMI_b2 + alcohol_freq_8yr + diabetes_bone2 + PTH_8yr
           # 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_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 9 iterations
## 
##   Estimator                                         ML
##   Optimization method                           NLMINB
##   Number of model parameters                        20
## 
##                                                   Used       Total
##   Number of observations                           130         163
## 
## Model Test User Model:
##                                                       
##   Test statistic                                45.543
##   Degrees of freedom                                30
##   P-value (Chi-square)                           0.034
## 
## Model Test Baseline Model:
## 
##   Test statistic                                66.804
##   Degrees of freedom                                45
##   P-value                                        0.019
## 
## User Model versus Baseline Model:
## 
##   Comparative Fit Index (CFI)                    0.287
##   Tucker-Lewis Index (TLI)                      -0.069
## 
## Loglikelihood and Information Criteria:
## 
##   Loglikelihood user model (H0)              -2328.592
##   Loglikelihood unrestricted model (H1)      -2305.820
##                                                       
##   Akaike (AIC)                                4697.183
##   Bayesian (BIC)                              4754.534
##   Sample-size adjusted Bayesian (SABIC)       4691.278
## 
## Root Mean Square Error of Approximation:
## 
##   RMSEA                                          0.063
##   90 Percent confidence interval - lower         0.018
##   90 Percent confidence interval - upper         0.098
##   P-value H_0: RMSEA <= 0.050                    0.262
##   P-value H_0: RMSEA >= 0.080                    0.237
## 
## Standardized Root Mean Square Residual:
## 
##   SRMR                                           0.065
## 
## 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.848    0.904    2.045    0.041    0.077    3.619
##     age_final        -0.154    0.115   -1.340    0.180   -0.379    0.071
##     female_b2        -0.579    1.714   -0.338    0.736   -3.938    2.781
##     BMI_b2           -0.260    0.128   -2.040    0.041   -0.511   -0.010
##     alchl_fr_8       -0.391    1.292   -0.303    0.762   -2.923    2.140
##     diabts_bn2        0.261    1.440    0.182    0.856   -2.560    3.083
##     PTH_8yr           0.023    0.017    1.321    0.186   -0.011    0.056
##   IL6 ~                                                                 
##     mod        (a)   -0.381    0.519   -0.734    0.463   -1.398    0.636
##   TNFa ~                                                                
##     mod        (c)    0.236    0.778    0.303    0.762   -1.290    1.761
##   IL1B ~                                                                
##     mod        (e)   -3.363    2.826   -1.190    0.234   -8.903    2.176
##   CRP ~                                                                 
##     mod        (g)   -1.473    0.684   -2.154    0.031   -2.814   -0.133
##   BMSi ~                                                                
##     IL6        (b)   -0.129    0.140   -0.925    0.355   -0.404    0.145
##     TNFa       (d)   -0.072    0.093   -0.767    0.443   -0.255    0.111
##     IL1B       (f)   -0.013    0.026   -0.507    0.612   -0.063    0.037
##     CRP        (h)   -0.041    0.106   -0.382    0.703   -0.249    0.168
##    Std.lv  Std.all
##                   
##     1.848    0.185
##    -0.154   -0.120
##    -0.579   -0.031
##    -0.260   -0.177
##    -0.391   -0.026
##     0.261    0.016
##     0.023    0.116
##                   
##    -0.381   -0.064
##                   
##     0.236    0.027
##                   
##    -3.363   -0.104
##                   
##    -1.473   -0.186
##                   
##    -0.129   -0.077
##    -0.072   -0.064
##    -0.013   -0.042
##    -0.041   -0.032
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower ci.upper
##    .BMSi             61.842    7.671    8.062    0.000   46.808   76.876
##    .IL6              24.263    3.009    8.062    0.000   18.365   30.161
##    .TNFa             54.598    6.772    8.062    0.000   41.325   67.871
##    .IL1B            720.157   89.324    8.062    0.000  545.084  895.230
##    .CRP              42.187    5.233    8.062    0.000   31.931   52.442
##    Std.lv  Std.all
##    61.842    0.896
##    24.263    0.996
##    54.598    0.999
##   720.157    0.989
##    42.187    0.966
## 
## Defined Parameters:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower ci.upper
##     ab                0.049    0.086    0.575    0.565   -0.119    0.217
##     cd               -0.017    0.060   -0.282    0.778   -0.134    0.100
##     ef                0.044    0.094    0.467    0.641   -0.140    0.228
##     gh                0.060    0.159    0.376    0.707   -0.252    0.371
##     total             1.984    0.889    2.231    0.026    0.241    3.727
##    Std.lv  Std.all
##     0.049    0.005
##    -0.017   -0.002
##     0.044    0.004
##     0.060    0.006
##     1.984    0.199
semPaths(fit_total_adj)

##total adjusted with log transformed mediators

model_total_adj_log <- ' # direct effect
             BMSi ~ i*mod + age_final + female_b2 + BMI_b2 + alcohol_freq_8yr + diabetes_bone2 + PTH_8yr
           # mediator
             log_IL6 ~ a*mod
             log_tnf ~ c*mod
             log_il1B ~ e*mod
             log_crp ~ g*mod
             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                        20
## 
##                                                   Used       Total
##   Number of observations                           130         163
## 
## Model Test User Model:
##                                                       
##   Test statistic                                51.790
##   Degrees of freedom                                30
##   P-value (Chi-square)                           0.008
## 
## Model Test Baseline Model:
## 
##   Test statistic                                78.790
##   Degrees of freedom                                45
##   P-value                                        0.001
## 
## User Model versus Baseline Model:
## 
##   Comparative Fit Index (CFI)                    0.355
##   Tucker-Lewis Index (TLI)                       0.033
## 
## Loglikelihood and Information Criteria:
## 
##   Loglikelihood user model (H0)              -1120.373
##   Loglikelihood unrestricted model (H1)      -1094.478
##                                                       
##   Akaike (AIC)                                2280.747
##   Bayesian (BIC)                              2338.097
##   Sample-size adjusted Bayesian (SABIC)       2274.841
## 
## Root Mean Square Error of Approximation:
## 
##   RMSEA                                          0.075
##   90 Percent confidence interval - lower         0.038
##   90 Percent confidence interval - upper         0.108
##   P-value H_0: RMSEA <= 0.050                    0.118
##   P-value H_0: RMSEA >= 0.080                    0.427
## 
## Standardized Root Mean Square Residual:
## 
##   SRMR                                           0.072
## 
## 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.841    0.893    2.061    0.039    0.090    3.592
##     age_final        -0.178    0.113   -1.578    0.115   -0.399    0.043
##     female_b2        -0.403    1.686   -0.239    0.811   -3.708    2.903
##     BMI_b2           -0.298    0.126   -2.373    0.018   -0.544   -0.052
##     alchl_fr_8       -0.666    1.271   -0.524    0.600   -3.157    1.824
##     diabts_bn2        0.263    1.416    0.186    0.853   -2.513    3.039
##     PTH_8yr           0.019    0.017    1.155    0.248   -0.014    0.052
##   log_IL6 ~                                                             
##     mod        (a)   -0.083    0.098   -0.844    0.399   -0.274    0.109
##   log_tnf ~                                                             
##     mod        (c)    0.034    0.055    0.609    0.542   -0.075    0.142
##   log_il1B ~                                                            
##     mod        (e)   -0.166    0.098   -1.695    0.090   -0.358    0.026
##   log_crp ~                                                             
##     mod        (g)   -0.283    0.137   -2.061    0.039   -0.552   -0.014
##   BMSi ~                                                                
##     log_IL6    (b)   -1.332    0.730   -1.824    0.068   -2.763    0.099
##     log_tnf    (d)   -1.370    1.291   -1.062    0.288   -3.900    1.159
##     log_il1B   (f)   -0.942    0.729   -1.293    0.196   -2.371    0.486
##     log_crp    (h)    0.467    0.521    0.897    0.369   -0.553    1.488
##    Std.lv  Std.all
##                   
##     1.841    0.183
##    -0.178   -0.138
##    -0.403   -0.021
##    -0.298   -0.202
##    -0.666   -0.044
##     0.263    0.016
##     0.019    0.099
##                   
##    -0.083   -0.074
##                   
##     0.034    0.053
##                   
##    -0.166   -0.147
##                   
##    -0.283   -0.178
##                   
##    -1.332   -0.149
##    -1.370   -0.086
##    -0.942   -0.106
##     0.467    0.074
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower ci.upper
##    .BMSi             59.861    7.425    8.062    0.000   45.309   74.413
##    .log_IL6           0.864    0.107    8.062    0.000    0.654    1.074
##    .log_tnf           0.276    0.034    8.062    0.000    0.209    0.344
##    .log_il1B          0.867    0.108    8.062    0.000    0.656    1.078
##    .log_crp           1.699    0.211    8.062    0.000    1.286    2.111
##    Std.lv  Std.all
##    59.861    0.857
##     0.864    0.995
##     0.276    0.997
##     0.867    0.978
##     1.699    0.968
## 
## Defined Parameters:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower ci.upper
##     ab                0.110    0.144    0.766    0.444   -0.171    0.392
##     cd               -0.046    0.087   -0.528    0.597   -0.218    0.125
##     ef                0.157    0.152    1.028    0.304   -0.142    0.455
##     gh               -0.132    0.161   -0.823    0.411   -0.447    0.183
##     total             1.929    0.890    2.168    0.030    0.185    3.673
##    Std.lv  Std.all
##     0.110    0.011
##    -0.046   -0.005
##     0.157    0.016
##    -0.132   -0.013
##     1.929    0.192
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_skim <- 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_skim,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_skim)

###Adjusted skim

model_skim_adj_TBS <- ' # direct effect
             TBSL1L2L3L4_final ~ i*skim + age_final + female_b2 + vitd_top + BMI_b2 + alcohol_freq_8yr + diabetes_bone2 + bone6f_b2
           # 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_skim_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_skim_adj,fit.measures=TRUE, standardized=TRUE, ci=TRUE )
## lavaan 0.6-18 ended normally after 78 iterations
## 
##   Estimator                                         ML
##   Optimization method                           NLMINB
##   Number of model parameters                        21
## 
##                                                   Used       Total
##   Number of observations                           362         445
## 
## Model Test User Model:
##                                                       
##   Test statistic                               116.466
##   Degrees of freedom                                34
##   P-value (Chi-square)                           0.000
## 
## Model Test Baseline Model:
## 
##   Test statistic                               143.150
##   Degrees of freedom                                50
##   P-value                                        0.000
## 
## User Model versus Baseline Model:
## 
##   Comparative Fit Index (CFI)                    0.115
##   Tucker-Lewis Index (TLI)                      -0.302
## 
## Loglikelihood and Information Criteria:
## 
##   Loglikelihood user model (H0)              -5447.407
##   Loglikelihood unrestricted model (H1)             NA
##                                                       
##   Akaike (AIC)                               10936.813
##   Bayesian (BIC)                             11018.538
##   Sample-size adjusted Bayesian (SABIC)      10951.914
## 
## Root Mean Square Error of Approximation:
## 
##   RMSEA                                          0.082
##   90 Percent confidence interval - lower         0.066
##   90 Percent confidence interval - upper         0.098
##   P-value H_0: RMSEA <= 0.050                    0.001
##   P-value H_0: RMSEA >= 0.080                    0.593
## 
## Standardized Root Mean Square Residual:
## 
##   SRMR                                           0.061
## 
## 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.039    0.019   -2.086    0.037   -0.076   -0.002
##     age_final           -0.000    0.001   -0.094    0.925   -0.002    0.002
##     female_b2           -0.015    0.020   -0.768    0.442   -0.053    0.023
##     vitd_top            -0.001    0.001   -0.507    0.612   -0.003    0.002
##     BMI_b2              -0.002    0.001   -1.954    0.051   -0.005    0.000
##     alchl_fr_8           0.001    0.015    0.083    0.934   -0.028    0.031
##     diabts_bn2          -0.033    0.016   -2.007    0.045   -0.065   -0.001
##     bone6f_b2           -0.056    0.024   -2.342    0.019   -0.103   -0.009
##   IL6 ~                                                                    
##     skim       (a)       0.637    0.740    0.861    0.389   -0.813    2.087
##   TNFa ~                                                                   
##     skim       (c)       0.328    0.917    0.357    0.721   -1.470    2.125
##   IL1B ~                                                                   
##     skim       (e)       1.156    4.598    0.251    0.802   -7.856   10.167
##   CRP ~                                                                    
##     skim       (g)      -1.888    1.412   -1.337    0.181   -4.655    0.879
##   TBSL1L2L3L4_final ~                                                      
##     IL6        (b)       0.000    0.001    0.165    0.869   -0.002    0.003
##     TNFa       (d)      -0.000    0.001   -0.198    0.843   -0.002    0.002
##     IL1B       (f)       0.000    0.000    1.084    0.278   -0.000    0.001
##     CRP        (h)      -0.000    0.001   -0.190    0.850   -0.001    0.001
##    Std.lv  Std.all
##                   
##    -0.039   -0.108
##    -0.000   -0.005
##    -0.015   -0.041
##    -0.001   -0.026
##    -0.002   -0.105
##     0.001    0.004
##    -0.033   -0.105
##    -0.056   -0.121
##                   
##     0.637    0.045
##                   
##     0.328    0.019
##                   
##     1.156    0.013
##                   
##    -1.888   -0.070
##                   
##     0.000    0.008
##    -0.000   -0.010
##     0.000    0.055
##    -0.000   -0.010
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower ci.upper
##    .TBSL1L2L3L4_fn    0.022    0.002   13.454    0.000    0.019    0.026
##    .IL6              35.996    2.676   13.454    0.000   30.752   41.240
##    .TNFa             55.346    4.114   13.454    0.000   47.283   63.409
##    .IL1B           1390.927  103.387   13.454    0.000 1188.293 1593.562
##    .CRP             131.141    9.748   13.454    0.000  112.036  150.246
##    Std.lv  Std.all
##     0.022    0.938
##    35.996    0.998
##    55.346    1.000
##  1390.927    1.000
##   131.141    0.995
## 
## Defined Parameters:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower ci.upper
##     ab                0.000    0.001    0.162    0.871   -0.002    0.002
##     cd               -0.000    0.000   -0.173    0.863   -0.001    0.001
##     ef                0.000    0.001    0.245    0.807   -0.002    0.002
##     gh                0.000    0.001    0.188    0.851   -0.002    0.003
##     total            -0.038    0.019   -2.060    0.039   -0.075   -0.002
##    Std.lv  Std.all
##     0.000    0.000
##    -0.000   -0.000
##     0.000    0.001
##     0.000    0.001
##    -0.038   -0.106
semPaths(fit2_skim_adj)

No-fat(skim) dichotomized (since right-skewed) as predictor var, TBS as response var; IL6, TNFa, IL1B, CRP as individual mediators

model_skim_dichot_TBS <- ' # direct effect
             TBSL1L2L3L4_final ~ i*skim_dichot 
           # mediator
             IL6 ~ a*skim_dichot
             TNFa ~ c*skim_dichot
             IL1B ~ e*skim_dichot
             CRP ~ g*skim_dichot
             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_skim_dichot <- sem(model_skim_dichot_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_skim_dichot,fit.measures=TRUE, standardized=TRUE, ci=TRUE )
## lavaan 0.6-18 ended normally after 47 iterations
## 
##   Estimator                                         ML
##   Optimization method                           NLMINB
##   Number of model parameters                        14
## 
##                                                   Used       Total
##   Number of observations                           396         445
## 
## Model Test User Model:
##                                                       
##   Test statistic                                79.433
##   Degrees of freedom                                 6
##   P-value (Chi-square)                           0.000
## 
## Model Test Baseline Model:
## 
##   Test statistic                                83.302
##   Degrees of freedom                                15
##   P-value                                        0.000
## 
## User Model versus Baseline Model:
## 
##   Comparative Fit Index (CFI)                    0.000
##   Tucker-Lewis Index (TLI)                      -1.688
## 
## Loglikelihood and Information Criteria:
## 
##   Loglikelihood user model (H0)              -5944.685
##   Loglikelihood unrestricted model (H1)      -5904.968
##                                                       
##   Akaike (AIC)                               11917.370
##   Bayesian (BIC)                             11973.110
##   Sample-size adjusted Bayesian (SABIC)      11928.688
## 
## Root Mean Square Error of Approximation:
## 
##   RMSEA                                          0.176
##   90 Percent confidence interval - lower         0.143
##   90 Percent confidence interval - upper         0.211
##   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.098
## 
## 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_dicht (i)       0.060    0.152    0.393    0.694   -0.238    0.358
##   IL6 ~                                                                    
##     skim_dicht (a)       1.661    5.784    0.287    0.774   -9.676   12.998
##   TNFa ~                                                                   
##     skim_dicht (c)       4.146    7.262    0.571    0.568  -10.088   18.380
##   IL1B ~                                                                   
##     skim_dicht (e)      31.606   38.501    0.821    0.412  -43.854  107.067
##   CRP ~                                                                    
##     skim_dicht (g)       1.490   11.239    0.133    0.895  -20.538   23.518
##   TBSL1L2L3L4_final ~                                                      
##     IL6        (b)       0.000    0.001    0.096    0.924   -0.002    0.003
##     TNFa       (d)      -0.001    0.001   -0.623    0.533   -0.003    0.001
##     IL1B       (f)       0.000    0.000    1.435    0.151   -0.000    0.001
##     CRP        (h)      -0.000    0.001   -0.375    0.707   -0.002    0.001
##    Std.lv  Std.all
##                   
##     0.060    0.020
##                   
##     1.661    0.014
##                   
##     4.146    0.029
##                   
##    31.606    0.041
##                   
##     1.490    0.007
##                   
##     0.000    0.005
##    -0.001   -0.031
##     0.000    0.072
##    -0.000   -0.019
## 
## 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.374    2.372   14.071    0.000   28.726   38.023
##    .TNFa             52.607    3.739   14.071    0.000   45.279   59.935
##    .IL1B           1478.570  105.077   14.071    0.000 1272.622 1684.518
##    .CRP             125.996    8.954   14.071    0.000  108.446  143.546
##    Std.lv  Std.all
##     0.023    0.993
##    33.374    1.000
##    52.607    0.999
##  1478.570    0.998
##   125.996    1.000
## 
## Defined Parameters:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower ci.upper
##     ab                0.000    0.002    0.091    0.928   -0.004    0.005
##     cd               -0.003    0.006   -0.421    0.674   -0.015    0.010
##     ef                0.009    0.013    0.713    0.476   -0.016    0.034
##     gh               -0.000    0.003   -0.125    0.901   -0.006    0.006
##     total             0.066    0.152    0.433    0.665   -0.233    0.365
##    Std.lv  Std.all
##     0.000    0.000
##    -0.003   -0.001
##     0.009    0.003
##    -0.000   -0.000
##     0.066    0.022
semPaths(fit2_skim_dichot)

#skim_dichot adjusted with TBS

model_skim_dichot_adj_TBS <- ' # direct effect
             TBSL1L2L3L4_final ~ i*skim_dichot + age_final + female_b2 + vitd_top + BMI_b2 + alcohol_freq_8yr + diabetes_bone2 + bone6f_b2
           # mediator
             IL6 ~ a*skim_dichot
             TNFa ~ c*skim_dichot
             IL1B ~ e*skim_dichot
             CRP ~ g*skim_dichot
             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_skim_dichot_adj <- sem(model_skim_dichot_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_skim_dichot_adj,fit.measures=TRUE, standardized=TRUE, ci=TRUE )
## lavaan 0.6-18 ended normally after 65 iterations
## 
##   Estimator                                         ML
##   Optimization method                           NLMINB
##   Number of model parameters                        21
## 
##                                                   Used       Total
##   Number of observations                           362         445
## 
## Model Test User Model:
##                                                       
##   Test statistic                               114.280
##   Degrees of freedom                                34
##   P-value (Chi-square)                           0.000
## 
## Model Test Baseline Model:
## 
##   Test statistic                               135.301
##   Degrees of freedom                                50
##   P-value                                        0.000
## 
## User Model versus Baseline Model:
## 
##   Comparative Fit Index (CFI)                    0.059
##   Tucker-Lewis Index (TLI)                      -0.384
## 
## Loglikelihood and Information Criteria:
## 
##   Loglikelihood user model (H0)              -5450.238
##   Loglikelihood unrestricted model (H1)             NA
##                                                       
##   Akaike (AIC)                               10942.475
##   Bayesian (BIC)                             11024.200
##   Sample-size adjusted Bayesian (SABIC)      10957.576
## 
## Root Mean Square Error of Approximation:
## 
##   RMSEA                                          0.081
##   90 Percent confidence interval - lower         0.065
##   90 Percent confidence interval - upper         0.097
##   P-value H_0: RMSEA <= 0.050                    0.001
##   P-value H_0: RMSEA >= 0.080                    0.550
## 
## Standardized Root Mean Square Residual:
## 
##   SRMR                                           0.061
## 
## 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_dicht (i)       0.074    0.151    0.488    0.625   -0.223    0.371
##     age_final           -0.000    0.001   -0.108    0.914   -0.002    0.002
##     female_b2           -0.018    0.020   -0.916    0.359   -0.057    0.021
##     vitd_top            -0.001    0.001   -0.658    0.511   -0.004    0.002
##     BMI_b2              -0.003    0.001   -1.966    0.049   -0.005   -0.000
##     alchl_fr_8           0.003    0.015    0.191    0.848   -0.027    0.033
##     diabts_bn2          -0.037    0.016   -2.260    0.024   -0.069   -0.005
##     bone6f_b2           -0.057    0.024   -2.383    0.017   -0.105   -0.010
##   IL6 ~                                                                    
##     skim_dicht (a)       1.745    6.013    0.290    0.772  -10.042   13.531
##   TNFa ~                                                                   
##     skim_dicht (c)       4.137    7.448    0.555    0.579  -10.461   18.734
##   IL1B ~                                                                   
##     skim_dicht (e)      31.338   37.314    0.840    0.401  -41.796  104.471
##   CRP ~                                                                    
##     skim_dicht (g)       1.581   11.496    0.138    0.891  -20.950   24.112
##   TBSL1L2L3L4_final ~                                                      
##     IL6        (b)      -0.000    0.001   -0.028    0.977   -0.003    0.003
##     TNFa       (d)      -0.000    0.001   -0.225    0.822   -0.002    0.002
##     IL1B       (f)       0.000    0.000    1.022    0.307   -0.000    0.001
##     CRP        (h)       0.000    0.001    0.059    0.953   -0.001    0.001
##    Std.lv  Std.all
##                   
##     0.074    0.025
##    -0.000   -0.006
##    -0.018   -0.049
##    -0.001   -0.034
##    -0.003   -0.106
##     0.003    0.010
##    -0.037   -0.118
##    -0.057   -0.124
##                   
##     1.745    0.015
##                   
##     4.137    0.029
##                   
##    31.338    0.044
##                   
##     1.581    0.007
##                   
##    -0.000   -0.001
##    -0.000   -0.012
##     0.000    0.052
##     0.000    0.003
## 
## 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
##    .IL6              36.062    2.680   13.454    0.000   30.808   41.315
##    .TNFa             55.318    4.112   13.454    0.000   47.259   63.377
##    .IL1B           1388.476  103.205   13.454    0.000 1186.199 1590.754
##    .CRP             131.783    9.795   13.454    0.000  112.584  150.981
##    Std.lv  Std.all
##     0.023    0.948
##    36.062    1.000
##    55.318    0.999
##  1388.476    0.998
##   131.783    1.000
## 
## Defined Parameters:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower ci.upper
##     ab               -0.000    0.002   -0.028    0.977   -0.005    0.004
##     cd               -0.001    0.005   -0.208    0.835   -0.010    0.008
##     ef                0.007    0.010    0.649    0.516   -0.014    0.027
##     gh                0.000    0.001    0.054    0.957   -0.002    0.002
##     total             0.080    0.151    0.527    0.598   -0.217    0.377
##    Std.lv  Std.all
##    -0.000   -0.000
##    -0.001   -0.000
##     0.007    0.002
##     0.000    0.000
##     0.080    0.027
semPaths(fit2_skim_dichot_adj)

skim & tbs adjusted with log tranformed inflammatory cytokines (bone6f = Ca supp)

model_skim_TBS_log <- ' # direct effect
             TBSL1L2L3L4_final ~ i*skim + age_final + female_b2 + vitd_top + BMI_b2 + alcohol_freq_8yr + diabetes_bone2 + bone6f_b2
           # mediator
             log_IL6 ~ a*skim
             log_tnf ~ c*skim
             log_il1B ~ e*skim
             log_crp ~ g*skim
             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 46 iterations
## 
##   Estimator                                         ML
##   Optimization method                           NLMINB
##   Number of model parameters                        21
## 
##                                                   Used       Total
##   Number of observations                           362         445
## 
## Model Test User Model:
##                                                       
##   Test statistic                               129.948
##   Degrees of freedom                                34
##   P-value (Chi-square)                           0.000
## 
## Model Test Baseline Model:
## 
##   Test statistic                               160.209
##   Degrees of freedom                                50
##   P-value                                        0.000
## 
## User Model versus Baseline Model:
## 
##   Comparative Fit Index (CFI)                    0.129
##   Tucker-Lewis Index (TLI)                      -0.280
## 
## Loglikelihood and Information Criteria:
## 
##   Loglikelihood user model (H0)              -1720.033
##   Loglikelihood unrestricted model (H1)             NA
##                                                       
##   Akaike (AIC)                                3482.065
##   Bayesian (BIC)                              3563.790
##   Sample-size adjusted Bayesian (SABIC)       3497.166
## 
## Root Mean Square Error of Approximation:
## 
##   RMSEA                                          0.088
##   90 Percent confidence interval - lower         0.073
##   90 Percent confidence interval - upper         0.105
##   P-value H_0: RMSEA <= 0.050                    0.000
##   P-value H_0: RMSEA >= 0.080                    0.813
## 
## 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
##   TBSL1L2L3L4_final ~                                                      
##     skim       (i)      -0.041    0.019   -2.198    0.028   -0.078   -0.004
##     age_final           -0.000    0.001   -0.080    0.936   -0.002    0.002
##     female_b2           -0.015    0.020   -0.747    0.455   -0.053    0.024
##     vitd_top            -0.001    0.001   -0.515    0.607   -0.003    0.002
##     BMI_b2              -0.002    0.001   -1.528    0.127   -0.004    0.001
##     alchl_fr_8           0.004    0.015    0.288    0.773   -0.025    0.034
##     diabts_bn2          -0.032    0.016   -1.954    0.051   -0.064    0.000
##     bone6f_b2           -0.053    0.024   -2.218    0.027   -0.100   -0.006
##   log_IL6 ~                                                                
##     skim       (a)       0.036    0.136    0.268    0.789   -0.230    0.302
##   log_tnf ~                                                                
##     skim       (c)       0.062    0.062    1.002    0.316   -0.060    0.184
##   log_il1B ~                                                               
##     skim       (e)      -0.051    0.110   -0.465    0.642   -0.267    0.165
##   log_crp ~                                                                
##     skim       (g)      -0.214    0.160   -1.332    0.183   -0.528    0.101
##   TBSL1L2L3L4_final ~                                                      
##     log_IL6    (b)       0.009    0.007    1.242    0.214   -0.005    0.023
##     log_tnf    (d)      -0.006    0.015   -0.390    0.696   -0.036    0.024
##     log_il1B   (f)       0.004    0.009    0.426    0.670   -0.013    0.021
##     log_crp    (h)      -0.013    0.006   -2.112    0.035   -0.024   -0.001
##    Std.lv  Std.all
##                   
##    -0.041   -0.113
##    -0.000   -0.004
##    -0.015   -0.040
##    -0.001   -0.027
##    -0.002   -0.082
##     0.004    0.015
##    -0.032   -0.102
##    -0.053   -0.114
##                   
##     0.036    0.014
##                   
##     0.062    0.053
##                   
##    -0.051   -0.024
##                   
##    -0.214   -0.070
##                   
##     0.009    0.063
##    -0.006   -0.020
##     0.004    0.022
##    -0.013   -0.107
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower ci.upper
##    .TBSL1L2L3L4_fn    0.022    0.002   13.454    0.000    0.019    0.025
##    .log_IL6           1.210    0.090   13.454    0.000    1.034    1.387
##    .log_tnf           0.255    0.019   13.454    0.000    0.218    0.292
##    .log_il1B          0.798    0.059   13.454    0.000    0.682    0.914
##    .log_crp           1.693    0.126   13.454    0.000    1.447    1.940
##    Std.lv  Std.all
##     0.022    0.931
##     1.210    1.000
##     0.255    0.997
##     0.798    0.999
##     1.693    0.995
## 
## Defined Parameters:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower ci.upper
##     ab                0.000    0.001    0.262    0.794   -0.002    0.003
##     cd               -0.000    0.001   -0.364    0.716   -0.002    0.002
##     ef               -0.000    0.001   -0.314    0.754   -0.001    0.001
##     total            -0.039    0.019   -2.057    0.040   -0.075   -0.002
##    Std.lv  Std.all
##     0.000    0.001
##    -0.000   -0.001
##    -0.000   -0.001
##    -0.039   -0.107
semPaths(fit_skim_log)

#skim_dichot adjusted with TBS and log transformed mediators

model_skim_dichot_log_adj_TBS <- ' # direct effect
             TBSL1L2L3L4_final ~ i*skim_dichot + age_final + female_b2 + vitd_top + BMI_b2 + alcohol_freq_8yr + diabetes_bone2 + bone6f_b2
           # mediator
             log_IL6 ~ a*skim_dichot
             log_tnf ~ c*skim_dichot
             log_il1B ~ e*skim_dichot
             log_crp ~ g*skim_dichot
             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
             gh := g*h
           # total effect
             total := i + (a*b) +(c*d) +(e*f) +(g*h)
         '
fit2_skim_dichot_log_adj <- sem(model_skim_dichot_log_adj_TBS, data = db2)
summary(fit2_skim_dichot_log_adj,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                        21
## 
##                                                   Used       Total
##   Number of observations                           362         445
## 
## Model Test User Model:
##                                                       
##   Test statistic                               130.759
##   Degrees of freedom                                34
##   P-value (Chi-square)                           0.000
## 
## Model Test Baseline Model:
## 
##   Test statistic                               155.880
##   Degrees of freedom                                50
##   P-value                                        0.000
## 
## User Model versus Baseline Model:
## 
##   Comparative Fit Index (CFI)                    0.086
##   Tucker-Lewis Index (TLI)                      -0.344
## 
## Loglikelihood and Information Criteria:
## 
##   Loglikelihood user model (H0)              -1722.603
##   Loglikelihood unrestricted model (H1)             NA
##                                                       
##   Akaike (AIC)                                3487.206
##   Bayesian (BIC)                              3568.930
##   Sample-size adjusted Bayesian (SABIC)       3502.307
## 
## Root Mean Square Error of Approximation:
## 
##   RMSEA                                          0.089
##   90 Percent confidence interval - lower         0.073
##   90 Percent confidence interval - upper         0.105
##   P-value H_0: RMSEA <= 0.050                    0.000
##   P-value H_0: RMSEA >= 0.080                    0.823
## 
## 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
##   TBSL1L2L3L4_final ~                                                      
##     skim_dicht (i)       0.070    0.151    0.463    0.643   -0.226    0.366
##     age_final           -0.000    0.001   -0.088    0.930   -0.002    0.002
##     female_b2           -0.018    0.020   -0.903    0.367   -0.056    0.021
##     vitd_top            -0.001    0.001   -0.648    0.517   -0.003    0.002
##     BMI_b2              -0.002    0.001   -1.554    0.120   -0.004    0.001
##     alchl_fr_8           0.006    0.015    0.383    0.702   -0.024    0.036
##     diabts_bn2          -0.036    0.016   -2.203    0.028   -0.068   -0.004
##     bone6f_b2           -0.054    0.024   -2.266    0.023   -0.101   -0.007
##   log_IL6 ~                                                                
##     skim_dicht (a)       0.075    1.102    0.068    0.946   -2.085    2.234
##   log_tnf ~                                                                
##     skim_dicht (c)       0.393    0.506    0.777    0.437   -0.599    1.385
##   log_il1B ~                                                               
##     skim_dicht (e)       1.186    0.893    1.328    0.184   -0.564    2.935
##   log_crp ~                                                                
##     skim_dicht (g)      -0.484    1.306   -0.371    0.711   -3.044    2.076
##   TBSL1L2L3L4_final ~                                                      
##     log_IL6    (b)       0.008    0.007    1.180    0.238   -0.006    0.022
##     log_tnf    (d)      -0.008    0.016   -0.489    0.625   -0.038    0.023
##     log_il1B   (f)       0.004    0.009    0.416    0.677   -0.014    0.021
##     log_crp    (h)      -0.011    0.006   -1.876    0.061   -0.023    0.001
##    Std.lv  Std.all
##                   
##     0.070    0.024
##    -0.000   -0.005
##    -0.018   -0.049
##    -0.001   -0.034
##    -0.002   -0.084
##     0.006    0.020
##    -0.036   -0.115
##    -0.054   -0.118
##                   
##     0.075    0.004
##                   
##     0.393    0.041
##                   
##     1.186    0.070
##                   
##    -0.484   -0.019
##                   
##     0.008    0.060
##    -0.008   -0.025
##     0.004    0.021
##    -0.011   -0.096
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower ci.upper
##    .TBSL1L2L3L4_fn    0.022    0.002   13.454    0.000    0.019    0.026
##    .log_IL6           1.211    0.090   13.454    0.000    1.034    1.387
##    .log_tnf           0.256    0.019   13.454    0.000    0.218    0.293
##    .log_il1B          0.795    0.059   13.454    0.000    0.679    0.910
##    .log_crp           1.701    0.126   13.454    0.000    1.453    1.949
##    Std.lv  Std.all
##     0.022    0.944
##     1.211    1.000
##     0.256    0.998
##     0.795    0.995
##     1.701    1.000
## 
## Defined Parameters:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower ci.upper
##     ab                0.001    0.009    0.068    0.946   -0.018    0.019
##     cd               -0.003    0.007   -0.414    0.679   -0.017    0.011
##     ef                0.004    0.011    0.397    0.691   -0.017    0.026
##     gh                0.005    0.015    0.364    0.716   -0.024    0.035
##     total             0.078    0.152    0.511    0.610   -0.220    0.375
##    Std.lv  Std.all
##     0.001    0.000
##    -0.003   -0.001
##     0.004    0.001
##     0.005    0.002
##     0.078    0.026
semPaths(fit2_skim_dichot_log_adj)

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(fit_fat)

###fat and TBS adjusted with log transformed mediators

model_fat_adj_TBS_log <- ' # direct effect
             TBSL1L2L3L4_final ~ i*fat + age_final + female_b2 + vitd_top + BMI_b2 + alcohol_freq_8yr + diabetes_bone2 + bone6f_b2
           # 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_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 52 iterations
## 
##   Estimator                                         ML
##   Optimization method                           NLMINB
##   Number of model parameters                        21
## 
##                                                   Used       Total
##   Number of observations                           362         445
## 
## Model Test User Model:
##                                                       
##   Test statistic                               130.922
##   Degrees of freedom                                34
##   P-value (Chi-square)                           0.000
## 
## Model Test Baseline Model:
## 
##   Test statistic                               162.003
##   Degrees of freedom                                50
##   P-value                                        0.000
## 
## User Model versus Baseline Model:
## 
##   Comparative Fit Index (CFI)                    0.135
##   Tucker-Lewis Index (TLI)                      -0.273
## 
## Loglikelihood and Information Criteria:
## 
##   Loglikelihood user model (H0)              -1719.623
##   Loglikelihood unrestricted model (H1)             NA
##                                                       
##   Akaike (AIC)                                3481.246
##   Bayesian (BIC)                              3562.971
##   Sample-size adjusted Bayesian (SABIC)       3496.347
## 
## Root Mean Square Error of Approximation:
## 
##   RMSEA                                          0.089
##   90 Percent confidence interval - lower         0.073
##   90 Percent confidence interval - upper         0.105
##   P-value H_0: RMSEA <= 0.050                    0.000
##   P-value H_0: RMSEA >= 0.080                    0.825
## 
## 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
##   TBSL1L2L3L4_final ~                                                      
##     fat        (i)       0.019    0.009    2.062    0.039    0.001    0.037
##     age_final           -0.000    0.001   -0.289    0.773   -0.003    0.002
##     female_b2           -0.020    0.020   -1.020    0.308   -0.058    0.018
##     vitd_top            -0.002    0.001   -1.206    0.228   -0.004    0.001
##     BMI_b2              -0.002    0.001   -1.574    0.116   -0.004    0.000
##     alchl_fr_8           0.012    0.015    0.759    0.448   -0.018    0.042
##     diabts_bn2          -0.036    0.016   -2.196    0.028   -0.067   -0.004
##     bone6f_b2           -0.050    0.024   -2.088    0.037   -0.097   -0.003
##   log_IL6 ~                                                                
##     fat        (a)      -0.120    0.063   -1.912    0.056   -0.243    0.003
##   log_tnf ~                                                                
##     fat        (c)      -0.015    0.029   -0.511    0.609   -0.072    0.042
##   log_il1B ~                                                               
##     fat        (e)      -0.019    0.051   -0.376    0.707   -0.120    0.081
##   log_crp ~                                                                
##     fat        (g)      -0.049    0.075   -0.654    0.513   -0.195    0.098
##   TBSL1L2L3L4_final ~                                                      
##     log_IL6    (b)       0.010    0.007    1.408    0.159   -0.004    0.024
##     log_tnf    (d)      -0.006    0.015   -0.390    0.697   -0.036    0.024
##     log_il1B   (f)       0.004    0.009    0.513    0.608   -0.013    0.022
##     log_crp    (h)      -0.012    0.006   -1.997    0.046   -0.024   -0.000
##    Std.lv  Std.all
##                   
##     0.019    0.113
##    -0.000   -0.015
##    -0.020   -0.054
##    -0.002   -0.065
##    -0.002   -0.084
##     0.012    0.040
##    -0.036   -0.114
##    -0.050   -0.108
##                   
##    -0.120   -0.100
##                   
##    -0.015   -0.027
##                   
##    -0.019   -0.020
##                   
##    -0.049   -0.034
##                   
##     0.010    0.072
##    -0.006   -0.020
##     0.004    0.026
##    -0.012   -0.101
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower ci.upper
##    .TBSL1L2L3L4_fn    0.022    0.002   13.454    0.000    0.019    0.025
##    .log_IL6           1.199    0.089   13.454    0.000    1.024    1.373
##    .log_tnf           0.256    0.019   13.454    0.000    0.219    0.293
##    .log_il1B          0.798    0.059   13.454    0.000    0.682    0.915
##    .log_crp           1.700    0.126   13.454    0.000    1.452    1.947
##    Std.lv  Std.all
##     0.022    0.931
##     1.199    0.990
##     0.256    0.999
##     0.798    1.000
##     1.700    0.999
## 
## Defined Parameters:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower ci.upper
##     ab               -0.001    0.001   -1.134    0.257   -0.003    0.001
##     cd                0.000    0.000    0.310    0.757   -0.000    0.001
##     ef               -0.000    0.000   -0.303    0.762   -0.001    0.000
##     total             0.018    0.009    1.991    0.047    0.000    0.037
##    Std.lv  Std.all
##    -0.001   -0.007
##     0.000    0.001
##    -0.000   -0.001
##     0.018    0.110
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 +diabetes_bone2 + PTH_8yr
           # 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_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                        22
## 
##                                                   Used       Total
##   Number of observations                           129         163
## 
## Model Test User Model:
##                                               Standard      Scaled
##   Test Statistic                                66.706      67.058
##   Degrees of freedom                                38          38
##   P-value (Chi-square)                           0.003       0.003
##   Scaling correction factor                                  0.995
##     Satorra-Bentler correction                                    
## 
## Model Test Baseline Model:
## 
##   Test statistic                                89.288      96.134
##   Degrees of freedom                                55          55
##   P-value                                        0.002       0.001
##   Scaling correction factor                                  0.929
## 
## User Model versus Baseline Model:
## 
##   Comparative Fit Index (CFI)                    0.163       0.294
##   Tucker-Lewis Index (TLI)                      -0.212      -0.022
##                                                                   
##   Robust Comparative Fit Index (CFI)                         0.243
##   Robust Tucker-Lewis Index (TLI)                           -0.095
## 
## Loglikelihood and Information Criteria:
## 
##   Loglikelihood user model (H0)              -2310.539   -2310.539
##   Loglikelihood unrestricted model (H1)      -2277.186   -2277.186
##                                                                   
##   Akaike (AIC)                                4665.078    4665.078
##   Bayesian (BIC)                              4727.994    4727.994
##   Sample-size adjusted Bayesian (SABIC)       4658.415    4658.415
## 
## Root Mean Square Error of Approximation:
## 
##   RMSEA                                          0.077       0.077
##   90 Percent confidence interval - lower         0.045       0.045
##   90 Percent confidence interval - upper         0.106       0.107
##   P-value H_0: RMSEA <= 0.050                    0.079       0.076
##   P-value H_0: RMSEA >= 0.080                    0.449       0.459
##                                                                   
##   Robust RMSEA                                               0.077
##   90 Percent confidence interval - lower                     0.045
##   90 Percent confidence interval - upper                     0.106
##   P-value H_0: Robust RMSEA <= 0.050                         0.076
##   P-value H_0: Robust RMSEA >= 0.080                         0.455
## 
## Standardized Root Mean Square Residual:
## 
##   SRMR                                           0.069       0.069
## 
## 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.932    0.766    2.522    0.012    0.430    3.433
##     age_final        -0.190    0.114   -1.662    0.096   -0.414    0.034
##     female_b2        -0.168    1.984   -0.085    0.933   -4.056    3.721
##     PA_SCORE_2        0.135    0.127    1.060    0.289   -0.115    0.385
##     vitd_top         -0.069    0.132   -0.527    0.598   -0.328    0.189
##     BMI_b2           -0.287    0.128   -2.237    0.025   -0.539   -0.036
##     alchl_fr_8       -0.364    1.499   -0.243    0.808   -3.303    2.575
##     diabts_bn2       -0.018    1.396   -0.013    0.989   -2.755    2.718
##     PTH_8yr           0.016    0.010    1.532    0.126   -0.004    0.036
##   IL6 ~                                                                 
##     fluid      (a)   -0.463    0.293   -1.579    0.114   -1.038    0.112
##   TNFa ~                                                                
##     fluid      (c)    0.416    0.807    0.516    0.606   -1.166    1.998
##   IL1B ~                                                                
##     fluid      (e)   -3.092    2.400   -1.289    0.198   -7.796    1.611
##   CRP ~                                                                 
##     fluid      (g)   -1.328    0.496   -2.678    0.007   -2.300   -0.356
##   BMSi ~                                                                
##     IL6        (b)   -0.168    0.108   -1.555    0.120   -0.379    0.044
##     TNFa       (d)   -0.064    0.064   -1.004    0.316   -0.189    0.061
##     IL1B       (f)   -0.013    0.029   -0.453    0.650   -0.070    0.044
##     CRP        (h)   -0.018    0.090   -0.204    0.838   -0.195    0.158
##    Std.lv  Std.all
##                   
##     1.932    0.196
##    -0.190   -0.148
##    -0.168   -0.009
##     0.135    0.094
##    -0.069   -0.048
##    -0.287   -0.196
##    -0.364   -0.024
##    -0.018   -0.001
##     0.016    0.080
##                   
##    -0.463   -0.079
##                   
##     0.416    0.047
##                   
##    -3.092   -0.096
##                   
##    -1.328   -0.169
##                   
##    -0.168   -0.100
##    -0.064   -0.057
##    -0.013   -0.043
##    -0.018   -0.015
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower ci.upper
##    .BMSi             60.569    7.849    7.717    0.000   45.185   75.952
##    .IL6              24.364   15.613    1.561    0.119   -6.236   54.965
##    .TNFa             54.401   20.897    2.603    0.009   13.443   95.359
##    .IL1B            724.429  155.183    4.668    0.000  420.277 1028.582
##    .CRP              42.703   12.170    3.509    0.000   18.851   66.555
##    Std.lv  Std.all
##    60.569    0.878
##    24.364    0.994
##    54.401    0.998
##   724.429    0.991
##    42.703    0.972
## 
## Defined Parameters:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower ci.upper
##     ab                0.078    0.060    1.296    0.195   -0.040    0.195
##     cd               -0.027    0.050   -0.530    0.596   -0.125    0.072
##     ef                0.041    0.088    0.465    0.642   -0.132    0.214
##     gh                0.024    0.120    0.203    0.839   -0.211    0.260
##     total             2.048    0.738    2.774    0.006    0.601    3.495
##    Std.lv  Std.all
##     0.078    0.008
##    -0.027   -0.003
##     0.041    0.004
##     0.024    0.002
##     2.048    0.208
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 + diabetes_bone2 + PTH_8yr
           # 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_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 9 iterations
## 
##   Estimator                                         ML
##   Optimization method                           NLMINB
##   Number of model parameters                        22
## 
##                                                   Used       Total
##   Number of observations                           129         163
## 
## Model Test User Model:
##                                               Standard      Scaled
##   Test Statistic                                65.626      66.107
##   Degrees of freedom                                38          38
##   P-value (Chi-square)                           0.004       0.003
##   Scaling correction factor                                  0.993
##     Satorra-Bentler correction                                    
## 
## Model Test Baseline Model:
## 
##   Test statistic                                89.166      96.353
##   Degrees of freedom                                55          55
##   P-value                                        0.002       0.000
##   Scaling correction factor                                  0.925
## 
## User Model versus Baseline Model:
## 
##   Comparative Fit Index (CFI)                    0.191       0.320
##   Tucker-Lewis Index (TLI)                      -0.170       0.016
##                                                                   
##   Robust Comparative Fit Index (CFI)                         0.271
##   Robust Tucker-Lewis Index (TLI)                           -0.055
## 
## Loglikelihood and Information Criteria:
## 
##   Loglikelihood user model (H0)              -2310.060   -2310.060
##   Loglikelihood unrestricted model (H1)      -2277.246   -2277.246
##                                                                   
##   Akaike (AIC)                                4664.119    4664.119
##   Bayesian (BIC)                              4727.035    4727.035
##   Sample-size adjusted Bayesian (SABIC)       4657.456    4657.456
## 
## Root Mean Square Error of Approximation:
## 
##   RMSEA                                          0.075       0.076
##   90 Percent confidence interval - lower         0.043       0.044
##   90 Percent confidence interval - upper         0.105       0.106
##   P-value H_0: RMSEA <= 0.050                    0.092       0.087
##   P-value H_0: RMSEA >= 0.080                    0.418       0.432
##                                                                   
##   Robust RMSEA                                               0.075
##   90 Percent confidence interval - lower                     0.044
##   90 Percent confidence interval - upper                     0.105
##   P-value H_0: Robust RMSEA <= 0.050                         0.088
##   P-value H_0: Robust RMSEA >= 0.080                         0.426
## 
## Standardized Root Mean Square Residual:
## 
##   SRMR                                           0.069       0.069
## 
## 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)    2.087    0.739    2.822    0.005    0.637    3.536
##     age_final        -0.185    0.112   -1.651    0.099   -0.405    0.035
##     female_b2        -0.276    1.993   -0.138    0.890   -4.182    3.630
##     PA_SCORE_2        0.120    0.127    0.949    0.343   -0.128    0.369
##     vitd_top         -0.084    0.134   -0.629    0.529   -0.346    0.178
##     BMI_b2           -0.279    0.128   -2.182    0.029   -0.530   -0.028
##     alchl_fr_8       -0.301    1.539   -0.196    0.845   -3.318    2.716
##     diabts_bn2       -0.018    1.396   -0.013    0.990   -2.754    2.718
##     PTH_8yr           0.016    0.010    1.615    0.106   -0.004    0.036
##   IL6 ~                                                                 
##     mod        (a)   -0.372    0.301   -1.235    0.217   -0.963    0.218
##   TNFa ~                                                                
##     mod        (c)    0.200    0.821    0.243    0.808   -1.410    1.809
##   IL1B ~                                                                
##     mod        (e)   -3.292    2.339   -1.407    0.159   -7.877    1.293
##   CRP ~                                                                 
##     mod        (g)   -1.462    0.488   -2.997    0.003   -2.418   -0.506
##   BMSi ~                                                                
##     IL6        (b)   -0.174    0.113   -1.530    0.126   -0.396    0.049
##     TNFa       (d)   -0.058    0.066   -0.881    0.378   -0.186    0.071
##     IL1B       (f)   -0.012    0.029   -0.411    0.681   -0.069    0.045
##     CRP        (h)   -0.018    0.090   -0.198    0.843   -0.194    0.158
##    Std.lv  Std.all
##                   
##     2.087    0.210
##    -0.185   -0.144
##    -0.276   -0.015
##     0.120    0.084
##    -0.084   -0.058
##    -0.279   -0.191
##    -0.301   -0.020
##    -0.018   -0.001
##     0.016    0.085
##                   
##    -0.372   -0.063
##                   
##     0.200    0.023
##                   
##    -3.292   -0.102
##                   
##    -1.462   -0.184
##                   
##    -0.174   -0.103
##    -0.058   -0.051
##    -0.012   -0.039
##    -0.018   -0.014
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower ci.upper
##    .BMSi             60.286    7.713    7.816    0.000   45.169   75.404
##    .IL6              24.420   15.631    1.562    0.118   -6.216   55.055
##    .TNFa             54.495   20.930    2.604    0.009   13.473   95.518
##    .IL1B            723.643  153.841    4.704    0.000  422.120 1025.167
##    .CRP              42.460   12.097    3.510    0.000   18.751   66.170
##    Std.lv  Std.all
##    60.286    0.874
##    24.420    0.996
##    54.495    0.999
##   723.643    0.990
##    42.460    0.966
## 
## Defined Parameters:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower ci.upper
##     ab                0.065    0.050    1.298    0.194   -0.033    0.162
##     cd               -0.012    0.046   -0.250    0.803   -0.102    0.079
##     ef                0.039    0.093    0.422    0.673   -0.144    0.223
##     gh                0.026    0.131    0.198    0.843   -0.232    0.284
##     total             2.205    0.720    3.064    0.002    0.794    3.616
##    Std.lv  Std.all
##     0.065    0.006
##    -0.012   -0.001
##     0.039    0.004
##     0.026    0.003
##     2.205    0.222
semPaths(fit_total_adj_mlm)

skim adj MLM

model_skim_TBS_mlm <- ' # direct effect
             TBSL1L2L3L4_final ~ i*skim + age_final + female_b2 + vitd_top + BMI_b2 + alcohol_freq_8yr + diabetes_bone2 + bone6f_b2
           # 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)
         '
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 78 iterations
## 
##   Estimator                                         ML
##   Optimization method                           NLMINB
##   Number of model parameters                        21
## 
##                                                   Used       Total
##   Number of observations                           362         445
## 
## Model Test User Model:
##                                               Standard      Scaled
##   Test Statistic                               116.466      80.616
##   Degrees of freedom                                34          34
##   P-value (Chi-square)                           0.000       0.000
##   Scaling correction factor                                  1.445
##     Satorra-Bentler correction                                    
## 
## Model Test Baseline Model:
## 
##   Test statistic                               143.150     112.719
##   Degrees of freedom                                50          50
##   P-value                                        0.000       0.000
##   Scaling correction factor                                  1.270
## 
## User Model versus Baseline Model:
## 
##   Comparative Fit Index (CFI)                    0.115       0.257
##   Tucker-Lewis Index (TLI)                      -0.302      -0.093
##                                                                   
##   Robust Comparative Fit Index (CFI)                         0.154
##   Robust Tucker-Lewis Index (TLI)                           -0.243
## 
## Loglikelihood and Information Criteria:
## 
##   Loglikelihood user model (H0)              -5447.407   -5447.407
##   Loglikelihood unrestricted model (H1)             NA          NA
##                                                                   
##   Akaike (AIC)                               10936.813   10936.813
##   Bayesian (BIC)                             11018.538   11018.538
##   Sample-size adjusted Bayesian (SABIC)      10951.914   10951.914
## 
## Root Mean Square Error of Approximation:
## 
##   RMSEA                                          0.082       0.062
##   90 Percent confidence interval - lower         0.066       0.047
##   90 Percent confidence interval - upper         0.098       0.076
##   P-value H_0: RMSEA <= 0.050                    0.001       0.090
##   P-value H_0: RMSEA >= 0.080                    0.593       0.017
##                                                                   
##   Robust RMSEA                                               0.074
##   90 Percent confidence interval - lower                     0.053
##   90 Percent confidence interval - upper                     0.095
##   P-value H_0: Robust RMSEA <= 0.050                         0.030
##   P-value H_0: Robust RMSEA >= 0.080                         0.336
## 
## Standardized Root Mean Square Residual:
## 
##   SRMR                                           0.061       0.061
## 
## 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.039    0.027   -1.434    0.151   -0.092    0.014
##     age_final           -0.000    0.001   -0.102    0.919   -0.002    0.002
##     female_b2           -0.015    0.018   -0.816    0.414   -0.051    0.021
##     vitd_top            -0.001    0.001   -0.478    0.633   -0.003    0.002
##     BMI_b2              -0.002    0.001   -1.704    0.088   -0.005    0.000
##     alchl_fr_8           0.001    0.014    0.090    0.928   -0.026    0.029
##     diabts_bn2          -0.033    0.015   -2.161    0.031   -0.063   -0.003
##     bone6f_b2           -0.056    0.024   -2.372    0.018   -0.102   -0.010
##   IL6 ~                                                                    
##     skim       (a)       0.637    0.870    0.732    0.464   -1.069    2.343
##   TNFa ~                                                                   
##     skim       (c)       0.328    0.606    0.541    0.589   -0.860    1.515
##   IL1B ~                                                                   
##     skim       (e)       1.156    4.323    0.267    0.789   -7.318    9.629
##   CRP ~                                                                    
##     skim       (g)      -1.888    0.866   -2.181    0.029   -3.585   -0.191
##   TBSL1L2L3L4_final ~                                                      
##     IL6        (b)       0.000    0.001    0.180    0.857   -0.002    0.003
##     TNFa       (d)      -0.000    0.001   -0.230    0.818   -0.002    0.002
##     IL1B       (f)       0.000    0.000    1.515    0.130   -0.000    0.001
##     CRP        (h)      -0.000    0.001   -0.251    0.802   -0.001    0.001
##    Std.lv  Std.all
##                   
##    -0.039   -0.108
##    -0.000   -0.005
##    -0.015   -0.041
##    -0.001   -0.026
##    -0.002   -0.105
##     0.001    0.004
##    -0.033   -0.105
##    -0.056   -0.121
##                   
##     0.637    0.045
##                   
##     0.328    0.019
##                   
##     1.156    0.013
##                   
##    -1.888   -0.070
##                   
##     0.000    0.008
##    -0.000   -0.010
##     0.000    0.055
##    -0.000   -0.010
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower ci.upper
##    .TBSL1L2L3L4_fn    0.022    0.003    8.054    0.000    0.017    0.028
##    .IL6              35.996    9.652    3.729    0.000   17.078   54.914
##    .TNFa             55.346   16.624    3.329    0.001   22.763   87.929
##    .IL1B           1390.927  288.394    4.823    0.000  825.685 1956.169
##    .CRP             131.141   55.924    2.345    0.019   21.531  240.751
##    Std.lv  Std.all
##     0.022    0.938
##    35.996    0.998
##    55.346    1.000
##  1390.927    1.000
##   131.141    0.995
## 
## Defined Parameters:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower ci.upper
##     ab                0.000    0.001    0.181    0.856   -0.001    0.002
##     cd               -0.000    0.000   -0.203    0.839   -0.001    0.001
##     ef                0.000    0.001    0.260    0.795   -0.002    0.002
##     gh                0.000    0.001    0.258    0.796   -0.002    0.002
##     total            -0.038    0.027   -1.426    0.154   -0.091    0.014
##    Std.lv  Std.all
##     0.000    0.000
##    -0.000   -0.000
##     0.000    0.001
##     0.000    0.001
##    -0.038   -0.106
semPaths(fit_skim_adj_mlm)