Skip to contents

Power is calculated for two-sample studies. Can be vectorized, but w, lam, cens, must always be length 2.

Usage

epower(n, r, alpha = 0.05, w = c(1, 1), n1, n2, lam, cens)

esamsize(r, w = c(1, 1), alpha = 0.05, power = 0.8, lam, cens)

Arguments

n

Total sample size.

r

Effect size (ratio of hazards/medians).

alpha

Type I error rate.

w

Controls sample size balance between two groups. Default: Equal size groups.

n1, n2

Sample size in each group.

lam

Hazard rate in each group (if specified, overrides r).

cens

Censoring rate.

power

Desired power. Default: 0.8.

Examples

epower(30, 2)
#> Group 1: 15 events
#> Group 2: 15 events
#> [1] 0.4754571
epower(30, lam=c(2,1), cens=c(0.2, 0.5))
#> Group 1: 14 events
#> Group 2: 10 events
#> [1] 0.3841116
epower(seq(30, 100, 10), lam=c(2,1), cens=c(0.2, 0.5))
#> [1] 0.3841116 0.4850871 0.5751279 0.6534168 0.7201209 0.7760102 0.8221800
#> [8] 0.8598596
epower(seq(30, 100, 10), w=c(2,1), lam=c(2,1), cens=c(0.2, 0.5))
#> [1] 0.3341812 0.4186048 0.5112196 0.5812575 0.6437309 0.7085796 0.7554212
#> [8] 0.7957832
epower(30, seq(1.5, 2.5, 0.1))
#>  [1] 0.1988560 0.2511182 0.3064761 0.3632565 0.4199906 0.4754571 0.5286981
#>  [8] 0.5790110 0.6259255 0.6691706 0.7086390
epower(30, 2, alpha=c(0.01, 0.05, 0.1))
#> [1] 0.2490268 0.4754571 0.6002213
esamsize(1.5)
#> Per group: 96 events
#> Total    : 192
esamsize(lam=c(1.5, 1), cens=1)
#> Group 1: 160 subjects
#> Group 2: 191 subjects
#> Total  : 351