prepare_ma | R Documentation |
Allows for one-way conversion from full to summary data or for calculation of effects for binary data. Usually used before calling baggr. Input must be pre-formatted appropriately.
prepare_ma(
data,
effect = c("mean", "logOR", "logRR", "RD"),
rare_event_correction = 0.25,
correction_type = c("single", "all"),
log = FALSE,
cfb = FALSE,
summarise = TRUE,
treatment = "treatment",
baseline = NULL,
group = "group",
outcome = "outcome",
pooling = FALSE
)
data |
either a data.frame of individual-level observations
with columns for outcome (numeric), treatment (values 0 and 1) and
group (numeric, character or factor); or, a data frame with binary data
(must have columns |
effect |
what effect to calculate? a |
rare_event_correction |
This correction is used when working with
binary data (effect |
correction_type |
If |
log |
logical; log-transform the outcome variable? |
cfb |
logical; calculate change from baseline? If yes, the outcome
variable is taken as a difference between values in |
summarise |
logical; |
treatment |
name of column with treatment variable |
baseline |
name of column with baseline variable |
group |
name of the column with grouping variable |
outcome |
name of column with outcome variable |
pooling |
Internal use only, please ignore |
The conversions done by this function are not typically needed and may happen automatically
when data
is given to baggr. However, this function can be used to explicitly
convert from full to reduced (summarised) data without analysing it in any model.
It can be useful for examining your data and generating summary tables.
If multiple operations are performed, they are taken in this order:
conversion to log scale,
calculating change from baseline,
summarising data (using appropriate effect
)
If you summarise
: a data.frame with columns for group
, tau
and se.tau
(for effect = "mean"
, also baseline means; for "logRR"
or "logOR"
also
a
, b
, c
, d
, which correspond to typical contingency table notation, that is:
a
= events in exposed; b
= no events in exposed, c
= events in unexposed,
d
= no events in unexposed).
If you do not summarise data, individual level data will be returned, but some columns may be renamed or transformed (see the arguments above).
Witold Wiecek
convert_inputs for how any type of data is (internally) converted into
a list of Stan inputs; vignette baggr_binary
for more details about
rare event corrections
# Example of working with binary outcomes data
# Make up some individual-level data first:
df_rare <- data.frame(group = paste("Study", LETTERS[1:5]),
a = c(0, 2, 1, 3, 1), c = c(2, 2, 3, 3, 5),
n1i = c(120, 300, 110, 250, 95),
n2i = c(120, 300, 110, 250, 95))
df_rare_ind <- binary_to_individual(df_rare)
# Calculate ORs; default rare event correction will be applied
prepare_ma(df_rare_ind, effect = "logOR")
# Add 0.5 to all rows
prepare_ma(df_rare_ind, effect = "logOR",
correction_type = "all",
rare_event_correction = 0.5)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.