assurance2 {agpower}R Documentation

Assurance (expected power) for LWYY

Description

Function to compute assurance given fixed sample size N and number of events, under input assumptions. Assumes a log-normal prior distribution. Here assurance is taken to mean probability to achieve statistical significance (p-value < alp).

Usage

assurance2(
  N,
  bta1,
  bta1_sd,
  thta,
  L,
  alp = 0.05,
  ar = 0.5,
  ns = 1000,
  method = c("integration", "montecarlo"),
  frailty.type = c("unblind", "blind"),
  thtawarning = FALSE
)

Arguments

N

Sample size.

bta1

log-transform of rate ratio.

bta1_sd

assumed standard deviation of log(rate ratio)

thta

Variance of frailty parameter. If frailty.type = "blind", assumes thta derives from pooled model; if frailty.type = "unblind" assumes thta is from correctly specified model. Default "unblind".

L

Number of events

alp

Two-sided alpha-level.

ar

Allocation ratio (Number control / Total).

ns

Maximum number of subintervals (if method = "integration") or Number of draws from prior distribution (if method = "montecarlo").

method

Whether to numerically solve ("integration") or estimate by random draws ("montecarlo"). Defaults to numerical.

frailty.type

Indicates whether frailty variance is based on blinded information ("blind") or unblinded ("unblind"). Default "unblind".

thtawarning

If TRUE indicates how many estimates of theta were negative before setting to 0. Default FALSE.

Details

If working with a blinded estimate of frailty variance (i.e. misspecified model), it is recommended to use frailty.type = "blind". In which case the frailty variance (i.e. model with treatment effect) is derived using thta and the quantile drawn from the prior distribution of the log-rate ratio. If working with an estimate of frailty variance, should use frailty.type = "unblind" instead.

Function assumes a rate ratio < 1 is favourable to treatment.

Value

The assurance given the input assumptions.

Examples


assurance2(N = 500, bta1 = log(0.8), bta1_sd = 1, thta = 2, L = 1000, alp = 0.05,
          ns = 100000)


if (require("dplyr") & require("tidyr")) {

  assumptions = tibble(alp = 0.05) %>%
  crossing(
    N = c(500, 1000),
    RR = c(0.6, 0.7, 0.8),
    bta1_sd = 1,
    thta = c(2, 3, 4),
    L = c(500, 1000, 1500)
  ) %>%
    mutate(pow = pow2(N = N, bta1 = log(RR), thta = thta, L = L, alp = alp)) %>%
    mutate(
      assurance_in_blind = assurance2(N = N, bta1 = log(RR), bta1_sd = bta1_sd, thta = thta,
                                     L = L, alp = alp, ns = 1000,
                                     frailty.type = "blind")
    ) %>%
    mutate(
      assurance_mc_blind = assurance2(N = N, bta1 = log(RR), bta1_sd = bta1_sd, thta = thta,
                                     L = L, alp = alp, ns = 1000,
                                     method = "monte",
                                     frailty.type = "blind")
    ) %>%
    mutate(
      assurance_in_unblind = assurance2(N = N, bta1 = log(RR), bta1_sd = bta1_sd, thta = thta,
                                       L = L, alp = alp, ns = 1000)
    ) %>%
    mutate(
      assurance_mc_unblind = assurance2(N = N, bta1 = log(RR), bta1_sd = bta1_sd, thta = thta,
                                       L = L, alp = alp, ns = 1000)
    )

  assumptions %>% data.frame()

}

[Package agpower version 0.1.2 Index]