filter_ard_hierarchical {cards}R Documentation

Filter Stacked Hierarchical ARDs

Description

[Experimental]

This function is used to filter stacked hierarchical ARDs.

For the purposes of this function, we define a "variable group" as a combination of ARD rows grouped by the combination of all their variable levels, but excluding any by variables.

Usage

filter_ard_hierarchical(x, filter, keep_empty = FALSE)

Arguments

x

(card)
a stacked hierarchical ARD of class 'card' created using ard_stack_hierarchical() or ard_stack_hierarchical_count().

filter

(expression)
an expression that is used to filter variable groups of the hierarchical ARD. See the Details section below.

keep_empty

(scalar logical)
Logical argument indicating whether to retain summary rows corresponding to hierarchy sections that have had all rows filtered out. Default is FALSE.

Details

The filter argument can be used to filter out variable groups of a hierarchical ARD which do not meet the requirements provided as an expression. Variable groups can be filtered on the values of any of the possible statistics (n, p, and N) provided they are included at least once in the ARD, as well as the values of any by variables.

To illustrate how the function works, consider the typical example below where the AE summaries are provided by treatment group.

ADAE |>
  dplyr::filter(AESOC == "GASTROINTESTINAL DISORDERS",
                AEDECOD %in% c("VOMITING", "DIARRHOEA")) |>
  ard_stack_hierarchical(
    variables = c(AESOC, AEDECOD),
    by = TRTA,
    denominator = ADSL,
    id = USUBJID
  )
SOC / AE Placebo Xanomeline High Dose Xanomeline Low Dose
GASTROINTESTINAL DISORDERS 11 (13%) 10 (12%) 8 (9.5%)
DIARRHOEA 9 (10%) 4 (4.8%) 5 (6.0%)
VOMITING 3 (3.5%) 7 (8.3%) 3 (3.6%)

Filters are applied to the summary statistics of the innermost variable in the hierarchy—AEDECOD in this case. If any of the summary statistics meet the filter requirement for any of the treatment groups, the entire row is retained. For example, if filter = n >= 9 were passed, the criteria would be met for DIARRHOEA as the Placebo group observed 9 AEs and as a result the summary statistics for the other treatment groups would be retained as well. Conversely, no treatment groups' summary statistics satisfy the filter requirement for VOMITING so all rows associated with this AE would be removed.

In addition to filtering on individual statistic values, filters can be applied across the treatment groups (i.e. across all by variable values) by using aggregate functions such as sum() and mean(). A value of filter = sum(n) >= 18 retains AEs where the sum of the number of AEs across the treatment groups is greater than or equal to 18.

If ard_stack_hierarchical(overall=TRUE) was run, the overall column is not considered in any filtering.

If ard_stack_hierarchical(over_variables=TRUE) was run, any overall statistics are kept regardless of filtering.

Some examples of possible filters:

Value

an ARD data frame of class 'card'

See Also

sort_ard_hierarchical()

Examples


# create a base AE ARD
ard <- ard_stack_hierarchical(
  ADAE,
  variables = c(AESOC, AEDECOD),
  by = TRTA,
  denominator = ADSL,
  id = USUBJID
)

# Example 1 ----------------------------------
# Keep AEs from TRTA groups where more than 3 AEs are observed across the group
filter_ard_hierarchical(ard, sum(n) > 3)

# Example 2 ----------------------------------
# Keep AEs where at least one level in the TRTA group has more than 3 AEs observed
filter_ard_hierarchical(ard, n > 3)

# Example 3 ----------------------------------
# Keep AEs that have an overall prevalence of greater than 5%
filter_ard_hierarchical(ard, sum(n) / sum(N) > 0.05)


[Package cards version 0.6.1 Index]