Description Usage Arguments Details Value Examples
View source: R/prevalence_ratio.R
Calculates the prevalence ratio of a binary / dichotomous outcome between two or more groups, from individual or aggregate data.
1 | prevalence_ratio(outcome_data, groups, outcomes)
|
outcome_data |
Data providing the outcomes against the groups. Can be provided as raw (i.e., participant-level) data, detailing row-by-row the the group and outcome for each participant. Can also be provided as aggregate data. Valid input types are data.frame, matrix and list; see Details for formats. |
groups |
Character vector of the groups in the order in which they should be analysed, starting with the control group. For list data the parameter will define the labels to be applied in the output, and default values will be used if not specified. |
outcomes |
Character vector of length 2 specifying the labels used in the data for the two outcome states, with the 'outcome occurred' state listed first and the 'outcome did not occur' state second. For list data the parameter will define the labels to the be applied in the output, and default values will be used if not specified. |
The prevalence ratio is defined for binary / dichotomous outcomes in a trial. In each group, the prevalence is the number of participants for whom the outcome occured as a proportion of the total number of participants in that group. For example, if 15 participants out of 100 in a group achieved the outcome in question, the prevalence for that group would be 0.15 (15 per cent).
The prevalence ratio is the ratio of the prevalence of the outcome in an intervention group to the prevalence in the control group.
As a relative measure, presenting the prevalence ratio on its own can tend
to create an impression of a larger effect than an absolute measure.
Consider using in association with an absolute measure, such as
prevalence_difference
.
The function is able to handle both individual and aggregate data. Individual data should be provided as a data.frame with two columns. Aggregate data can be provided as either a named list or a matrix with named rows and columns. Data should be provided using one of the following options:
data.frame: 2 columns and a row for each participant. The first column contains the participant's group, second column contains the participant's outcome;
matrix: a contingency table of the groups against the outcomes, with 2 columns (one for the 'outcome occurred' state and one for the 'outcome did not occur' state), and a named row for each group;
list: 4 named elements, group1_t
, group1_f
,
group2_t
and group2_f
, giving the number of
participants in each category. group1 is the control group and
group2 is the intervention group; _t is the 'outcome occurred'
state and _f is the 'outcome did not occur' state.
The list method only supports two groups. The other methods support multiple groups (by multiple rows for matrices and multiple entries in the 'group' column for data.frames).
The prevalence ratio, indicating the prevalence in group 2, relative to group 1. Returns a list of objects if there are more than 2 groups.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | dummy_rct_data_list <- list(group1_t = 48, group1_f = 52,
group2_t = 64, group2_f = 36)
prevalence_ratio(outcome_data = dummy_rct_data_list,
groups = c("Control group", "Intervention group"),
outcomes = c("Outcome occurred", "Outcome did not occur"))
# Data will be reordered if necessary.
dummy_rct_data_matrix <- matrix(data=c(36, 64,
52, 48),
ncol=2, byrow=TRUE,
dimnames = list(c("Group 1 - new treatment",
"Control group"),
c("No","Yes")))
prevalence_ratio(outcome_data = dummy_rct_data_matrix,
groups = c("Control group", "Group 1 - new treatment"),
outcomes = c("Yes", "No"))
# Multiple-arm studies are supported (4 groups in this example):
dummy_rct_4 <- matrix(c(7,21,20,30,93,79,80,70),
nrow=4,
dimnames = list(c("Treatment as usual",
"Intervention 1",
"Intervention 2",
"Intervention 3"), c("Yes","No")))
pr4 <- prevalence_ratio(dummy_rct_4,
groups = rownames(dummy_rct_4),
outcomes = colnames(dummy_rct_4))
# Returns a list of prevalence_ratio objects.
length(pr4) # Length 3, comparing each of interventions 1-3 to TAU.
pr4[[1]]
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.