Skip to contents

Information and effect size under risk difference

Usage

gs_info_rd(
  p_c = tibble::tibble(Stratum = "All", Rate = 0.2),
  p_e = tibble::tibble(Stratum = "All", Rate = 0.15),
  N = tibble::tibble(Stratum = "All", N = c(100, 200, 300), Analysis = 1:3),
  rd0 = 0,
  ratio = 1,
  weight = c("un-stratified", "ss", "invar")
)

Arguments

p_c

rate at the control group

p_e

rate at the experimental group

N

sample size

rd0

the risk difference under H0

ratio

Experimental:Control randomization ratio

weight

weigting method, either "un-stratified" or "ss" or "invar"

Examples

library(tibble)
# --------------------- #
#      example 1        #
# --------------------- #
# un-stratified case with H0: rd0 = 0
gs_info_rd(
  p_c = tibble(Stratum = "All", Rate = .15),
  p_e = tibble(Stratum = "All", Rate = .1),
  N = tibble(Stratum = "All", N = c(100, 200, 300), Analysis = 1:3),
  rd0 = 0,
  ratio = 1
)
#> # A tibble: 3 × 8
#>   Analysis     N    rd   rd0 theta1 theta0 info1 info0
#>      <int> <dbl> <dbl> <dbl>  <dbl>  <dbl> <dbl> <dbl>
#> 1        1   100  0.05     0  0.758      0  230.  229.
#> 2        2   200  0.05     0  1.07       0  460.  457.
#> 3        3   300  0.05     0  1.31       0  690.  686.

# --------------------- #
#      example 2        #
# --------------------- #
# un-stratified case with H0: rd0 != 0
gs_info_rd(
  p_c = tibble(Stratum = "All", Rate = .2),
  p_e = tibble(Stratum = "All", Rate = .15),
  N = tibble(Stratum = "All", N = c(100, 200, 300), Analysis = 1:3),
  rd0 = 0.005,
  ratio = 1
)
#> # A tibble: 3 × 8
#>   Analysis     N    rd   rd0 theta1 theta0 info1 info0
#>      <int> <dbl> <dbl> <dbl>  <dbl>  <dbl> <dbl> <dbl>
#> 1        1   100  0.05 0.005  0.659 0.0658  174.  173.
#> 2        2   200  0.05 0.005  0.933 0.0930  348.  346.
#> 3        3   300  0.05 0.005  1.14  0.114   522.  519.

# --------------------- #
#      example 3        #
# --------------------- #
# stratified case under sample size weighting and H0: rd0 = 0
gs_info_rd(
  p_c = tibble(Stratum = c("S1", "S2", "S3"), Rate = c(.15, .2, .25)),
  p_e = tibble(Stratum = c("S1", "S2", "S3"), Rate = c(.1, .16, .19)),
  N = tibble(Stratum = rep(c("S1", "S2", "S3"), each = 3),
             Analysis = rep(1:3, 3),
             N = c(50, 100, 200, 40, 80, 160, 60, 120, 240)),
  rd0 = 0,
  ratio = 1,
  weight = "ss")
#> # A tibble: 3 × 8
#>   Analysis     N     rd   rd0 theta1 theta0 info1 info0
#>      <int> <dbl>  <dbl> <dbl>  <dbl>  <dbl> <dbl> <dbl>
#> 1        1   150 0.0513     0  0.829      0  261.  260.
#> 2        2   300 0.0513     0  1.17       0  522.  519.
#> 3        3   600 0.0513     0  1.66       0 1043. 1038.

# --------------------- #
#      example 4        #
# --------------------- #
# stratified case under inverse variance weighting and H0: rd0 = 0
gs_info_rd(
  p_c = tibble(Stratum = c("S1", "S2", "S3"),
               Rate = c(.15, .2, .25)),
  p_e = tibble(Stratum = c("S1", "S2", "S3"),
               Rate = c(.1, .16, .19)),
  N = tibble(Stratum = rep(c("S1", "S2", "S3"), each = 3),
             Analysis = rep(1:3, 3),
             N = c(50, 100, 200, 40, 80, 160, 60, 120, 240)),
  rd0 = 0,
  ratio = 1,
  weight = "invar")
#> # A tibble: 3 × 8
#>   Analysis     N     rd   rd0 theta1 theta0 info1 info0
#>      <int> <dbl>  <dbl> <dbl>  <dbl>  <dbl> <dbl> <dbl>
#> 1        1   150 0.0507     0  0.835      0  271.  269.
#> 2        2   300 0.0507     0  1.18       0  542.  539.
#> 3        3   600 0.0507     0  1.67       0 1083. 1078.

# --------------------- #
#      example 5        #
# --------------------- #
# stratified case under sample size weighting and H0: rd0 != 0
gs_info_rd(
  p_c = tibble(Stratum = c("S1", "S2", "S3"),
               Rate = c(.15, .2, .25)),
  p_e = tibble(Stratum = c("S1", "S2", "S3"),
               Rate = c(.1, .16, .19)),
  N = tibble(Stratum = rep(c("S1", "S2", "S3"), each = 3),
             Analysis = rep(1:3, 3),
             N = c(50, 100, 200, 40, 80, 160, 60, 120, 240)),
  rd0 = 0.02,
  ratio = 1,
  weight = "ss")
#> # A tibble: 3 × 8
#>   Analysis     N     rd   rd0 theta1 theta0 info1 info0
#>      <int> <dbl>  <dbl> <dbl>  <dbl>  <dbl> <dbl> <dbl>
#> 1        1   150 0.0513  0.02  0.829  0.322  261.  260.
#> 2        2   300 0.0513  0.02  1.17   0.456  522.  519.
#> 3        3   600 0.0513  0.02  1.66   0.644 1043. 1038.

# --------------------- #
#      example 6        #
# --------------------- #
# stratified case under inverse variance weighting and H0: rd0 != 0
gs_info_rd(
  p_c = tibble(Stratum = c("S1", "S2", "S3"),
               Rate = c(.15, .2, .25)),
  p_e = tibble(Stratum = c("S1", "S2", "S3"),
               Rate = c(.1, .16, .19)),
  N = tibble(Stratum = rep(c("S1", "S2", "S3"), each = 3),
             Analysis = rep(1:3, 3),
             N = c(50, 100, 200, 40, 80, 160, 60, 120, 240)),
  rd0 = 0.02,
  ratio = 1,
  weight = "invar")
#> # A tibble: 3 × 8
#>   Analysis     N     rd   rd0 theta1 theta0 info1 info0
#>      <int> <dbl>  <dbl> <dbl>  <dbl>  <dbl> <dbl> <dbl>
#> 1        1   150 0.0507  0.02  0.835  0.328  271.  269.
#> 2        2   300 0.0507  0.02  1.18   0.464  542.  539.
#> 3        3   600 0.0507  0.02  1.67   0.657 1083. 1078.

# --------------------- #
#      example 7        #
# --------------------- #
# stratified case under inverse variance weighting and H0: rd0 != 0 and 
# rd0 difference for different statum
gs_info_rd(
  p_c = tibble(Stratum = c("S1", "S2", "S3"),
               Rate = c(.15, .2, .25)),
  p_e = tibble(Stratum = c("S1", "S2", "S3"),
               Rate = c(.1, .16, .19)),
  N = tibble(Stratum = rep(c("S1", "S2", "S3"), each = 3),
             Analysis = rep(1:3, 3),
             N = c(50, 100, 200, 40, 80, 160, 60, 120, 240)),
  rd0 = tibble(Stratum = c("S1", "S2", "S3"),
               rd0 = c(0.01, 0.02, 0.03)),
  ratio = 1,
  weight = "invar")
#> # A tibble: 3 × 8
#>   Analysis     N     rd    rd0 theta1 theta0 info1 info0
#>      <int> <dbl>  <dbl>  <dbl>  <dbl>  <dbl> <dbl> <dbl>
#> 1        1   150 0.0507 0.0190  0.835  0.312  271.  269.
#> 2        2   300 0.0507 0.0190  1.18   0.441  542.  539.
#> 3        3   600 0.0507 0.0190  1.67   0.624 1083. 1078.