-
Notifications
You must be signed in to change notification settings - Fork 0
/
README.Rmd
221 lines (172 loc) · 6.57 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
---
output: github_document
editor_options:
markdown:
wrap: sentence
always_allow_html: yes
---
<!-- README.md is generated from README.Rmd. Please edit this file -->
```{r, include = FALSE, cache = FALSE}
library(cTOST)
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
out.width = "100%"
)
# Turn on ANSI colors
asciicast::init_knitr_engine(
startup = quote({
library(cli)
library(cTOST)
set.seed(1) }),
echo = FALSE,
echo_input = FALSE)
```
# `cTOST` Overview <a href="https://yboulag.github.io/cTOST/"><img src="man/figures/hex-cTOST.png" alt="" align="right" height="138" width="125" /></a>
<!-- badges: start -->
[![Licence](https://img.shields.io/badge/licence-AGPL--3.0-blue.svg)](https://opensource.org/licenses/AGPL-3.0)
[![Last-changedate](https://img.shields.io/badge/last%20change-`r gsub('-', '--', Sys.Date())`-green.svg)](https://github.com/yboulag/cTOST)
[![R-CMD-check](https://github.com/yboulag/cTOST/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/yboulag/cTOST/actions/workflows/R-CMD-check.yaml)
[![CRAN RStudio mirror downloads](http://cranlogs.r-pkg.org/badges/cTOST)](https://www.r-pkg.org/pkg/cTOST)
[![CRAN RStudio mirror downloads](https://cranlogs.r-pkg.org/badges/grand-total/cTOST)](https://www.r-pkg.org/pkg/cTOST)
<!-- badges: end -->
## 1. `cTOST` Overview
This R package contains functions for testing equivalence in both univariate and multivariate settings, based on the Two One-Sided Tests (TOST). The `cTOST` package implements the $\alpha$-TOST and $\delta$-TOST methods proposed by Boulaguiem et al. (2024a, 2024b). These two corrective procedures that can be applied to the standard TOST to adjust the size of the procedure to the desired nominal level, resulting in more powerful procedures.
## 2. Install Instructions
The `cTOST` package is available on cran and on GitHub. The version on GitHub is subject to ongoing updates that may lead to stability issues.
The package can from cran as follows:
```{r, eval = F}
install.packages("cTOST")
```
The package can also be install from GitHub using the `devtools` package:
```{r, eval=FALSE}
install.packages("devtools")
devtools::install_github("stephaneguerrier/cTOST")
```
Note that Windows users are assumed that have Rtools installed (if this is not the case, please visit this [link](https://cran.r-project.org/bin/windows/Rtools/).
## 3. How to use
We provide here a few examples on the usage of the `cTOST` package.
### 3.1. Univariate settings
To illustrate the use of the proposed method in the univariate settings, we consider the `skin` dataset analyzed in Boulaguiem et al. (2024a), which can be loaded as follows:
```{r}
data(skin)
theta_hat = diff(apply(skin,2,mean))
nu = nrow(skin) - 1
sig_hat = sd(apply(skin,1,diff))/sqrt(nu)
```
### 3.1.1. Standard TOST
The standard TOST can be used as follows:
```{r, eval = F}
stost = tost(theta = theta_hat, sigma = sig_hat, nu = nu, delta = log(1.25))
stost
```
```{asciicast}
library(cTOST)
data(skin)
theta_hat = diff(apply(skin,2,mean))
nu = nrow(skin) - 1
sig_hat = sd(apply(skin,1,diff))/sqrt(nu)
stost = tost(theta = theta_hat, sigma = sig_hat, nu = nu, delta = log(1.25))
stost
```
#### 3.1.2. $\alpha$-TOST
The $\alpha$-TOST can be used through the function `ctost` as follows:
```{r, eval = F}
atost = ctost(theta = theta_hat, sigma = sig_hat, nu = nu,
delta = log(1.25), method = "alpha")
atost
```
```{asciicast}
library(cTOST)
data(skin)
theta_hat = diff(apply(skin,2,mean))
nu = nrow(skin) - 1
sig_hat = sd(apply(skin,1,diff))/sqrt(nu)
atost = ctost(theta = theta_hat, sigma = sig_hat, nu = nu, delta = log(1.25), method = "alpha")
atost
```
It is possible to compare the results of the $\alpha$-TOST (or $\delta$-TOST, see below) with the standard TOST as follows:
```{r, eval = F}
compare_to_tost(atost)
```
```{asciicast}
library(cTOST)
data(skin)
theta_hat = diff(apply(skin,2,mean))
nu = nrow(skin) - 1
sig_hat = sd(apply(skin,1,diff))/sqrt(nu)
atost = ctost(theta = theta_hat, sigma = sig_hat, nu = nu, delta = log(1.25), method = "alpha")
compare_to_tost(atost)
```
### 3.1.3. $\delta$-TOST
The $\delta$-TOST can be used through the function `ctost` as follows:
```{r}
dtost = ctost(theta = theta_hat, sigma = sig_hat, nu = nu,
delta = log(1.25), method = "delta")
dtost
```
```{asciicast}
library(cTOST)
data(skin)
theta_hat = diff(apply(skin,2,mean))
nu = nrow(skin) - 1
sig_hat = sd(apply(skin,1,diff))/sqrt(nu)
dtost = ctost(theta = theta_hat, sigma = sig_hat, nu = nu, delta = log(1.25), method = "delta")
dtost
```
### 3.2. Multivariate settings
```{r, eval = FALSE}
data(ticlopidine)
n = nrow(ticlopidine)
p = ncol(ticlopidine)
nu = n-1
theta_hat = colMeans(ticlopidine)
Sigma_hat = cov(ticlopidine)/n
```
#### 3.2.1. Multivariate TOST
```{r, eval = FALSE}
mtost = tost(theta = theta_hat, sigma = Sigma_hat, nu = nu, delta = log(1.25))
mtost
```
```{asciicast}
library(cTOST)
data(ticlopidine)
n = nrow(ticlopidine)
p = ncol(ticlopidine)
nu = n-1
theta_hat = colMeans(ticlopidine)
Sigma_hat = cov(ticlopidine)/n
mtost = tost(theta = theta_hat, sigma = Sigma_hat, nu = nu, delta = log(1.25))
mtost
```
#### 3.2.2. Multivariate $\alpha$-TOST
```{r, eval = FALSE}
matost = ctost(theta = theta_hat, sigma = Sigma_hat, nu = nu, delta = log(1.25))
matost
```
```{asciicast}
library(cTOST)
data(ticlopidine)
n = nrow(ticlopidine)
p = ncol(ticlopidine)
nu = n-1
theta_hat = colMeans(ticlopidine)
Sigma_hat = cov(ticlopidine)/n
matost = ctost(theta = theta_hat, sigma = Sigma_hat, nu = nu, delta = log(1.25))
matost
```
## 4. How to cite
```{}
@Manual{boulaguiem2024ctost,
title = {cTOST: Finite Sample Correction of The TOST in The Univariate Framework},
author = {Boulaguiem, Y. and Insolia, L. and Couturier, D.-L. and Guerrier, S.},
year = {2024},
note = {R package version 1.1.0},
url = {https://github.com/stephaneguerrier},
}
```
## 5. License
The license this source code is released under is the GNU AFFERO GENERAL PUBLIC LICENSE (AGPL) v3.0. Please see the LICENSE file for full text. Otherwise, please consult [GNU](https://www.gnu.org/licenses/agpl-3.0.en.html) which will provide a synopsis of the restrictions placed upon the code.
## 6. References
Boulaguiem, Y., Quartier, J., Lapteva, M., Kalia, Y. N., Victoria-Feser, M. P., Guerrier, S. & Couturier, D. L., "*Finite Sample Adjustments for Average Equivalence Testing*", Statistics in Medicine, 2024a, [https://doi.org/10.1002/sim.9993]( https://doi.org/10.1002/sim.9993).
Boulaguiem, Y., Insolia, L., Victoria-Feser, M. P., Couturier, D. L. & Guerrier, S., "*Multivariate Adjustments for Average Equivalence Testing*", submitted manuscript, 2024b.