plot.RdThe various causalRisk plot methods produce paneled ggplot2 objects depicting
each set of estimates or effect measures of interest and their associated
confidence intervals. In the case of the cumrisk and cumcount methods,
the results are plotted over time, wheras for the hr method the plot simply
displays a single data point for each hazard ratio since by construction the
ratios are constant over time.
Note that the plot and forest_plot methods for the hr class are aliases
for each other.
# S3 method for hr
plot(..., alpha = 0.05, legend_title = "Treatment \nGroups", colors = "Dark2")
# S3 method for cumcount
plot(
...,
cd = FALSE,
effect_measure_type = NULL,
overlay = FALSE,
smooth = FALSE,
ncol = 2,
panel_dim = 1,
time_lab,
alpha = 0.05,
scales = "free_y",
stepribbon = TRUE,
legend_title = "Treatment \nGroups",
colors = "Dark2",
ref = 1,
boot_method = "normal"
)
# S3 method for cumrisk
plot(
...,
rd = FALSE,
effect_measure_type = NULL,
overlay = FALSE,
smooth = FALSE,
ncol = 2,
panel_dim = 1,
time_lab,
alpha = 0.05,
scales = "free_y",
stepribbon = TRUE,
legend_title = "Treatment \nGroups",
colors = "Dark2",
ref = 1,
boot_method = "normal"
)Objects with an associated method for creating plots supplied as either as seperate arguments or as a list.
The desired significance level of the confidence intervals.
A string used to title the legend, default is
"Treatment Groups"
Set colors for resulting ggplot object. Either a vector of
strings which are interpreted as RGB codes or a sinlge string that
identifies a color brewer palette. If set to NULL, the methods will
use grey shades via the color brewer palette 'Dark2'.
A flag to indicate whether the count difference should be plotted or
the individual count functions (deprecated, now use the effect_measure_type parameter)
Either NULL to display the original estimates of
interrest or a string identifying the type of effect measure to be
displayed from among the following options for a given method.
cumrisk: "RD" (risk difference), "RR" (risk ratio), "logRR"
(logarithm of the risk ratio), or "AR" (attributable risk)
cumcount: "CD" (count difference) or "CR" (count ratio)
Note that when a given input
results object was created using bootstrap estimation and boot_method is
"log-normal", then only effect measures with support on the positive real
line can be used (i.e. "RR" or "CR", depending on the method). See the
Cumulative risk effect measure types and Cumulative count effect measure
types sections for the definitions of the various effect measures.
A flag to indicate that the risk difference curves should be overlayed rather than paneled
A flag to indicate the use of LOESS smoothing for risk difference
The number of columns for the faceting.
The number of dimensions for the faceting (either 1 or 2). Panels are faceted using the first (and if panel_dim = 2) and second elements of the labels vector in the supplied objects.
A numeric vector denoting the x-axis tick marks to be
labeled. Default is the ggplot2 default. Setting the parameter to NULL
suppressed labeling.
A ggplot2 option for facet_grid/facet_wrap that controls the
scales on facted plots. It can be fixed ("fixed"), free ("free"), or free
in one dimension ("free.x", "free.y"). The default is "free.y."
A flag to determine whether to force the confidence
intervals to be plotted using the stepribbon geom. The default is TRUE.
Identifies the treatment group in the supplied object(s) to be
used as a referent category for risk differecence curves. Defaults to 1.
The specific bootstrap approach used to compute confidence
intervals, for either the cumulative risk or count estimates or the effect
measures. Options are "normal" (default; normal approximation on the
original scale), "log-normal" (normal approximation on the log scale),
"percentile" (percentile-based approach using quantiles of the bootstrap
distribution), and "basic" (basic bootstrap using the reflection method).
When a given input results object was created without using bootstrap
estimation then the value of boot_method is ignored. Note that when a
given input results object was created using bootstrap estimation and
boot_method is "log-normal", then only effect measures specified via
effect_measure_type with support on the positive real line can be used.
A flag to indicate whether the risk difference should be plotted or
the individual risk functions (deprecated, now use the
effect_measure_ttype parameter)
A ggplot2 object that can be further modified by the user before
plotting.
plot(hr): Plot hazard ratios for analyses relative to their respective
control groups.
plot(cumcount): Plot a panel of (possibly overlayed) cumulative count
functions or cumulative count effect measures and confidence intervals.
plot(cumrisk): Plot a panel of (possibly overlayed) cumulative risk
functions or cumulative risk effect measures and confidence intervals.
Mean: \(\mathrm{E}[Y^{1}] - \mathrm{E}[Y^{0}]\)
Variance with IPW: \( \mathrm{Var}[Y^{1}] + \mathrm{Var}[Y^{0}] + \frac{2}{n} \mathrm{E}[Y^{1}] \, \mathrm{E}[Y^{0}] \)
Variance otherwise: \(\mathrm{Var}[Y^{1}] + \mathrm{Var}[Y^{0}]\)
Mean: \(\frac{\mathrm{E}[Y^{1}]}{\mathrm{E}[Y^{0}]}\)
Variance with IPW: \( \frac{\mathrm{Var}[Y^{1}]}{(\mathrm{E}[Y^{0}])^{2}} + \frac{\mathrm{Var}[Y^{0}]\,(\mathrm{E}[Y^{1}])^2} {(\mathrm{E}[Y^{0}])^{4}} + \frac{2\,(\mathrm{E}[Y^{1}])^2}{n\,(\mathrm{E}[Y^{0}])^2} \)
Variance otherwise: \( \frac{\mathrm{Var}[Y^{1}]}{(\mathrm{E}[Y^{0}])^{2}} + \frac{\mathrm{Var}[Y^{0}]\,(\mathrm{E}[Y^{1}])^2} {(\mathrm{E}[Y^{0}])^{4}} \)
A ratio of 0 (no events yet in the numerator group) is reported with a
variance of 0 and a CI of (0, 0). This holds for the influence-curve
variance, where every term is 0, and for every bootstrap method, since
resampling or reweighting cannot create events and so every replicate is 0
as well. (The "log-normal" method's log-scale variance is undefined for a
ratio of 0 and is taken to be 0 to give the same result.) The exception is
when the denominator group is also 0 in all but at most one replicate; see
the Handling non-finite values section.
Mean: \(\mathrm{log}\frac{\mathrm{E}[Y^{1}]}{\mathrm{E}[Y^{0}]}\)
Variance with IPW: \( \frac{\mathrm{Var}[Y^{1}]}{(\mathrm{E}[Y^{1}])^{2}} + \frac{\mathrm{Var}[Y^{0}]}{(\mathrm{E}[Y^{0}])^{2}} + \frac{2}{n} \)
Variance otherwise: \( \frac{\mathrm{Var}[Y^{1}]}{(\mathrm{E}[Y^{1}])^{2}} + \frac{\mathrm{Var}[Y^{0}]}{(\mathrm{E}[Y^{0}])^{2}} \)
Mean: \(\frac{\mathrm{E}[Y^{1}] - \mathrm{E}[Y^{0}]}{\mathrm{E}[Y^{1}]}\)
Variance with IPW: \( \frac{\mathrm{Var}[Y^{0}]}{(\mathrm{E}[Y^{1}])^{2}} + \frac{\mathrm{Var}[Y^{1}]\,(\mathrm{E}[Y^{0}])^{2}} {(\mathrm{E}[Y^{1}])^{4}} + \frac{2\,(\mathrm{E}[Y^{0}])^{2}}{n\,(\mathrm{E}[Y^{1}])^{2}} \)
Variance otherwise: \( \frac{\mathrm{Var}[Y^{0}]}{(\mathrm{E}[Y^{1}])^{2}} + \frac{\mathrm{Var}[Y^{1}]\,(\mathrm{E}[Y^{0}])^{2}} {(\mathrm{E}[Y^{1}])^{4}} \)
Mean: \(\mathrm{E}[Y^{1}] - \mathrm{E}[Y^{0}]\)
Variance with IPW: \( \mathrm{Var}[Y^{1}] + \mathrm{Var}[Y^{0}] + \frac{2}{n} \mathrm{E}[Y^{1}] \, \mathrm{E}[Y^{0}] \)
Variance otherwise: \(\mathrm{Var}[Y^{1}] + \mathrm{Var}[Y^{0}]\)
Mean: \(\frac{\mathrm{E}[Y^{1}]}{\mathrm{E}[Y^{0}]}\)
Variance with IPW: \( \frac{\mathrm{Var}[Y^{1}]}{(\mathrm{E}[Y^{0}])^{2}} + \frac{\mathrm{Var}[Y^{0}]\,(\mathrm{E}[Y^{1}])^2} {(\mathrm{E}[Y^{0}])^{4}} + \frac{2\,(\mathrm{E}[Y^{1}])^2}{n\,(\mathrm{E}[Y^{0}])^2} \)
Variance otherwise: \( \frac{\mathrm{Var}[Y^{1}]}{(\mathrm{E}[Y^{0}])^{2}} + \frac{\mathrm{Var}[Y^{0}]\,(\mathrm{E}[Y^{1}])^2} {(\mathrm{E}[Y^{0}])^{4}} \)
A ratio of 0 (no events yet in the numerator group) is reported with a
variance of 0 and a CI of (0, 0). This holds for the influence-curve
variance, where every term is 0, and for every bootstrap method, since
resampling or reweighting cannot create events and so every replicate is 0
as well. (The "log-normal" method's log-scale variance is undefined for a
ratio of 0 and is taken to be 0 to give the same result.) The exception is
when the denominator group is also 0 in all but at most one replicate; see
the Handling non-finite values section.