designFreqZ: Design a Frequentist Z-Test

View source: R/zTest.R

designFreqZR Documentation

Design a Frequentist Z-Test

Description

Computes the number of samples necessary to reach a tolerable type I and desired power for the frequentist Z-test.

Usage

designFreqZ(
  meanDiffMin,
  alternative = c("twoSided", "greater", "less"),
  alpha = 0.05,
  power = 0.8,
  testType = c("oneSample", "paired", "twoSample"),
  ratio = 1,
  sigma = 1,
  h0 = 0,
  kappa = sigma,
  lowN = 3L,
  highN = 100L,
  ...
)

Arguments

meanDiffMin

numeric that defines the minimal relevant mean difference, the smallest population mean difference that we would like to detect (with sufficient power).

alternative

a character string specifying the alternative hypothesis. Must be one of "twoSided" (default), "greater" or "less".

alpha

numeric in (0, 1) that specifies the tolerable type I error and the null rejection rule e >= 1/alpha.

power

numeric in (0, 1) that specifies the desired power, that is, the targetted chance to stop in favour of the alternative over the null hypothesis, when the alternative holds true. Note that prior to version 0.8.8 power <- 1-beta. The "beta" argument does not need to be specified anymore.

testType

either one of "oneSample", "paired", "twoSample".

ratio

numeric > 0 representing the randomisation ratio of condition 2 over condition 1. If testType is not equal to "twoSample", or if nPlan is of length(1) then ratio=1.

sigma

numeric > 0 representing the assumed population standard deviation used to scale the data.

h0

numeric, representing the null value, default h0=0.

kappa

the true population standard deviation. Default kappa=sigma.

lowN

integer that defines the smallest n of our search space for n.

highN

integer that defines the largest n of our search space for n. This might be the largest n that we are able to fund.

...

further arguments to be passed to or from methods.

Value

returns a 'freqZDesign' object.

Examples

freqDesign <- designFreqZ(meanDiffMin = 0.5, highN = 100)
freqDesign$nPlan
freqDesign2 <- designFreqZ(meanDiffMin = 0.2, lowN = 32, highN = 200)
freqDesign2$nPlan

safestats documentation built on Sept. 6, 2026, 1:06 a.m.