Estimate, compare, and visualize exposure histories
Source:R/compareHistories.R
compareHistories.RdTakes fitted model output to created predicted values for user-specified histories (pooling for imputed data), before conducting contrast comparisons (pooling for imputed data), correcting for multiple comparisons, and then plotting results.
Usage
compareHistories(
fit,
hi_lo_cut,
dose_level = "h",
reference = NULL,
comparison = NULL,
outcome_level = NULL,
mc_comp_method = "BH",
verbose = FALSE,
save.out = FALSE
)
# S3 method for class 'devMSM_comparisons'
print(x, save.out = FALSE, ...)
# S3 method for class 'devMSM_comparisons'
plot(
x,
colors = "Dark2",
exp_lab = NULL,
out_lab = NULL,
save.out = FALSE,
...
)
# S3 method for class 'devMSM_comparisons'
summary(object, type = "comps", ...)Arguments
- fit
list of model outputs from
fitModel()- hi_lo_cut
list of two numbers indicating quantile values that reflect high and low values, respectively, for continuous exposure
- dose_level
(optional) "l" or "h" indicating whether low or high doses should be tallied in tables and plots (default is high "h")
- reference
lists of one or more strings of "-"-separated "l" and "h" values indicative of a reference exposure history to which to compare comparison, required if comparison is supplied
- comparison
(optional) list of one or more strings of "-"-separated "l" and "h" values indicative of comparison history/histories to compare to reference, required if reference is supplied
- outcome_level
levels of a factor outcome within which the user wishes compare histories (default is all levels), history predictions and comparisons will be made within each outcome level.
- mc_comp_method
(optional) character abbreviation for multiple comparison correction method for stats::p.adjust, default is Benjamini-Hochburg ("BH")
- verbose
(optional) TRUE or FALSE indicator for printing output to console. default is FALSE.
- save.out
(optional) Either logical or a character string. If
TRUE, it will output the result to a default file name withinhome_dirset ininitMSM(). You can load the data withx <- readRDS(file). To use a non-default file name, specify a character string with the file name. It will save relative tohome_dir. There might be naming conflicts where two objects get saved to the same file. In these cases, users should specify a custom name. default is FALSE.- x
devMSM_histories object from
compareHistories()- ...
ignored
- colors
(optional) character specifying Brewer palette or list of colors (n(epochs)+1) for plotting (default is "Dark2" palette)
- exp_lab
(optional) character label for exposure variable in plots (default is variable name)
- out_lab
(optional) character label for outcome variable in plots (default is variable name)
- object
devMSM_histories object from
compareHistories()- type
Either "preds" or "comps" corresponding to the results of
marginaleffects::avg_predictions()at low and high dosages ormarginaleffects::avg_comparisons()respectively
Value
list containing two dataframes: preds with predictions from
marginaleffects::avg_predictions() containing average expected outcome
for different exposure histories and comps with contrasts from
marginaleffects::comparisons() comparing different exposure history
See also
marginaleffects::avg_predictions(),
https://cran.r-project.org/web/packages/marginaleffects/marginaleffects.pdf;
marginaleffects::hypotheses(),
https://cran.r-project.org/web/packages/marginaleffects/marginaleffects.pdf;
stats::p.adjust(),
https://www.rdocumentation.org/packages/stats/versions/3.6.2/topics/p.adjust;
Examples
library(devMSMs)
set.seed(123)
data <- data.frame(
ID = 1:50,
A.1 = rnorm(n = 50),
A.2 = rnorm(n = 50),
A.3 = rnorm(n = 50),
B.1 = rnorm(n = 50),
B.2 = rnorm(n = 50),
B.3 = rnorm(n = 50),
C = rnorm(n = 50),
D.3 = rnorm(n = 50)
)
obj <- initMSM(
data,
exposure = c("A.1", "A.2", "A.3"),
ti_conf = c("C"),
tv_conf = c("B.1", "B.2", "B.3", "D.3")
)
f <- createFormulas(obj, type = "short")
w <- createWeights(data = data, formulas = f)
fit <- fitModel(
data = data, weights = w,
outcome = "D.3", model = "m0"
)
comp <- compareHistories(
fit = fit,
hi_lo_cut = c(0.3, 0.6)
)
print(comp)
#> Summary of Exposure Main Effects:
#> USER ALERT: Out of the total of 50 individuals in the sample, below is the distribution of the 50 (100%) individuals that fall into 24 user-selected exposure histories (out of the 24 total) created from 30th and 60th percentile values for low and high levels of exposure-epoch A.1, A.2, A.3.
#> USER ALERT: Please inspect the distribution of the sample across the following exposure histories and ensure there is sufficient spread to avoid extrapolation and low precision:
#>
#> +---------------+---+
#> | epoch_history | n |
#> +===============+===+
#> | NA-NA-h | 2 |
#> +---------------+---+
#> | NA-NA-l | 1 |
#> +---------------+---+
#> | NA-h-NA | 2 |
#> +---------------+---+
#> | NA-h-h | 3 |
#> +---------------+---+
#> | NA-h-l | 2 |
#> +---------------+---+
#> | NA-l-NA | 1 |
#> +---------------+---+
#> | NA-l-h | 2 |
#> +---------------+---+
#> | NA-l-l | 2 |
#> +---------------+---+
#> | h-NA-NA | 2 |
#> +---------------+---+
#> | h-NA-h | 4 |
#> +---------------+---+
#> | h-NA-l | 1 |
#> +---------------+---+
#> | h-h-NA | 2 |
#> +---------------+---+
#> | h-h-h | 3 |
#> +---------------+---+
#> | h-h-l | 3 |
#> +---------------+---+
#> | h-l-NA | 1 |
#> +---------------+---+
#> | h-l-h | 2 |
#> +---------------+---+
#> | h-l-l | 2 |
#> +---------------+---+
#> | l-NA-NA | 3 |
#> +---------------+---+
#> | l-NA-l | 2 |
#> +---------------+---+
#> | l-h-NA | 2 |
#> +---------------+---+
#> | l-h-h | 1 |
#> +---------------+---+
#> | l-h-l | 2 |
#> +---------------+---+
#> | l-l-NA | 2 |
#> +---------------+---+
#> | l-l-h | 3 |
#> +---------------+---+
#>
#> Table: Summary of user-selected exposure histories based on exposure main effects A.1, A.2, A.3:
#>
#> Below are the pooled average predictions by user-specified history:
#> +-------+-------+------+--------+----------+-----------+----------+-----------+
#> | term | A.1 | A.2 | A.3 | estimate | std.error | conf.low | conf.high |
#> +=======+=======+======+========+==========+===========+==========+===========+
#> | l-l-l | -0.47 | -0.3 | -0.804 | -0.15 | 0.2 | -0.54 | 0.239 |
#> +-------+-------+------+--------+----------+-----------+----------+-----------+
#> | l-l-h | -0.47 | -0.3 | -0.051 | -0.064 | 0.2 | -0.47 | 0.338 |
#> +-------+-------+------+--------+----------+-----------+----------+-----------+
#> | l-h-l | -0.47 | 0.31 | -0.804 | -0.093 | 0.18 | -0.44 | 0.25 |
#> +-------+-------+------+--------+----------+-----------+----------+-----------+
#> | l-h-h | -0.47 | 0.31 | -0.051 | -0.007 | 0.19 | -0.37 | 0.357 |
#> +-------+-------+------+--------+----------+-----------+----------+-----------+
#> | h-l-l | 0.24 | -0.3 | -0.804 | -0.235 | 0.15 | -0.53 | 0.059 |
#> +-------+-------+------+--------+----------+-----------+----------+-----------+
#> | h-l-h | 0.24 | -0.3 | -0.051 | -0.149 | 0.15 | -0.45 | 0.154 |
#> +-------+-------+------+--------+----------+-----------+----------+-----------+
#> | h-h-l | 0.24 | 0.31 | -0.804 | -0.179 | 0.13 | -0.43 | 0.07 |
#> +-------+-------+------+--------+----------+-----------+----------+-----------+
#> | h-h-h | 0.24 | 0.31 | -0.051 | -0.093 | 0.14 | -0.36 | 0.176 |
#> +-------+-------+------+--------+----------+-----------+----------+-----------+
#>
#> Conducting multiple comparison correction for all pairings between comparison histories and each reference history using the BH method.
#>
#>
#> +-------------------+---------------+------------+-----------+-------------+------------+--------------+
#> | term | estimate | std.error | p.value | conf.low | conf.high | p.value_corr |
#> +===================+===============+============+===========+=============+============+==============+
#> | (l-l-h) - (l-l-l) | 0.0860245895 | 0.09323352 | 0.3561746 | -0.09670975 | 0.26875893 | 0.5955719 |
#> +-------------------+---------------+------------+-----------+-------------+------------+--------------+
#> | (l-h-l) - (l-l-l) | 0.0567671468 | 0.06804542 | 0.4041380 | -0.07659942 | 0.19013371 | 0.5955719 |
#> +-------------------+---------------+------------+-----------+-------------+------------+--------------+
#> | (l-h-h) - (l-l-l) | 0.1427917364 | 0.12113187 | 0.2384729 | -0.09462238 | 0.38020585 | 0.5955719 |
#> +-------------------+---------------+------------+-----------+-------------+------------+--------------+
#> | (h-l-l) - (l-l-l) | -0.0855518211 | 0.09515353 | 0.3686034 | -0.27204931 | 0.10094567 | 0.5955719 |
#> +-------------------+---------------+------------+-----------+-------------+------------+--------------+
#> | (h-l-h) - (l-l-l) | 0.0004727684 | 0.12853504 | 0.9970653 | -0.25145129 | 0.25239683 | 0.9970653 |
#> +-------------------+---------------+------------+-----------+-------------+------------+--------------+
#> | (h-h-l) - (l-l-l) | -0.0287846743 | 0.12605829 | 0.8193787 | -0.27585438 | 0.21828504 | 0.8824078 |
#> +-------------------+---------------+------------+-----------+-------------+------------+--------------+
#> | (h-h-h) - (l-l-l) | 0.0572399153 | 0.15718784 | 0.7157462 | -0.25084259 | 0.36532242 | 0.8824078 |
#> +-------------------+---------------+------------+-----------+-------------+------------+--------------+
#> | (l-l-l) - (l-l-h) | -0.0860245895 | 0.09323352 | 0.3561746 | -0.26875893 | 0.09670975 | 0.5955719 |
#> +-------------------+---------------+------------+-----------+-------------+------------+--------------+
#> | (l-h-l) - (l-l-h) | -0.0292574427 | 0.10941846 | 0.7891686 | -0.24371368 | 0.18519879 | 0.8824078 |
#> +-------------------+---------------+------------+-----------+-------------+------------+--------------+
#> | (l-h-h) - (l-l-h) | 0.0567671468 | 0.06804540 | 0.4041379 | -0.07659940 | 0.19013369 | 0.5955719 |
#> +-------------------+---------------+------------+-----------+-------------+------------+--------------+
#> | (h-l-l) - (l-l-h) | -0.1715764106 | 0.13773924 | 0.2128888 | -0.44154035 | 0.09838753 | 0.5955719 |
#> +-------------------+---------------+------------+-----------+-------------+------------+--------------+
#> | (h-l-h) - (l-l-h) | -0.0855518211 | 0.09515351 | 0.3686033 | -0.27204927 | 0.10094563 | 0.5955719 |
#> +-------------------+---------------+------------+-----------+-------------+------------+--------------+
#> | (h-h-l) - (l-l-h) | -0.1148092638 | 0.15639157 | 0.4628792 | -0.42133110 | 0.19171258 | 0.6480308 |
#> +-------------------+---------------+------------+-----------+-------------+------------+--------------+
#> | (h-h-h) - (l-l-h) | -0.0287846743 | 0.12605824 | 0.8193786 | -0.27585428 | 0.21828493 | 0.8824078 |
#> +-------------------+---------------+------------+-----------+-------------+------------+--------------+
#> | (l-l-l) - (l-h-l) | -0.0567671468 | 0.06804542 | 0.4041380 | -0.19013371 | 0.07659942 | 0.5955719 |
#> +-------------------+---------------+------------+-----------+-------------+------------+--------------+
#> | (l-l-h) - (l-h-l) | 0.0292574427 | 0.10941846 | 0.7891686 | -0.18519879 | 0.24371368 | 0.8824078 |
#> +-------------------+---------------+------------+-----------+-------------+------------+--------------+
#> | (l-h-h) - (l-h-l) | 0.0860245895 | 0.09323350 | 0.3561745 | -0.09670970 | 0.26875888 | 0.5955719 |
#> +-------------------+---------------+------------+-----------+-------------+------------+--------------+
#> | (h-l-l) - (l-h-l) | -0.1423189679 | 0.10713570 | 0.1840463 | -0.35230108 | 0.06766314 | 0.5955719 |
#> +-------------------+---------------+------------+-----------+-------------+------------+--------------+
#> | (h-l-h) - (l-h-l) | -0.0562943784 | 0.13264561 | 0.6712764 | -0.31627499 | 0.20368623 | 0.8824078 |
#> +-------------------+---------------+------------+-----------+-------------+------------+--------------+
#> | (h-h-l) - (l-h-l) | -0.0855518211 | 0.09515355 | 0.3686035 | -0.27204934 | 0.10094570 | 0.5955719 |
#> +-------------------+---------------+------------+-----------+-------------+------------+--------------+
#> | (h-h-h) - (l-h-l) | 0.0004727684 | 0.12853505 | 0.9970653 | -0.25145130 | 0.25239683 | 0.9970653 |
#> +-------------------+---------------+------------+-----------+-------------+------------+--------------+
#> | (l-l-l) - (l-h-h) | -0.1427917364 | 0.12113187 | 0.2384729 | -0.38020585 | 0.09462238 | 0.5955719 |
#> +-------------------+---------------+------------+-----------+-------------+------------+--------------+
#> | (l-l-h) - (l-h-h) | -0.0567671468 | 0.06804540 | 0.4041379 | -0.19013369 | 0.07659940 | 0.5955719 |
#> +-------------------+---------------+------------+-----------+-------------+------------+--------------+
#> | (l-h-l) - (l-h-h) | -0.0860245895 | 0.09323350 | 0.3561745 | -0.26875888 | 0.09670970 | 0.5955719 |
#> +-------------------+---------------+------------+-----------+-------------+------------+--------------+
#> | (h-l-l) - (l-h-h) | -0.2283435575 | 0.15081852 | 0.1300186 | -0.52394242 | 0.06725530 | 0.5955719 |
#> +-------------------+---------------+------------+-----------+-------------+------------+--------------+
#> | (h-l-h) - (l-h-h) | -0.1423189679 | 0.10713570 | 0.1840463 | -0.35230107 | 0.06766314 | 0.5955719 |
#> +-------------------+---------------+------------+-----------+-------------+------------+--------------+
#> | (h-h-l) - (l-h-h) | -0.1715764106 | 0.13773922 | 0.2128888 | -0.44154031 | 0.09838749 | 0.5955719 |
#> +-------------------+---------------+------------+-----------+-------------+------------+--------------+
#> | (h-h-h) - (l-h-h) | -0.0855518211 | 0.09515351 | 0.3686033 | -0.27204928 | 0.10094563 | 0.5955719 |
#> +-------------------+---------------+------------+-----------+-------------+------------+--------------+
#> | (l-l-l) - (h-l-l) | 0.0855518211 | 0.09515353 | 0.3686034 | -0.10094567 | 0.27204931 | 0.5955719 |
#> +-------------------+---------------+------------+-----------+-------------+------------+--------------+
#> | (l-l-h) - (h-l-l) | 0.1715764106 | 0.13773924 | 0.2128888 | -0.09838753 | 0.44154035 | 0.5955719 |
#> +-------------------+---------------+------------+-----------+-------------+------------+--------------+
#> | (l-h-l) - (h-l-l) | 0.1423189679 | 0.10713570 | 0.1840463 | -0.06766314 | 0.35230108 | 0.5955719 |
#> +-------------------+---------------+------------+-----------+-------------+------------+--------------+
#> | (l-h-h) - (h-l-l) | 0.2283435575 | 0.15081852 | 0.1300186 | -0.06725530 | 0.52394242 | 0.5955719 |
#> +-------------------+---------------+------------+-----------+-------------+------------+--------------+
#> | (h-l-h) - (h-l-l) | 0.0860245895 | 0.09323348 | 0.3561744 | -0.09670968 | 0.26875886 | 0.5955719 |
#> +-------------------+---------------+------------+-----------+-------------+------------+--------------+
#> | (h-h-l) - (h-l-l) | 0.0567671468 | 0.06804543 | 0.4041381 | -0.07659945 | 0.19013374 | 0.5955719 |
#> +-------------------+---------------+------------+-----------+-------------+------------+--------------+
#> | (h-h-h) - (h-l-l) | 0.1427917364 | 0.12113185 | 0.2384729 | -0.09462233 | 0.38020580 | 0.5955719 |
#> +-------------------+---------------+------------+-----------+-------------+------------+--------------+
#> | (l-l-l) - (h-l-h) | -0.0004727684 | 0.12853504 | 0.9970653 | -0.25239683 | 0.25145129 | 0.9970653 |
#> +-------------------+---------------+------------+-----------+-------------+------------+--------------+
#> | (l-l-h) - (h-l-h) | 0.0855518211 | 0.09515351 | 0.3686033 | -0.10094563 | 0.27204927 | 0.5955719 |
#> +-------------------+---------------+------------+-----------+-------------+------------+--------------+
#> | (l-h-l) - (h-l-h) | 0.0562943784 | 0.13264561 | 0.6712764 | -0.20368623 | 0.31627499 | 0.8824078 |
#> +-------------------+---------------+------------+-----------+-------------+------------+--------------+
#> | (l-h-h) - (h-l-h) | 0.1423189679 | 0.10713570 | 0.1840463 | -0.06766314 | 0.35230107 | 0.5955719 |
#> +-------------------+---------------+------------+-----------+-------------+------------+--------------+
#> | (h-l-l) - (h-l-h) | -0.0860245895 | 0.09323348 | 0.3561744 | -0.26875886 | 0.09670968 | 0.5955719 |
#> +-------------------+---------------+------------+-----------+-------------+------------+--------------+
#> | (h-h-l) - (h-l-h) | -0.0292574427 | 0.10941843 | 0.7891686 | -0.24371363 | 0.18519875 | 0.8824078 |
#> +-------------------+---------------+------------+-----------+-------------+------------+--------------+
#> | (h-h-h) - (h-l-h) | 0.0567671468 | 0.06804541 | 0.4041380 | -0.07659941 | 0.19013371 | 0.5955719 |
#> +-------------------+---------------+------------+-----------+-------------+------------+--------------+
#> | (l-l-l) - (h-h-l) | 0.0287846743 | 0.12605829 | 0.8193787 | -0.21828504 | 0.27585438 | 0.8824078 |
#> +-------------------+---------------+------------+-----------+-------------+------------+--------------+
#> | (l-l-h) - (h-h-l) | 0.1148092638 | 0.15639157 | 0.4628792 | -0.19171258 | 0.42133110 | 0.6480308 |
#> +-------------------+---------------+------------+-----------+-------------+------------+--------------+
#> | (l-h-l) - (h-h-l) | 0.0855518211 | 0.09515355 | 0.3686035 | -0.10094570 | 0.27204934 | 0.5955719 |
#> +-------------------+---------------+------------+-----------+-------------+------------+--------------+
#> | (l-h-h) - (h-h-l) | 0.1715764106 | 0.13773922 | 0.2128888 | -0.09838749 | 0.44154031 | 0.5955719 |
#> +-------------------+---------------+------------+-----------+-------------+------------+--------------+
#> | (h-l-l) - (h-h-l) | -0.0567671468 | 0.06804543 | 0.4041381 | -0.19013374 | 0.07659945 | 0.5955719 |
#> +-------------------+---------------+------------+-----------+-------------+------------+--------------+
#> | (h-l-h) - (h-h-l) | 0.0292574427 | 0.10941843 | 0.7891686 | -0.18519875 | 0.24371363 | 0.8824078 |
#> +-------------------+---------------+------------+-----------+-------------+------------+--------------+
#> | (h-h-h) - (h-h-l) | 0.0860245895 | 0.09323346 | 0.3561743 | -0.09670963 | 0.26875881 | 0.5955719 |
#> +-------------------+---------------+------------+-----------+-------------+------------+--------------+
#> | (l-l-l) - (h-h-h) | -0.0572399153 | 0.15718784 | 0.7157462 | -0.36532242 | 0.25084259 | 0.8824078 |
#> +-------------------+---------------+------------+-----------+-------------+------------+--------------+
#> | (l-l-h) - (h-h-h) | 0.0287846743 | 0.12605824 | 0.8193786 | -0.21828493 | 0.27585428 | 0.8824078 |
#> +-------------------+---------------+------------+-----------+-------------+------------+--------------+
#> | (l-h-l) - (h-h-h) | -0.0004727684 | 0.12853505 | 0.9970653 | -0.25239683 | 0.25145130 | 0.9970653 |
#> +-------------------+---------------+------------+-----------+-------------+------------+--------------+
#> | (l-h-h) - (h-h-h) | 0.0855518211 | 0.09515351 | 0.3686033 | -0.10094563 | 0.27204928 | 0.5955719 |
#> +-------------------+---------------+------------+-----------+-------------+------------+--------------+
#> | (h-l-l) - (h-h-h) | -0.1427917364 | 0.12113185 | 0.2384729 | -0.38020580 | 0.09462233 | 0.5955719 |
#> +-------------------+---------------+------------+-----------+-------------+------------+--------------+
#> | (h-l-h) - (h-h-h) | -0.0567671468 | 0.06804541 | 0.4041380 | -0.19013371 | 0.07659941 | 0.5955719 |
#> +-------------------+---------------+------------+-----------+-------------+------------+--------------+
#> | (h-h-l) - (h-h-h) | -0.0860245895 | 0.09323346 | 0.3561743 | -0.26875881 | 0.09670963 | 0.5955719 |
#> +-------------------+---------------+------------+-----------+-------------+------------+--------------+
plot(comp)
#> `height` was translated to `width`.
summary(comp, "preds")
#> term A.1 A.2 A.3 estimate std.error statistic
#> 1 l-l-l -0.4684962 -0.2971206 -0.80434443 -0.149799589 0.1983536 -0.75521502
#> 2 l-l-h -0.4684962 -0.2971206 -0.05134827 -0.063774999 0.2048054 -0.31139320
#> 3 l-h-l -0.4684962 0.3148300 -0.80434443 -0.093032442 0.1750306 -0.53152099
#> 4 l-h-h -0.4684962 0.3148300 -0.05134827 -0.007007852 0.1859760 -0.03768148
#> 5 h-l-l 0.2359494 -0.2971206 -0.80434443 -0.235351410 0.1502512 -1.56638599
#> 6 h-l-h 0.2359494 -0.2971206 -0.05134827 -0.149326820 0.1547615 -0.96488365
#> 7 h-h-l 0.2359494 0.3148300 -0.80434443 -0.178584263 0.1267806 -1.40860888
#> 8 h-h-h 0.2359494 0.3148300 -0.05134827 -0.092559673 0.1371104 -0.67507386
#> p.value s.value conf.low conf.high df dose
#> 1 0.4501200 1.15161850 -0.5385654 0.23896625 Inf 0
#> 2 0.7555017 0.40449305 -0.4651861 0.33763614 Inf 1
#> 3 0.5950578 0.74889829 -0.4360861 0.25002124 Inf 1
#> 4 0.9699416 0.04403015 -0.3715142 0.35749845 Inf 2
#> 5 0.1172583 3.09223828 -0.5298384 0.05913557 Inf 1
#> 6 0.3346031 1.57947733 -0.4526537 0.15400010 Inf 2
#> 7 0.1589509 2.65334736 -0.4270696 0.06990112 Inf 2
#> 8 0.4996288 1.00107133 -0.3612912 0.17617185 Inf 3
summary(comp, "comps")
#> term estimate std.error statistic p.value
#> 1 (l-l-h) - (l-l-l) 0.0860245895 0.09323352 0.922678774 0.3561746
#> 2 (l-h-l) - (l-l-l) 0.0567671468 0.06804542 0.834253795 0.4041380
#> 3 (l-h-h) - (l-l-l) 0.1427917364 0.12113187 1.178812239 0.2384729
#> 4 (h-l-l) - (l-l-l) -0.0855518211 0.09515353 -0.899092485 0.3686034
#> 5 (h-l-h) - (l-l-l) 0.0004727684 0.12853504 0.003678129 0.9970653
#> 6 (h-h-l) - (l-l-l) -0.0287846743 0.12605829 -0.228344158 0.8193787
#> 7 (h-h-h) - (l-l-l) 0.0572399153 0.15718784 0.364149773 0.7157462
#> 8 (l-l-l) - (l-l-h) -0.0860245895 0.09323352 -0.922678774 0.3561746
#> 9 (l-h-l) - (l-l-h) -0.0292574427 0.10941846 -0.267390382 0.7891686
#> 10 (l-h-h) - (l-l-h) 0.0567671468 0.06804540 0.834253942 0.4041379
#> 11 (h-l-l) - (l-l-h) -0.1715764106 0.13773924 -1.245661109 0.2128888
#> 12 (h-l-h) - (l-l-h) -0.0855518211 0.09515351 -0.899092667 0.3686033
#> 13 (h-h-l) - (l-l-h) -0.1148092638 0.15639157 -0.734114157 0.4628792
#> 14 (h-h-h) - (l-l-h) -0.0287846743 0.12605824 -0.228344258 0.8193786
#> 15 (l-l-l) - (l-h-l) -0.0567671468 0.06804542 -0.834253795 0.4041380
#> 16 (l-l-h) - (l-h-l) 0.0292574427 0.10941846 0.267390382 0.7891686
#> 17 (l-h-h) - (l-h-l) 0.0860245895 0.09323350 0.922679016 0.3561745
#> 18 (h-l-l) - (l-h-l) -0.1423189679 0.10713570 -1.328399128 0.1840463
#> 19 (h-l-h) - (l-h-l) -0.0562943784 0.13264561 -0.424396854 0.6712764
#> 20 (h-h-l) - (l-h-l) -0.0855518211 0.09515355 -0.899092312 0.3686035
#> 21 (h-h-h) - (l-h-l) 0.0004727684 0.12853505 0.003678129 0.9970653
#> 22 (l-l-l) - (l-h-h) -0.1427917364 0.12113187 -1.178812239 0.2384729
#> 23 (l-l-h) - (l-h-h) -0.0567671468 0.06804540 -0.834253942 0.4041379
#> 24 (l-h-l) - (l-h-h) -0.0860245895 0.09323350 -0.922679016 0.3561745
#> 25 (h-l-l) - (l-h-h) -0.2283435575 0.15081852 -1.514028675 0.1300186
#> 26 (h-l-h) - (l-h-h) -0.1423189679 0.10713570 -1.328399160 0.1840463
#> 27 (h-h-l) - (l-h-h) -0.1715764106 0.13773922 -1.245661293 0.2128888
#> 28 (h-h-h) - (l-h-h) -0.0855518211 0.09515351 -0.899092634 0.3686033
#> 29 (l-l-l) - (h-l-l) 0.0855518211 0.09515353 0.899092485 0.3686034
#> 30 (l-l-h) - (h-l-l) 0.1715764106 0.13773924 1.245661109 0.2128888
#> 31 (l-h-l) - (h-l-l) 0.1423189679 0.10713570 1.328399128 0.1840463
#> 32 (l-h-h) - (h-l-l) 0.2283435575 0.15081852 1.514028675 0.1300186
#> 33 (h-l-h) - (h-l-l) 0.0860245895 0.09323348 0.922679150 0.3561744
#> 34 (h-h-l) - (h-l-l) 0.0567671468 0.06804543 0.834253595 0.4041381
#> 35 (h-h-h) - (h-l-l) 0.1427917364 0.12113185 1.178812468 0.2384729
#> 36 (l-l-l) - (h-l-h) -0.0004727684 0.12853504 -0.003678129 0.9970653
#> 37 (l-l-h) - (h-l-h) 0.0855518211 0.09515351 0.899092667 0.3686033
#> 38 (l-h-l) - (h-l-h) 0.0562943784 0.13264561 0.424396854 0.6712764
#> 39 (l-h-h) - (h-l-h) 0.1423189679 0.10713570 1.328399160 0.1840463
#> 40 (h-l-l) - (h-l-h) -0.0860245895 0.09323348 -0.922679150 0.3561744
#> 41 (h-h-l) - (h-l-h) -0.0292574427 0.10941843 -0.267390434 0.7891686
#> 42 (h-h-h) - (h-l-h) 0.0567671468 0.06804541 0.834253833 0.4041380
#> 43 (l-l-l) - (h-h-l) 0.0287846743 0.12605829 0.228344158 0.8193787
#> 44 (l-l-h) - (h-h-l) 0.1148092638 0.15639157 0.734114157 0.4628792
#> 45 (l-h-l) - (h-h-l) 0.0855518211 0.09515355 0.899092312 0.3686035
#> 46 (l-h-h) - (h-h-l) 0.1715764106 0.13773922 1.245661293 0.2128888
#> 47 (h-l-l) - (h-h-l) -0.0567671468 0.06804543 -0.834253595 0.4041381
#> 48 (h-l-h) - (h-h-l) 0.0292574427 0.10941843 0.267390434 0.7891686
#> 49 (h-h-h) - (h-h-l) 0.0860245895 0.09323346 0.922679367 0.3561743
#> 50 (l-l-l) - (h-h-h) -0.0572399153 0.15718784 -0.364149773 0.7157462
#> 51 (l-l-h) - (h-h-h) 0.0287846743 0.12605824 0.228344258 0.8193786
#> 52 (l-h-l) - (h-h-h) -0.0004727684 0.12853505 -0.003678129 0.9970653
#> 53 (l-h-h) - (h-h-h) 0.0855518211 0.09515351 0.899092634 0.3686033
#> 54 (h-l-l) - (h-h-h) -0.1427917364 0.12113185 -1.178812468 0.2384729
#> 55 (h-l-h) - (h-h-h) -0.0567671468 0.06804541 -0.834253833 0.4041380
#> 56 (h-h-l) - (h-h-h) -0.0860245895 0.09323346 -0.922679367 0.3561743
#> s.value conf.low conf.high dose p.value_corr
#> 1 1.489343334 -0.09670975 0.26875893 1 - 0 0.5955719
#> 2 1.307080145 -0.07659942 0.19013371 1 - 0 0.5955719
#> 3 2.068102467 -0.09462238 0.38020585 2 - 0 0.5955719
#> 4 1.439858713 -0.27204931 0.10094567 1 - 0 0.5955719
#> 5 0.004240124 -0.25145129 0.25239683 2 - 0 0.9970653
#> 6 0.287397708 -0.27585438 0.21828504 2 - 0 0.8824078
#> 7 0.482480047 -0.25084259 0.36532242 3 - 0 0.8824078
#> 8 1.489343334 -0.26875893 0.09670975 0 - 1 0.5955719
#> 9 0.341594533 -0.24371368 0.18519879 1 - 1 0.8824078
#> 10 1.307080441 -0.07659940 0.19013369 2 - 1 0.5955719
#> 11 2.231827791 -0.44154035 0.09838753 1 - 1 0.5955719
#> 12 1.439859094 -0.27204927 0.10094563 2 - 1 0.5955719
#> 13 1.111292465 -0.42133110 0.19171258 2 - 1 0.6480308
#> 14 0.287397845 -0.27585428 0.21828493 3 - 1 0.8824078
#> 15 1.307080145 -0.19013371 0.07659942 0 - 1 0.5955719
#> 16 0.341594533 -0.18519879 0.24371368 1 - 1 0.8824078
#> 17 1.489343847 -0.09670970 0.26875888 2 - 1 0.5955719
#> 18 2.441859447 -0.35230108 0.06766314 1 - 1 0.5955719
#> 19 0.575021141 -0.31627499 0.20368623 2 - 1 0.8824078
#> 20 1.439858354 -0.27204934 0.10094570 2 - 1 0.5955719
#> 21 0.004240124 -0.25145130 0.25239683 3 - 1 0.9970653
#> 22 2.068102467 -0.38020585 0.09462238 0 - 2 0.5955719
#> 23 1.307080441 -0.19013369 0.07659940 1 - 2 0.5955719
#> 24 1.489343847 -0.26875888 0.09670970 1 - 2 0.5955719
#> 25 2.943210436 -0.52394242 0.06725530 1 - 2 0.5955719
#> 26 2.441859530 -0.35230107 0.06766314 2 - 2 0.5955719
#> 27 2.231828248 -0.44154031 0.09838749 2 - 2 0.5955719
#> 28 1.439859025 -0.27204928 0.10094563 3 - 2 0.5955719
#> 29 1.439858713 -0.10094567 0.27204931 0 - 1 0.5955719
#> 30 2.231827791 -0.09838753 0.44154035 1 - 1 0.5955719
#> 31 2.441859447 -0.06766314 0.35230108 1 - 1 0.5955719
#> 32 2.943210436 -0.06725530 0.52394242 2 - 1 0.5955719
#> 33 1.489344129 -0.09670968 0.26875886 2 - 1 0.5955719
#> 34 1.307079744 -0.07659945 0.19013374 2 - 1 0.5955719
#> 35 2.068103018 -0.09462233 0.38020580 3 - 1 0.5955719
#> 36 0.004240124 -0.25239683 0.25145129 0 - 2 0.9970653
#> 37 1.439859094 -0.10094563 0.27204927 1 - 2 0.5955719
#> 38 0.575021141 -0.20368623 0.31627499 1 - 2 0.8824078
#> 39 2.441859530 -0.06766314 0.35230107 2 - 2 0.5955719
#> 40 1.489344129 -0.26875886 0.09670968 1 - 2 0.5955719
#> 41 0.341594607 -0.24371363 0.18519875 2 - 2 0.8824078
#> 42 1.307080221 -0.07659941 0.19013371 3 - 2 0.5955719
#> 43 0.287397708 -0.21828504 0.27585438 0 - 2 0.8824078
#> 44 1.111292465 -0.19171258 0.42133110 1 - 2 0.6480308
#> 45 1.439858354 -0.10094570 0.27204934 1 - 2 0.5955719
#> 46 2.231828248 -0.09838749 0.44154031 2 - 2 0.5955719
#> 47 1.307079744 -0.19013374 0.07659945 1 - 2 0.5955719
#> 48 0.341594607 -0.18519875 0.24371363 2 - 2 0.8824078
#> 49 1.489344586 -0.09670963 0.26875881 3 - 2 0.5955719
#> 50 0.482480047 -0.36532242 0.25084259 0 - 3 0.8824078
#> 51 0.287397845 -0.21828493 0.27585428 1 - 3 0.8824078
#> 52 0.004240124 -0.25239683 0.25145130 1 - 3 0.9970653
#> 53 1.439859025 -0.10094563 0.27204928 2 - 3 0.5955719
#> 54 2.068103018 -0.38020580 0.09462233 1 - 3 0.5955719
#> 55 1.307080221 -0.19013371 0.07659941 2 - 3 0.5955719
#> 56 1.489344586 -0.26875881 0.09670963 2 - 3 0.5955719
comp2 <- compareHistories(
fit = fit,
hi_lo_cut = c(0.3, 0.6),
reference = "l-l-l",
comparison = c("h-h-h", "h-h-l")
)
print(comp2)
#> Summary of Exposure Main Effects:
#> Warning: There are no participants in your sample in the following histories: l-l-l.
#> Please revise your reference/comparison histories and/or the high/low cutoffs, if applicable.
#> USER ALERT: Out of the total of 50 individuals in the sample, below is the distribution of the 6 (12%) individuals that fall into 2 user-selected exposure histories (out of the 24 total) created from 30th and 60th percentile values for low and high levels of exposure-epoch A.1, A.2, A.3.
#> USER ALERT: Please inspect the distribution of the sample across the following exposure histories and ensure there is sufficient spread to avoid extrapolation and low precision:
#>
#> +---------------+---+
#> | epoch_history | n |
#> +===============+===+
#> | h-h-h | 3 |
#> +---------------+---+
#> | h-h-l | 3 |
#> +---------------+---+
#>
#> Table: Summary of user-selected exposure histories based on exposure main effects A.1, A.2, A.3:
#>
#> Below are the pooled average predictions by user-specified history:
#> +-------+-------+------+--------+----------+-----------+----------+-----------+
#> | term | A.1 | A.2 | A.3 | estimate | std.error | conf.low | conf.high |
#> +=======+=======+======+========+==========+===========+==========+===========+
#> | l-l-l | -0.47 | -0.3 | -0.804 | -0.15 | 0.2 | -0.54 | 0.24 |
#> +-------+-------+------+--------+----------+-----------+----------+-----------+
#> | h-h-l | 0.24 | 0.31 | -0.804 | -0.179 | 0.13 | -0.43 | 0.07 |
#> +-------+-------+------+--------+----------+-----------+----------+-----------+
#> | h-h-h | 0.24 | 0.31 | -0.051 | -0.093 | 0.14 | -0.36 | 0.18 |
#> +-------+-------+------+--------+----------+-----------+----------+-----------+
#>
#> Conducting multiple comparison correction for all pairings between comparison histories and each reference history using the BH method.
#>
#>
#> +-------------------+-------------+-----------+-----------+------------+-----------+--------------+
#> | term | estimate | std.error | p.value | conf.low | conf.high | p.value_corr |
#> +===================+=============+===========+===========+============+===========+==============+
#> | (h-h-h) - (l-l-l) | 0.05723992 | 0.1571878 | 0.7157462 | -0.2508426 | 0.3653224 | 0.8193787 |
#> +-------------------+-------------+-----------+-----------+------------+-----------+--------------+
#> | (h-h-l) - (l-l-l) | -0.02878467 | 0.1260583 | 0.8193787 | -0.2758544 | 0.2182850 | 0.8193787 |
#> +-------------------+-------------+-----------+-----------+------------+-----------+--------------+
plot(comp2)
#> `height` was translated to `width`.
summary(comp2, "preds")
#> term A.1 A.2 A.3 estimate std.error statistic
#> 1 l-l-l -0.4684962 -0.2971206 -0.80434443 -0.14979959 0.1983536 -0.7552150
#> 7 h-h-l 0.2359494 0.3148300 -0.80434443 -0.17858426 0.1267806 -1.4086089
#> 8 h-h-h 0.2359494 0.3148300 -0.05134827 -0.09255967 0.1371104 -0.6750739
#> p.value s.value conf.low conf.high df dose
#> 1 0.4501200 1.151619 -0.5385654 0.23896625 Inf 0
#> 7 0.1589509 2.653347 -0.4270696 0.06990112 Inf 2
#> 8 0.4996288 1.001071 -0.3612912 0.17617185 Inf 3
summary(comp2, "comps")
#> term estimate std.error statistic p.value s.value
#> 1 (h-h-h) - (l-l-l) 0.05723992 0.1571878 0.3641498 0.7157462 0.4824800
#> 2 (h-h-l) - (l-l-l) -0.02878467 0.1260583 -0.2283442 0.8193787 0.2873977
#> conf.low conf.high dose p.value_corr
#> 1 -0.2508426 0.3653224 3 - 0 0.8193787
#> 2 -0.2758544 0.2182850 2 - 0 0.8193787