---
title: "PowerTOST &bull; Main Vignette"
lang: "en"
output:
  rmarkdown::html_vignette:
    css: vignette.css
    toc: true
    toc_depth: 2
vignette: >
  %\VignetteIndexEntry{PowerTOST &bull; Main Vignette}
  %\VignetteEngine{knitr::rmarkdown}
  %\VignetteEncoding{UTF-8}
---
```{r, include = FALSE}
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#"
)
```
<div class="top"><a class="toplink" href="#nav" title="&uArr; top">&nbsp;</a></div>
<div id="nav">
<ul>
<li><span title="» You are here «">Main Vignette</span></li>
<li>[ABE](ABE.html "Average Bioequivalence")</li>
<li>[RSABE](RSABE.html "Reference-scaled Average Bioequivalence")</li>
<li>[Non-Inferiority](NI.html)</li>
<li>[Dose-Proportionality](DP.html)</li>
<li>[Power Analysis](PA.html)</li>
</ul>
</div>

# Introduction
The package contains functions to calculate power and estimate sample size for various study designs used in (not only bio-) equivalence studies. Power and sample size can be obtained based on different methods, amongst them prominently the TOST procedure (two one-sided *t*-tests).\
Version `r packageVersion("PowerTOST")` built `r packageDate("PowerTOST", date.fields = "Built")` with R `r getRversion()`.

For an overview of supported designs, methods, and defaults together with some basic examples see

  * [README](https://cran.r-project.org/package=PowerTOST/readme/README.html) of the released version on CRAN;
  * [README](https://github.com/Detlew/PowerTOST/blob/master/README.md) of the development version on GitHub.\

<h3>Details and examples are accessible via the menu bar on top of the page and in the<br><a href="https://cran.r-project.org/package=PowerTOST/PowerTOST.pdf" title="PDF">online manual</a> of all functions.</h3>

# Abbreviations, Definition of Terms, Models
2×2×2
: Crossover design with 2 treatments, 2 sequences, and 2 periods. In the literature also TR | RT or AB | AB. In the functions `2x2x2` or short `2x2`.

2x2x3, 2x2x4
: Full replicate designs with 2 treatments, 2 sequences, and 3 or 4 periods. Both T and R are administered twice to ½ of the subjects.

2×3×3
: Partial (or semi-) replicate design with 2 treatments, 3 sequences, and 3 periods. R is administered to all subjects twice and T once. Popular (though not optimal) is TRR|RTR|RRT.

2×4×2
: Full replicate design with 2 treatments, 4 sequences, and 2 periods (Balaam’s design). TR|RT|TT|RR; not optimal due to poor power characteristics.

2×4×4
: Full replicate designs with 2 treatments, 4 sequences, and 4 periods (TRTR|RTRT|TRRT|RTTR or TRTR|RTRT|TTRR|RRTT). This design should be avoided due to confounding.

3×3, 3×6×3
: Higher-order crossover designs with 3 treatments, 3 or 6 sequences, and 3 periods (Latin Square or a Williams’ design). In the functions `3x3` and `3x6x3`. Both have the same degrees of freedom (2*n*--4) in the convential approach and therefore, require the same number of subjects.

4×4
: Higher-order crossover design with 4 treatments, 4 sequences, and 4 periods (Latin Square or a Williams’ design).

<span id="abe">ABE</span>
: Average Bioequivalence with *fixed* limits based on a clinically not relevant difference <small>$\Delta$</small>. The common <small>$\Delta$</small> 0.20 leads to <small>$\theta_1=1-\Delta,\:\theta_2=1/(1-\Delta)$</small> or 80.00--125.00\%. For <a href="#ntid">NTIDs</a> (<span title="European Medicines Agency">EMA</span> and other jurisdicions) <small>$\Delta$</small> 0.10 (90.00--111.11\%). For C~max~ (Russian Federation, <span title="Eurasian Economic Union">EEU</span>, <span title="Gulf Cooperation Council">GCC</span>) <small>$\Delta$</small> 0.25 (75.00--133.33\%).<small>$$H_0:\mu_T/\mu_R\notin \left [ \theta_1,\theta_2 \right ]\:vs\:H_1:\theta_1<\mu_T/\mu_R<\theta_2$$</small>

<span id="abel">ABEL</span>
: Average Bioequivalence with *expanding* limits (see also ***<a href="#LU">L, U</a>***). Same model like for <a href="#abe">ABE</a> but <small>$\theta_1,\theta_2$</small> are based on the *CV~wR~* observed in the study.

$\alpha$
: Nominal level of the test. In tests for equivalence commonly 0.05 (except for the ratio of two means with normality on original scale based on Fieller’s (‘fiducial’) confidence interval in function `sampleN.RatioF()` and for non-inferiority/-superiority  in function `sampleN.noninf()`, where it is 0.025). In the functions `alpha`.

$\beta$
: Probability that the Null-hypothesis of inequivalence is *falsely not* rejected. Also the type II error or producer’s risk, where <small>$\beta=1-\pi$</small>.

$\beta_0$
: Assumed or true slope of the (linearized) power model of dose-proportionality <small>$x=\alpha\cdot dose^\beta,\:log(x)=\alpha+\beta\cdot log(dose)$</small>. Argument `beta0`.

CV
: Coefficient of variation

    : Calculated from the residual error of the model of log-transformed data as <small>$CV=\sqrt{e^{\sigma^2}+1}$</small>.
    <ul>
      <li>In crossover designs the intra- (between-) subject CV. Argument `CV`.</li>
      <li>In parallel designs the total (pooled) CV. Argument `CV`.</li>
      <li>In replicate designs the intra-subject CV (assuming homoscedasticity, argument `CV`). If heteroscedasticity is assumed, `CV` has to given as a vector with two elements `CV = c(x, y)` where `CV[1]` is *CV~wT~* and `CV[2]` is *CV~wR~*.</li>
    </ul>

CV~b~
: Inter- (between-) subject coefficient of variation. Argument `CVb` is required in function `sampleN.RatioF()` and in function `sampleN.dp()` if `design = "IBD"` (incomplete block design).

<span id="CVcap">CV~cap~</span>
: Upper cap in <a href="#abel">ABEL</a>. If *CV~wR~* > CV~cap~, expanding is based on CV~cap~ (and not on *CV~wR~*). In all jurisdictions 50\%, except for Health Canada where CV~cap~ ≈57.4\%.

CV~switch~
: Switching coefficient of variation in reference-scaling. Only above this value reference-scaling is acceptable. For highly variable drugs / drug products 30\% (*CV*~0~ 0.30, *s*~0~ 0.294).

<span id="Delta">$\Delta$</span>
: Clinically not relevant difference. Commonly 0.20.  For <a href="#ntid">NTIDs</a> (<span title="European Medicines Agency">EMA</span> and other jurisdicions) <small>$\Delta$</small> 0.10, for C~max~ (Russian Federation, <span title="Eurasian Economic Union">EEU</span>, <span title="Gulf Cooperation Council">GCC</span>) <small>$\Delta$</small> 0.25.

HVD(P)
: Highly variable drug (product); commonly defined with an intra-subject *CV* of ≥30\%. HVDs exhibit highly variable clearances (*CV* ≥30\% if administered as a solution), whereas HVDPs may additionally -- or solely -- show highly variable absorption. HVDP(s) generally are ones with a flat dose-response curve.

<span id="k">*k*</span>
: Regulatory constant <span style="font-weight:normal">(also <small>$\theta_s$</small>)</span>

    : **<a href="#abel">ABEL</a>**: Based on the switching coefficient of variation <small>$CV_0=30\%$</small>. <small>$k=log(1.25)/\sqrt{log(CV_{0}^{2}+1)}\approx 0.760$</small>.
    : **<a href="#rsabe">RSABE</a>**: Based on the switching standard deviation <small>$s_0=0.25$</small>. <small>$k=log(1.25)/0.25\approx 0.8926$</small>.

<span id="LU">*L*, *U*</span>
: ABEL, RSABE

    : **<a href="#abel">ABEL</a>**: Lower and upper expanded limits.
    <ul>
      <li>30% < *CV~wR~* ≤ 50%: Based on <small>$s_{wR}$</small>. <small>$\left[ {L,\,U} \right] = 100{e^{ \mp 0.760 \cdot {s_{wR}}}}$</small></li>
      <li>*CV~wR~* > <a href="#CVcap">CV~cap~</a>: Applying <small>$s^*_{wR}=\sqrt{log(CV_{cap}^{2}+1)}$</small> in the expansion formula: <small>$\left[ {L,\,U} \right] = {69.84 - 143.19\%}$</small>. All jurisdictions except Health Canada, where <small>$\left[ {L,\,U} \right] = {66.7 - 150.0\%}$</small>.</li>
    </ul>
    : **<a href="#rsabe">RSABE</a>**: Lower and upper ‘implied limits’.
    <ul>
      <li>If <small>$s_{wR}\geq 0.294$</small>: <small>$\left[ {L,\: U} \right] = 100{e^{ \mp 0.8926 \cdot {s_{wR}}}}$</small></li>
    </ul>

: Dose-Proportionality

    : <small>$\left[ {L,\,U} \right]=\left[1+log(0.80)/log(rd),\:1+log(1.25)/log(rd) \right]$</small>

margin
: Non-inferiority/-superiority margin <span style="font-weight:normal">(example for `logscale = TRUE` where <small>$\theta_0=\mu_T/\mu_R$</small>).</span>

    : **Non-inferiority**: If margin < 1, <u>higher</u> responses are are assumed to be better.
    <small>$$H_0:\,\theta_0 \leq \log({margin})\:vs\:H_1:\,\theta_0>\log({margin})$$</small>
    : **Non-superiority**: If margin > 1, <u>lower</u> responses are are assumed to be better.
    <small>$$H_0:\,\theta_0 \geq \log({margin})\:vs\:H_1:\,\theta_0<\log({margin})$$</small>

*n*
: (Total) number of subjects.

*n~seq~*
: Number of sequences.

<span id="ntid">NTID</span>
: Narrow therapeutic index drug, *i.e.*, with a steep dose-response curve.

$\pi$
: Target (or desired) power in study planning. Commonly set to 0.80--0.90. In the functions `targetpower`.

R
: Reference (treatment, product).

*rd*
: Ratio of the highest/lowest dose. In the functions `rd`.

`robust`
: Selects degrees of freedom according to Senn’s basic estimator, where *n* -- *n~seq~*.

<span id="rsabe">RSABE</span>
: Reference-scaled Average Bioequivalence (U.S. <span title="Food and Drug Administration">FDA</span>, China <span title="National Medical Products Administration, Center for Drug Evaluation">NMPA-CDE</span>). Applicable if the intra-subject variability of the reference treatment *s~wR~* ≥0.294 (*CV~wR~* ≈ 30\%). The linearized model is <small>$$H_0:(\mu_T/\mu_R)^2-\theta_{s}^{2}\cdot s_{wR}^{2}>0\:vs\:H_1:(\mu_T/\mu_R)^2-\theta_{s}^{2}\cdot s_{wR}^{2}\leq 0$$</small>
    See also <a href="#abel">ABEL</a>.

$\theta_0$
: Assumed or true T/R-ratio (`logscale = TRUE`) or difference T--R (`logscale = FALSE`). In the functions `theta0`.

$\theta_1,\theta_2$
: Lower and upper limits of the equivalence range. In the functions `theta1` and `theta2`.

$\theta_s$
: Regulatory constant in reference-scaling (see also ***<a href="#k">k</a>***).

T
: Test (treatment, product).

TIE <span style="font-weight:normal">(type I error)</span>
: Probability that the Null-hypothesis of inequivalence is *falsely* rejected (*i.e.*, equivalence is concluded). Also the patient’s risk. Can be assessed with the power-functions setting `theta0 = theta2` or `theta0 = theta1`.<br />Exact, except in reference-scaling based on simulations (`power.scABEL()`, `power.RSABE()`, `power.NTIDFDA()`, `power.HVNTID()`).

# Installation
You can install the released version of PowerTOST from [CRAN](https://CRAN.R-project.org) with …
```{r}
package <- "PowerTOST"
inst    <- package %in% installed.packages()
if (length(package[!inst]) > 0) install.packages(package[!inst])
```
… and the development version from [GitHub](https://github.com/) with
```
# install.packages("remotes")
remotes::install_github("Detlew/PowerTOST")
```
Skips installation from a github remote if the [SHA-1](https://en.wikipedia.org/wiki/SHA-1) has not changed since last install. Use `force = TRUE` to force installation.

# Contributors
- Detlew Labes (author, maintainer)
- Helmut Schütz (author)
- Benjamin Lang (author)

# Session Information
Inspect this information for reproducibility. Of particular importance are the versions of R and the packages used to create this workflow. It is considered good practice to record this information with every analysis.
```{r, sessioninfo}
options(width = 80)
devtools::session_info()
```
# License{#license}
<h4 class="author">Helmut Schütz `r Sys.Date()`</h4>
[GPL-2](https://cran.r-project.org/web/licenses/GPL-2 "GNU General Public License, Version 2") | [GPL-3](https://cran.r-project.org/web/licenses/GPL-3 "GNU General Public License, Version 3")