Get a stage-wise p-value after the trial is complete.

get.pvalue.sw(
  obs,
  u_k,
  n_k,
  k_r,
  alt = 0,
  rho = 1,
  ancova_monitor = F,
  ancova_test = T,
  last_stage = F,
  crossed_lower = FALSE,
  type = "two-sided"
)

Arguments

obs

Observed z-statistic

u_k

Matrix of boundaries for *previous* stages (if last_stage = F) There should be two columns, one for lower bound, one for upper. This allows asymmetric boundaries.

k_r

Stage trial ended

rho

sqrt(R^2)

ancova_monitor

Whether to monitor with ANCOVA

ancova_test

Whether to get final inferene with ANCOVA

crossed_lower

Was it the lower or upper boundary that was crossed if there was early stopping (if not, arg ignored).

type

Type of p-value ("two-sided", "lower", or "upper")

Examples

# OBF boundaries in 3-stage trial
bounds <- get.boundaries.design(rates=1:3/3, obf=FALSE)
u_k <- cbind(-bounds, bounds)
n_k <- c(10, 20, 30)

# Hit the last boundary at the last stage, should be p-value = 0.05
get.pvalue.sw(obs=bounds[3],
              u_k=u_k, k_r=3, n_k=n_k, last_stage=T,
              ancova_monitor=F, ancova_test=F)
#> [1] 0.04999908

# Switch to using ANCOVA at last stage
get.pvalue.sw(obs=bounds[3],
              u_k=u_k, k_r=3, n_k=n_k, last_stage=T,
              ancova_monitor=F, ancova_test=T, rho=sqrt(0.5))
#> [1] 0.05524079

# What if we had been using corrected boundaries
bounds.c <- get.boundaries.design(rates=1:3/3, obf=FALSE,
                                  rho=sqrt(0.5), change=c(0, 0, 1))
u_k <- cbind(-bounds.c, bounds.c)
get.pvalue.sw(obs=bounds.c[3],
              u_k=u_k, k_r=3, n_k=n_k, last_stage=T,
              ancova_monitor=F, ancova_test=T, rho=sqrt(0.5))
#> [1] 0.04999787