Skip to contents

This is a function for designing a study with a binary outcome whose inferential target is the relative risk. rr_design() will calculate the minimum number sample size, relative risk, power, or Type I error when the other arguments are specified. The approximation used relies on the delta method for the log relative risk.

Usage

rr_n_per_arm(
  pi_1 = NULL,
  pi_0 = NULL,
  rr = NULL,
  power = 0.8,
  alpha = 0.05,
  test_sides = 2
)

rr_power(
  pi_1 = NULL,
  pi_0 = NULL,
  rr = NULL,
  n_per_arm,
  alpha = 0.05,
  test_sides = 2
)

rr_alpha(
  pi_1 = NULL,
  pi_0 = NULL,
  rr = NULL,
  n_per_arm,
  power = 0.8,
  test_sides = 2
)

rr_minimal(
  n_per_arm = NULL,
  pi_0 = NULL,
  rr_above_1,
  power = 0.8,
  alpha = 0.05,
  test_sides = 2
)

rr_design(
  n_per_arm = NULL,
  pi_1 = NULL,
  pi_0 = NULL,
  rr = NULL,
  rr_above_1 = NULL,
  power = NULL,
  alpha = NULL,
  test_sides = 2
)

Arguments

pi_1

A numeric vector: the risk of the outcome under treatment

pi_0

A numeric vector: the risk of the outcome under control

rr

A numeric vector: the relative risk of the outcome under treatment relative to control

power

A numeric vector: the statistical power of interest

alpha

A numeric vector: Type I Error probability

test_sides

A numeric vector: Number of sides for test (1 or 2)

n_per_arm

A numeric vector: the sample size in each arm in a 1:1 randomized study

rr_above_1

A logical scalar: search for a relative risk above 1 (TRUE) or below 1 (FALSE)

Value

a numeric vector or data.frame, depending on the arguments supplied and quantity of interest.

Details

The function rr_design takes in user input, and depending on the arguments supplied, calls the appropriate function depending on whether the sample size (rr_n_per_arm), power (rr_power), Type I Error (rr_alpha), or relative risk (rr_minimal),

See also

hr_design() for hazard ratios.

Examples

# Sample Size
rr_design(
  pi_0 = 0.08,
  rr = 0.8,
  power = 0.80,
  alpha = 0.025,
  test_sides = 1
)
#>   n_per_arm n_total
#> 1  4118.085 8236.17

# Power
rr_design(
  n_per_arm = 4500,
  pi_0 = 0.08,
  rr = 0.8,
  alpha = 0.025,
  test_sides = 1
)
#> [1] 0.8336406

# Type I Error
rr_design(
  n_per_arm = 4500,
  pi_0 = 0.08,
  rr = 0.8,
  power = 0.80,
  test_sides = 1
)
#> [1] 0.0184443

# Relative Risk: Treatment < Control
rr_design(
  n_per_arm = 4500,
  pi_0 = 0.08,
  rr_above_1 = FALSE,
  power = 0.80,
  alpha = 0.025,
  test_sides = 1
)
#> [1] 0.8083121

# Relative Risk: Treatment > Control
rr_design(
  n_per_arm = 4500,
  pi_0 = 0.08,
  rr_above_1 = TRUE,
  power = 0.80,
  alpha = 0.025,
  test_sides = 1
)
#> [1] 1.209989