Learn R Programming

biostats (version 1.1.1)

sample_size_range: Calculate and visualize sample size across a range of treatment effects

Description

Calculates required sample sizes for specified power levels (70%, 80%, 90%) across a range of treatment effect values (x1), while keeping the control group value (x2) fixed. Internally calls sample_size() and generates a plot to visualize how total sample size changes with varying x1.

Usage

sample_size_range(x1_range, x2, step = 0.1, ...)

# S3 method for sample_size_range print(x, ...)

Value

An object of class "sample_size_range" containing the dataframe of sample size calculations and the ggplot object. A plot is also generated to visualize the relationship between treatment effects and required sample sizes.

Arguments

x1_range

Numeric vector of length 2 specifying the range of values to evaluate for the treatment group mean or proportion (x1).

x2

Numeric value for the control group mean or proportion (reference value).

step

Numeric value indicating the step size to increment across the x1_range. Default: 0.1.

...

Further arguments passed to or from other methods.

x

An object of class "sample_size_range".

Methods (by generic)

  • print(sample_size_range): Print method for objects of class "sample_size_range".

References

Chow, S.-C., Shao, J., Wang, H., & Lokhnygina, Y. (2017). Sample Size Calculations in Clinical Research (3rd ed.). Chapman and Hall/CRC. https://doi.org/10.1201/9781315183084

See Also

sample_size

Examples

Run this code
# Two-sample parallel non-inferiority test for proportions with 10% dropout
sample_size_range(x1_range = c(0.65, 0.75), x2 = 0.65, step = 0.01,
                  sample = "two-sample", design = "parallel", outcome = "proportion",
                  type = "non-inferiority", delta = -0.1, dropout = 0.1)
                  
# One-sample equivalence test for means
sample_size_range(x1_range = c(-0.01, 0.01), x2 = 0, step = 0.005,
                  sample = "one-sample", outcome = "mean", type = "equivalence",
                  SD = 0.1, delta = 0.05, alpha = 0.05)

Run the code above in your browser using DataLab