power_diff {incubate}R Documentation

Power simulation function for a two-group comparison of the delay parameter.

Description

There are two ways of operation:

  1. power=NULL Given sample size n it simulates the power.

  2. n=NULL Given a power an iterative search is started to find a suitable n within a specified range.

Usage

power_diff(
  distribution = c("exponential", "weibull"),
  param = "delay",
  test = c("bootstrap", "pearson", "moran", "lr", "lr_pp"),
  eff = stop("Provide parameters for both group that reflect the effect!"),
  n = NULL,
  r = 1,
  sig.level = 0.05,
  power = NULL,
  nPowerSim = 1600,
  R = 201,
  nRange = c(5, 50)
)

Arguments

distribution

character. Which assumed distribution is used for the power calculation.

param

character. Parameter name(s) for which to simulate the power.

test

character. Which test to use for this power estimation?

eff

list. The two list elements contain the model parameters (as understood by the delay-distribution functions provided by this package) for the two groups.

n

integer. Number of observations per group for the power simulation or NULL when n is to be estimated for a given power.

r

numeric. Ratio of both groups sizes, ny / nx. Default value is 1, i.e., balanced group sizes. Must be positive.

sig.level

numeric. Significance level. Default is 0.05.

power

numeric. NULL when power is to be estimated for a given sample size or a desired power is specified (and n is estimated).

nPowerSim

integer. Number of simulation rounds. Default value 1600 yields a standard error of 0.01 for power if the true power is 80%.

R

integer. Number of bootstrap samples for test of difference in parameter within each power simulation. It affects the resolution of the P-value for each simulation round. A value of around R=200 gives a resolution of 0.5% which might be enough for power analysis.

nRange

integer. Admissible range for sample size when power is pre-specified and sample size is requested.

Details

In any case, the distribution, the parameters that are tested for, the type of test and the effect size (⁠eff=⁠) need to be specified. The more power simulation rounds (parameter ⁠nPowerSim=⁠) the more densely the space of data according to the specified model is sampled.

Note that this second modus (when n is estimated) is computationally quite heavy. The iterative search for n uses some heuristics and the estimated sample size might actually give a different power-level. It is important to check the stated power in the output. The search algorithm comes to results closer to the power aimed at when the admissible range for sample size (⁠nRange=⁠) is chosen sensibly. In case the estimated sample size and the achieved power is too high it might pay off to rerun the function with an adapted admissible range.

Value

List of results of power simulation. Or NULL in case of errors.


[Package incubate version 1.2.1 Index]