serial.testing.sim: Simulate an optional stopping p-value scenario

Description Usage Arguments Value Examples

Description

Simulates type I error inflation from testing a difference in group means many times as the trial is ongoing, stopping if the test is significant. A matrix of p values is returned with length(ns) columns and nsim rows.

Usage

1
serial.testing.sim(ns = c(20, 30, 40, 50), nsim = 10000)

Arguments

ns

A vector of numbers, each of which is a number of people per group at which the group difference should be tested.

nsim

The number of simulated samples to run.

Value

A matrix of p values with length(ns) columns and nsim rows. Each row corresponds to a different sample, and the p values resulting from tests of the nested subsamples of size specified by ns are in different columns.

Examples

1
2
sims <- serial.testing.sim(nsim = 1000)
mean(apply(sims, 1, min) < .05) #How often would optional stopping lead to a rejection of the null at the .05 level?

mdedge/stfspack documentation built on May 9, 2019, 8:17 a.m.