ChiSquare: Chi-squared test

ChiSquare-classR Documentation

Chi-squared test


This class implements a chi-squared test for superiority trials. A trial with binary outcomes in two groups E and C is assumed. If alternative == "greater" the null and alternative hypotheses for the difference in response probabilities are

H_0: p_E \leq p_C \textrm{ vs. } H_1: p_E > p_C.

If alternative == "smaller", the direction of the effect is changed.

The function setupChiSquare creates an object of class ChiSquare.


  r = 1,
  alternative = c("greater", "smaller"),
  n_max = Inf,



One-sided type I error rate.


Type II error rate.


Allocation ratio between experimental and control group.


Difference of effect size between alternative and null hypothesis.


Does the alternative hypothesis contain greater (greater) or smaller (smaller) values than the null hypothesis.


Maximal overall sample size. If the recalculated sample size is greater than n_max it is set to n_max.


Further optional arguments.


The nuisance parameter is the overall response probability p_0. In the blinded sample size #' recalculation procedure it is blindly estimated by:

\hat{p}_0 := (X_{1,E} + X_{1,C}) / (n_{1,E} + n_{1,C}),

where X_{1,E} and X_{1,C} are the numbers of responses and n_{1,E} and n_{1,C} are the sample sizes of the respective group after the first stage. The event rates in both groups under the alternative hypothesis can then be blindly estimated as:

\hat{p}_{C,A} := \hat{p}_0 - \Delta \cdot r / (1 + r) \textrm{, } \hat{p}_{E,A} := \hat{p}_0 + \Delta / (1 + r),

where \Delta is the difference in response probabilities under the alternative hypothesis and r is the allocation ratio of the sample sizes in the two groups. These blinded estimates can then be used to re-estimate the sample size.

The following methods are available for this class: toer, pow, n_dist, adjusted_alpha, and n_fix. Check the design specific documentation for details.

For non-inferiority trials use the function setupFarringtonManning.


An object of class ChiSquare.


Friede, T., & Kieser, M. (2004). Sample size recalculation for binary data in internal pilot study designs. Pharmaceutical Statistics: The Journal of Applied Statistics in the Pharmaceutical Industry, 3(4), 269-279.
Kieser, M. (2020). Methods and applications of sample size calculation and recalculation in clinical trials. Springer.


design <- setupChiSquare(alpha = .025, beta = .2, r = 1, delta = 0.2,
alternative = "greater")

blindrecalc documentation built on Oct. 4, 2023, 5:06 p.m.