# SampleSize

Sample size estimation.

## Introduction

### Hypothesis

#### Equality

Two-sided hypothesis:

H₀: A - B = 0 Hₐ: A - B ≠ 0

100*(1 - α)% two-sided confidence interval used to demonstrate it.

#### Equivalence | Bioequivalence

Two-sided hypothesis or two one-sided hypothesis (TOST):

H₀: |A − B| ≥ δ Hₐ: |A − B| < δ

or

H₀: A - B ≤ δˡ || A - B ≥ δᵘ Hₐ: δˡ < A - B < δᵘ

100*(1 - 2*α)% two-sided confidence interval used to demonstrate it.

See Walker&Nowacki, 2011, Understanding Equivalence and Noninferiority Testing.

*Chow at al. Sample Size Calculations in Clinical Research 3-rd ed. for sample size calculation used alpha level for testing corresponding 100\*(1 - α)% two-sided confidence interval*

For bioequivalence clinical trial 90% *(100\*(1 - 2*α)%)* two-sided confidence interval is used (α = 0.05), but for therapeutic equivalence 95% two-sided confidence interval should be used (in this case use α = 0.025).

#### Non-inferiority | Superiority

One-sided hypothesis:

H₀: A − B ≤ δ Hₐ: A − B > δ

100*(1 - α)% one-sided confidence interval used to demonstrate it.

In clinical research α = 0.025 or less should be used, or 100*(1 - α)% two-sided confidence interval should be used.

### ctsamplen

`ClinicalTrialUtilities.ctsamplen`

— Function```
ctsamplen(;param::Symbol, type::Symbol, group::Symbol = :notdef,
alpha::Real = 0.05, beta::Real = 0.2, diff::Real = 0, sd::Real = 0,
a::Real = 0, b::Real = 0,
k::Real = 1, logscale::Bool = true)::TaskResult
```

Clinical trial sample size estimation.

**param (Parameter type):**

- :mean - Means;
- :prop - Proportions;
- :or - Odd Ratio;

**type (Hypothesis type):**

- :ea - Equality (two-sided hypothesis, 100*(1 - α)% two-sided CI);
- :ei - Equivalence (two-sided hypothesis, 100*(1 -
**2*α**)% two-sided CI); - :ns - Non-Inferiority / Superiority (one-sided hypothesis, one side of 100*(1 -
**2*α**)% two-sided CI); - :mcnm - McNemar's Equality test;

**group (group num):**

- :one - One sample;
- :two - Two sample, result is for one group, second group size = n * k;

**alpha** - Alpha (o < α < 1) (default = 0.05);

**beta** - Beta (o < β < 1) (default = 0.2); power = 1 - β;

**diff** - difference/equivalence margin/non-inferiority/superiority margin;

**sd** - Standard deviation (σ, for Means only);

**a** - Group A (μ₀/p₀) - Test group;

**b** - Group B (μ₁/p₁) - Reference group or reference value;

**k** - Na/Nb (after sample size estimation second group size: Na=k*Nb, only for two sample design) (default=1);

**logscale** - diff is log transformed for OR:

- true - diff is already in log-scale, no transformation required (default);
- false - diff is not in log-scale, will be transformed;

### besamplen

`ClinicalTrialUtilities.besamplen`

— Function```
besamplen(;alpha::Real=0.05, beta::Real=0.2,
theta0::Real=0.95, theta1::Real=0.8, theta2::Real=1.25,
cv::Real=0.0, sd::Real=0.0, design::Symbol=:d2x2,
method::Symbol=:owenq, logscale::Bool=true)::TaskResult
```

Bioequivalence sample size estimation.

**alpha** - Alpha (o < α < 1) (default = 0.05);

**beta** - Beta (o < β < 1) (default=0.2); power = 1 - β;

**theta0** - T/R Ratio (default=0.95);

**theta1** - Lower Level (default=0.8);

**theta2** - Upper level (default=1.25);

**cv** - coefficient of variation;

**logscale** - theta1, theta2, theta0: if true - make log transformation (default true);

**design** - trial design;

- :parallel
- :d2x2 (default)
- :d2x2x4
- :d2x4x4
- :d2x3x3
- :d2x4x2
- :d3x3
- :d3x6x3

**method** - calculating method: Owen's Q Function | NonCentral T | Shifted;

- :owenq (default)
- :nct
- :shifted