Skip to contents

Print Method for Object of Class ctmedmc

Usage

# S3 method for class 'ctmedmc'
print(x, alpha = 0.05, digits = 4, ...)

Arguments

x

an object of class ctmedmc.

alpha

Numeric vector. Significance level \(\alpha\).

digits

Integer indicating the number of decimal places to display.

...

further arguments.

Value

Prints a list of matrices of time intervals, estimates, standard errors, number of Monte Carlo replications, and confidence intervals.

Author

Ivan Jacob Agaloos Pesigan

Examples

set.seed(42)
phi <- matrix(
  data = c(
    -0.357, 0.771, -0.450,
    0.0, -0.511, 0.729,
    0, 0, -0.693
  ),
  nrow = 3
)
colnames(phi) <- rownames(phi) <- c("x", "m", "y")
vcov_phi_vec <- matrix(
  data = c(
    0.002704274, -0.001475275, 0.000949122,
    -0.001619422, 0.000885122, -0.000569404,
    0.00085493, -0.000465824, 0.000297815,
    -0.001475275, 0.004428442, -0.002642303,
    0.000980573, -0.00271817, 0.001618805,
    -0.000586921, 0.001478421, -0.000871547,
    0.000949122, -0.002642303, 0.006402668,
    -0.000697798, 0.001813471, -0.004043138,
    0.000463086, -0.001120949, 0.002271711,
    -0.001619422, 0.000980573, -0.000697798,
    0.002079286, -0.001152501, 0.000753,
    -0.001528701, 0.000820587, -0.000517524,
    0.000885122, -0.00271817, 0.001813471,
    -0.001152501, 0.00342605, -0.002075005,
    0.000899165, -0.002532849, 0.001475579,
    -0.000569404, 0.001618805, -0.004043138,
    0.000753, -0.002075005, 0.004984032,
    -0.000622255, 0.001634917, -0.003705661,
    0.00085493, -0.000586921, 0.000463086,
    -0.001528701, 0.000899165, -0.000622255,
    0.002060076, -0.001096684, 0.000686386,
    -0.000465824, 0.001478421, -0.001120949,
    0.000820587, -0.002532849, 0.001634917,
    -0.001096684, 0.003328692, -0.001926088,
    0.000297815, -0.000871547, 0.002271711,
    -0.000517524, 0.001475579, -0.003705661,
    0.000686386, -0.001926088, 0.004726235
  ),
  nrow = 9
)

# Specific time interval ----------------------------------------------------
mc <- MCMed(
  phi = phi,
  vcov_phi_vec = vcov_phi_vec,
  delta_t = 1,
  from = "x",
  to = "y",
  med = "m",
  R = 100L # use a large value for R in actual research
)
print(mc)
#> 
#> Total, Direct, and Indirect Effects
#> 
#> $`1`
#>          interval     est     se   R    2.5%   97.5%
#> total           1 -0.1000 0.0342 100 -0.1666 -0.0440
#> direct          1 -0.2675 0.0440 100 -0.3567 -0.1863
#> indirect        1  0.1674 0.0201 100  0.1273  0.2006
#> 

# Range of time intervals ---------------------------------------------------
mc <- MCMed(
  phi = phi,
  vcov_phi_vec = vcov_phi_vec,
  delta_t = 1:5,
  from = "x",
  to = "y",
  med = "m",
  R = 100L # use a large value for R in actual research
)
print(mc)
#> 
#> Total, Direct, and Indirect Effects
#> 
#> $`1`
#>          interval     est     se   R    2.5%   97.5%
#> total           1 -0.1000 0.0340 100 -0.1648 -0.0320
#> direct          1 -0.2675 0.0471 100 -0.3397 -0.1738
#> indirect        1  0.1674 0.0201 100  0.1239  0.1982
#> 
#> $`2`
#>          interval     est     se   R    2.5%   97.5%
#> total           2  0.0799 0.0352 100  0.0110  0.1542
#> direct          2 -0.3209 0.0555 100 -0.4178 -0.2099
#> indirect        2  0.4008 0.0413 100  0.3090  0.4663
#> 
#> $`3`
#>          interval     est     se   R    2.5%   97.5%
#> total           3  0.2508 0.0337 100  0.1884  0.3100
#> direct          3 -0.2914 0.0524 100 -0.3863 -0.1918
#> indirect        3  0.5423 0.0523 100  0.4351  0.6286
#> 
#> $`4`
#>          interval     est     se   R    2.5%   97.5%
#> total           4  0.3449 0.0324 100  0.2823  0.3989
#> direct          4 -0.2374 0.0464 100 -0.3272 -0.1538
#> indirect        4  0.5823 0.0575 100  0.4668  0.6888
#> 
#> $`5`
#>          interval     est     se   R    2.5%   97.5%
#> total           5  0.3693 0.0325 100  0.3091  0.4402
#> direct          5 -0.1828 0.0402 100 -0.2636 -0.1132
#> indirect        5  0.5521 0.0594 100  0.4404  0.6682
#>