library(MAZE)
#> Loading required package: flexmix
#> Loading required package: lattice
#> Loading required package: numDeriv
#> Loading required package: pracma
#>
#> Attaching package: 'pracma'
#> The following objects are masked from 'package:numDeriv':
#>
#> grad, hessian, jacobian
# load the example dataset "zinb10"
data(zinb10)
# call MAZE() to perform mediation analysis
maze_out <- MAZE(data = zinb10,
distM = c('zilonm', 'zinbm', 'zipm'), K = 1,
selection = 'AIC',
X = 'X', M = 'Mobs', Y = 'Y', Z = NULL,
XMint = c(TRUE, FALSE),
x1 = 0, x2 = 1, zval = NULL, mval = 0,
B = 20, seed = 1)
#> $zilonm_K1
#> $zilonm_K1$init
#> (Intercept) Mobs X
#> 1.78569404 0.12005503 0.00000000 0.85118891 0.00000000 0.95403184
#> (Intercept) X
#> 1.23291057 0.06162764 -0.44558991 -2.21212075 -0.35269450 0.01000000
#>
#> $zilonm_K1$est
#> (Intercept) Mobs X
#> 1.30167999 0.12005557 0.48393825 0.15873694 0.69218518 0.93329877
#> (Intercept) X
#> 1.23217909 0.06211809 -0.44458704 -2.21739677 -0.35363937 2.49329787
#>
#> $zilonm_K1$countEM
#> [1] 33
#>
#> $zilonm_K1$AIC
#> [1] 756.3761
#>
#> $zilonm_K1$BIC
#> [1] 787.6382
#>
#> $zilonm_K1$tau2
#> $zilonm_K1$tau2$tauG1
#> [,1]
#> [1,] 1
#> [2,] 1
#> [3,] 1
#> [4,] 1
#> [5,] 1
#> [6,] 1
#> [7,] 1
#> [8,] 1
#> [9,] 1
#> [10,] 1
#> [11,] 1
#> [12,] 1
#> [13,] 1
#> [14,] 1
#> [15,] 1
#> [16,] 1
#> [17,] 1
#> [18,] 1
#> [19,] 1
#> [20,] 1
#> [21,] 1
#> [22,] 1
#> [23,] 1
#> [24,] 1
#> [25,] 1
#> [26,] 1
#> [27,] 1
#> [28,] 1
#> [29,] 1
#> [30,] 1
#> [31,] 1
#> [32,] 1
#> [33,] 1
#> [34,] 1
#> [35,] 1
#> [36,] 1
#> [37,] 1
#> [38,] 1
#> [39,] 1
#> [40,] 1
#> [41,] 1
#> [42,] 1
#> [43,] 1
#> [44,] 1
#> [45,] 1
#> [46,] 1
#> [47,] 1
#> [48,] 1
#> [49,] 1
#> [50,] 1
#> [51,] 1
#> [52,] 1
#> [53,] 1
#> [54,] 1
#> [55,] 1
#> [56,] 1
#> [57,] 1
#> [58,] 1
#> [59,] 1
#> [60,] 1
#> [61,] 1
#> [62,] 1
#> [63,] 1
#> [64,] 1
#> [65,] 1
#> [66,] 1
#> [67,] 1
#> [68,] 1
#> [69,] 1
#> [70,] 1
#> [71,] 1
#> [72,] 1
#> [73,] 1
#> [74,] 1
#> [75,] 1
#> [76,] 1
#> [77,] 1
#> [78,] 1
#> [79,] 1
#> [80,] 1
#> [81,] 1
#> [82,] 1
#> [83,] 1
#> [84,] 1
#> [85,] 1
#> [86,] 1
#> [87,] 1
#> [88,] 1
#> [89,] 1
#> [90,] 1
#>
#> $zilonm_K1$tau2$tauG2
#> [,1] [,2]
#> [1,] 0.9972266 0.0027734091
#> [2,] 0.9977148 0.0022851621
#> [3,] 0.9952583 0.0047417365
#> [4,] 0.9957374 0.0042625746
#> [5,] 0.9980420 0.0019580465
#> [6,] 0.9973702 0.0026298407
#> [7,] 0.9968183 0.0031816703
#> [8,] 0.9990487 0.0009512697
#> [9,] 0.9969852 0.0030147807
#> [10,] 0.9969090 0.0030909859
#>
#>
#>
#> $zinbm_K1
#> $zinbm_K1$init
#> (Intercept) Mobs X
#> 1.78517270 0.12015440 0.00000000 0.85104549 0.00000000 0.95403971
#> (Intercept) X (Intercept) X
#> 1.41269766 0.09257633 5.68623319 -2.21212075 -0.35269450 0.01000000
#>
#> $zinbm_K1$est
#> (Intercept) Mobs X
#> 1.3032717 0.1200885 0.4823095 0.1533072 0.6979238 0.9333399
#> (Intercept) X (Intercept) X
#> 1.3645683 0.1069317 6.7790122 -2.8245948 -0.3554505 2.9869217
#>
#> $zinbm_K1$countEM
#> [1] 85
#>
#> $zinbm_K1$AIC
#> [1] 750.4574
#>
#> $zinbm_K1$BIC
#> [1] 781.7195
#>
#> $zinbm_K1$tau2
#> $zinbm_K1$tau2$tauG1
#> [1] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
#> [39] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
#> [77] 1 1 1 1 1 1 1 1 1 1 1 1 1 1
#>
#> $zinbm_K1$tau2$tauG2
#> [,1] [,2]
#> [1,] 0.9998879 1.120824e-04
#> [2,] 0.9999099 9.011999e-05
#> [3,] 0.9997935 2.065316e-04
#> [4,] 0.9998199 1.801039e-04
#> [5,] 0.9999185 8.152604e-05
#> [6,] 0.9998969 1.030726e-04
#> [7,] 0.9998685 1.315202e-04
#> [8,] 0.9999623 3.774995e-05
#> [9,] 0.9998760 1.239638e-04
#> [10,] 0.9998716 1.283670e-04
#>
#>
#>
#> $zipm_K1
#> $zipm_K1$init
#> (Intercept) Mobs X
#> 1.78512362 0.12019466 0.00000000 0.85116028
#> coef.(Intercept) coef.X
#> 0.00000000 0.95413982 1.41225480 0.09506801
#> (Intercept) X
#> -2.21212075 -0.35269450 0.01000000
#>
#> $zipm_K1$est
#> (Intercept) Mobs X
#> 1.3038644 0.1200770 0.4818120 0.1554076
#> coef.(Intercept) coef.X
#> 0.6957494 0.9334036 1.3930176 0.1025632
#> (Intercept) X
#> -2.4125566 -0.3399581 3.8115853
#>
#> $zipm_K1$countEM
#> [1] 31
#>
#> $zipm_K1$AIC
#> [1] 757.0581
#>
#> $zipm_K1$BIC
#> [1] 785.715
#>
#> $zipm_K1$tau2
#> $zipm_K1$tau2$tauG1
#> [,1]
#> [1,] 1
#> [2,] 1
#> [3,] 1
#> [4,] 1
#> [5,] 1
#> [6,] 1
#> [7,] 1
#> [8,] 1
#> [9,] 1
#> [10,] 1
#> [11,] 1
#> [12,] 1
#> [13,] 1
#> [14,] 1
#> [15,] 1
#> [16,] 1
#> [17,] 1
#> [18,] 1
#> [19,] 1
#> [20,] 1
#> [21,] 1
#> [22,] 1
#> [23,] 1
#> [24,] 1
#> [25,] 1
#> [26,] 1
#> [27,] 1
#> [28,] 1
#> [29,] 1
#> [30,] 1
#> [31,] 1
#> [32,] 1
#> [33,] 1
#> [34,] 1
#> [35,] 1
#> [36,] 1
#> [37,] 1
#> [38,] 1
#> [39,] 1
#> [40,] 1
#> [41,] 1
#> [42,] 1
#> [43,] 1
#> [44,] 1
#> [45,] 1
#> [46,] 1
#> [47,] 1
#> [48,] 1
#> [49,] 1
#> [50,] 1
#> [51,] 1
#> [52,] 1
#> [53,] 1
#> [54,] 1
#> [55,] 1
#> [56,] 1
#> [57,] 1
#> [58,] 1
#> [59,] 1
#> [60,] 1
#> [61,] 1
#> [62,] 1
#> [63,] 1
#> [64,] 1
#> [65,] 1
#> [66,] 1
#> [67,] 1
#> [68,] 1
#> [69,] 1
#> [70,] 1
#> [71,] 1
#> [72,] 1
#> [73,] 1
#> [74,] 1
#> [75,] 1
#> [76,] 1
#> [77,] 1
#> [78,] 1
#> [79,] 1
#> [80,] 1
#> [81,] 1
#> [82,] 1
#> [83,] 1
#> [84,] 1
#> [85,] 1
#> [86,] 1
#> [87,] 1
#> [88,] 1
#> [89,] 1
#> [90,] 1
#>
#> $zipm_K1$tau2$tauG2
#> [,1] [,2]
#> [1,] 0.9999997 2.634686e-07
#> [2,] 0.9999998 2.113970e-07
#> [3,] 0.9999995 4.860296e-07
#> [4,] 0.9999996 4.119145e-07
#> [5,] 0.9999998 2.054828e-07
#> [6,] 0.9999998 2.450092e-07
#> [7,] 0.9999997 3.003230e-07
#> [8,] 0.9999999 8.004548e-08
#> [9,] 0.9999997 2.852396e-07
#> [10,] 0.9999997 2.730768e-07
#>
#>
#>
#> [1] "selected_model_name: zinbm_K1"
## results of selected mediation model
maze_out$results_effects # indirect and direct effects. "_cond" for conditional effects and "_avg" for average effects
#> Estimate SE CI_lower CI_upper Pvalue
#> NIE1_cond 0.05848985 0.04004099 -0.01998904 0.13696874 1.440842e-01
#> NIE2_cond 0.03049883 0.02884348 -0.02603336 0.08703102 2.903333e-01
#> NIE_cond 0.08898868 0.05507323 -0.01895287 0.19693023 1.061322e-01
#> NDE_cond 0.78215096 0.10561449 0.57515037 0.98915155 1.303402e-13
#> CDE_cond 0.15330724 0.44685318 -0.72250891 1.02912338 7.315368e-01
#> NIE1_avg 0.05848985 0.04004099 -0.01998904 0.13696874 1.440842e-01
#> NIE2_avg 0.03049883 0.02884348 -0.02603336 0.08703102 2.903333e-01
#> NIE_avg 0.08898868 0.05507323 -0.01895287 0.19693023 1.061322e-01
#> NDE_avg 0.78215096 0.10561449 0.57515037 0.98915155 1.303402e-13
#> CDE_avg 0.15330724 0.44685318 -0.72250891 1.02912338 7.315368e-01
maze_out$selected_model_name # distribution of the mediator and number of components K in the selected mediation model
#> [1] "zinbm_K1"
maze_out$results_parameters # model parameters
#> Initials Estimate SE CI_lower CI_upper Pvalue
#> beta0 1.78517270 1.3032717 0.30847932 0.69866338 1.9078801 2.391245e-05
#> beta1 0.12015440 0.1200885 0.04070186 0.04031429 0.1998626 3.173197e-03
#> beta2 0.00000000 0.4823095 0.36486355 -0.23280989 1.1974290 1.862047e-01
#> beta3 0.85104549 0.1533072 0.44685318 -0.72250891 1.0291234 7.315368e-01
#> beta4 0.00000000 0.6979238 0.45876488 -0.20123887 1.5970864 1.281820e-01
#> delta 0.95403971 0.9333399 0.06599795 0.80398635 1.0626935 0.000000e+00
#> alpha10 1.41269766 1.3645683 0.07253340 1.22240549 1.5067312 0.000000e+00
#> alpha11 0.09257633 0.1069317 0.06954885 -0.02938149 0.2432450 1.241695e-01
#> r 5.68623319 6.7790122 3.36669264 0.18041588 13.3776085 4.405654e-02
#> gamma0 -2.21212075 -2.8245948 0.67815514 -4.15375450 -1.4954352 3.111943e-05
#> gamma1 -0.35269450 -0.3554505 0.51607623 -1.36694127 0.6560404 4.909770e-01
#> eta 0.01000000 2.9869217 14.53529043 -25.50172408 31.4755674 8.371858e-01
maze_out$BIC; maze_out$AIC # BIC and AIC of the selected mediation model
#> zinbm_K1
#> 781.7195
#> zinbm_K1
#> 750.4574