Title: | Equivalence Test for the Means of Two Normal Distributions |
Version: | 0.0.1.1 |
Description: | Two methods for performing equivalence test for the means of two (test and reference) normal distributions are implemented. The null hypothesis of the equivalence test is that the absolute difference between the two means are greater than or equal to the equivalence margin and the alternative is that the absolute difference is less than the margin. Given that the margin is often difficult to obtain a priori, it is assumed to be a constant multiple of the standard deviation of the reference distribution. The first method assumes a fixed margin which is a constant multiple of the estimated standard deviation of the reference data and whose variability is ignored. The second method takes into account the margin variability. In addition, some tools to summarize and illustrate the data and test results are included to facilitate the evaluation of the data and interpretation of the results. |
Depends: | R (≥ 3.0.0) |
License: | GPL-3 |
Encoding: | UTF-8 |
LazyData: | true |
RoxygenNote: | 6.1.1 |
Imports: | polynom, rootSolve, cubature, Rdpack, stats, graphics |
RdMacros: | Rdpack |
NeedsCompilation: | no |
Packaged: | 2019-02-26 13:22:11 UTC; cwang |
Author: | Chao Wang [aut, cre] |
Maintainer: | Chao Wang <wan9c9@gmail.com> |
Repository: | CRAN |
Date/Publication: | 2019-03-04 18:30:03 UTC |
eqivalenceTest: A package for evaluating equivalence of the means of two normal distributions.
Description
We implemented two equivalence tests which evaluate equivalence in the means of two normal distributions. The first is discussed by Tsong et al. (2017) and the second by Weng et al. (2018).
Details
Let X_{I,i}\sim_{IID} N(\mu_I,\sigma_I)
for I=T,R
and i=1,...,n_I
, where T
stands for test distribution and R
for reference distribution.
The equivalence test here considers the following hypotheses,
H_0: |\mu_T - \mu_R| \ge \delta \;\mathrm{versus}\;H_1:|\mu_T - \mu_R| < \delta,
where \delta
is the equivalence margin.
Let \hat{\mu}_I
and \hat{\sigma}_I^2
be the sample mean and unbiased sample variance estimates respectively for I=T,R
.
Tsong et al. (2017) define the follows test statistics,
\tau_1=\frac{\hat{\mu}_T-\hat{\mu}_R+\delta}{\sqrt{\hat{\sigma}_T^2/n_T^*+\hat{\sigma}_R^2/n_R^*}},
and
\tau_2=\frac{\hat{\mu}_T-\hat{\mu}_R-\delta}{\sqrt{\hat{\sigma}_T^2/n_T^*+\hat{\sigma}_R^2/n_R^*}},
where n_T^*=min\{n_T,1.5n_R\}
and n_R^*=min\{n_R,1.5n_R\}
are possibly adjusted sample sizes proposed by Dong et al. (2017).
The null hypothesis H_0
is rejected at nominal size \alpha
if both \tau_1 > t_{1-\alpha,df^*}
and \tau_2 < -t_{1-\alpha,df^*}
where t_{1-\alpha,df^*}
is the (1-\alpha)
-th quantile of the t-distribution with degree of freedom df^*
, which is approximated by the Satterthwaite method with sample size adjusted and given as follows,
df^*=\frac{\left(\frac{\hat{\sigma}_T^2}{n_T^*}+\frac{\hat{\sigma}_R^2}{n_T^*}\right)^2}{\frac{1}{n_B-1} \left(\frac{\hat{\sigma}_T^2}{n_T^*}\right)^2+\frac{1}{n_R-1} \left(\frac{\hat{\sigma}_R^2}{n_R^*}\right)^2}.
The above assumes that \delta
is a predetermined constant. However, in many studies, such constant is not available, and \delta
must be determined by the study data. A popular choice is \delta=k\hat{\sigma_R}
. In this case, the above test may not control type I error well.
Replacing \delta
by k\sigma_R
, the hypotheses becomes
H_0^\prime: |\mu_T - \mu_R| \ge k\sigma_R \;\mathrm{versus}\;H_a^\prime |\mu_T - \mu_R| < k\sigma_R.
Weng et al. (2018) proposed an improved Wald test with the following test statistics,
\tau_1^\prime=\frac{\hat{\mu}_T-\hat{\mu}_R+k\hat{\sigma}_R}{\sqrt{\frac{\tilde{\sigma}_{T,1}^2}{n_T^*}+\left(\frac{1}{n_R^*}+\frac{k^2V_{n_R}}{n_R-1}\right)\tilde{\sigma}_{R,1}^2}},
\tau_2^\prime=\frac{\hat{\mu}_T-\hat{\mu}_R-k\hat{\sigma}_R}{\sqrt{\frac{\tilde{\sigma}_{T,2}^2}{n_T^*}+\left(\frac{1}{n_R^*}+\frac{k^2V_{n_R}}{n_R-1}\right)\tilde{\sigma}_{R,2}^2}},
where V_{n_R} = n_R-1-2\frac{\Gamma^22(n_R/2)}{\Gamma^2((n_R-1)/2)}
and \tilde{\sigma}_{T,i}
and \tilde{\sigma}_{R,i}
are the restricted maximum likelihood estimator of \sigma_T
and \sigma_R
respectively with the constraint \mu_T - \mu_R = (-1)^i \sigma_R
.
The null hypothesis H_0^\prime
is rejected at nominal size \alpha
if both \tau_1^\prime > z_{1-\alpha}
and \tau_2^\prime < -z_{1-\alpha}
where z_{1-\alpha}
is the (1-\alpha)
-th quantile of the standard normal distribution.
For more details, see the cited reference.
References
Dong X, Weng Y, Tsong Y (2017). “Adjustment for unbalanced sample size for analytical biosimilar equivalence assessment.” Journal of biopharmaceutical statistics, 27(2), 220–232.
Tsong Y, Dong X, Shen M (2017). “Development of statistical methods for analytical similarity assessment.” Journal of biopharmaceutical statistics, 27(2), 197–205.
Weng Y, Tsong Y, Shen M, Wang C (2018). “Improved Wald Test for Equivalence Assessment of Analytical Biosimilarity.” International Journal of Clinical Biostatistics and Biometrics, 4(1), 1–10.
Perform restricted MLE (RMLE) to estimate parameters under the constraint defined by the boundary of null hypothesis
Description
Perform restricted MLE (RMLE) to estimate parameters under the constraint defined by the boundary of null hypothesis, \mu_T - \mu_R = \eta\sigma_R
where \eta
is the margin multiplier.
Usage
RMLE_equivTest(nT, nR, smplMuT, smplMuR, smplSigmaT, smplSigmaR, vecT,
vecR, eta)
Arguments
nT |
sample size for test data |
nR |
sample size for reference data |
smplMuT |
sample mean for test data |
smplMuR |
sample mean for reference data |
smplSigmaT |
sample standard deviation for test data |
smplSigmaR |
sample standard devivation for reference data |
vecT |
a vector of observations for test product |
vecR |
a vector of observations for reference product |
eta |
the margin multipler |
Value
a list containing the RMLE for the means and standard deviations for both test and reference data
Create summary information of a dataset
Description
Create a list of summary statistics of a dataset for equivalence test.
Usage
createEquivTestSmpl(smpl)
Arguments
smpl |
a vector representing the dataset |
Value
a list of objects summarizing the dataset
Examples
vecT = rnorm(n=20)
s = createEquivTestSmpl(vecT)
Compute the Satterthwaite approximation of degree of freedom for t distribution
Description
Compute the Satterthwaite approximation of degree of freedom for t distribution.
Usage
dfSatterthwaite(s1, n1, n1s, s2, n2, n2s)
Arguments
s1 |
sample standard deviation for group 1 |
n1 |
sample size for group 1 |
n1s |
adjusted sample size for group 1 |
s2 |
sample standard deviation for group 2 |
n2 |
sample size for group 2 |
n2s |
adjusted sample size for group 2 |
Value
degree of freedom
Conduct the equivalence test with fixed margin
Description
Conduct the equivalence test with fixed margin.
Usage
equivTestFixedMargin(vecT, vecR, alpha = 0.05, marginX = 1.5,
sampleSizeX = 1.5, qa = "", sigmaTOverride = NULL,
labelT = "Proposed", labelR = "Reference", show.message = FALSE,
method = "Fixed Margin")
Arguments
vecT |
the sample data for test product, can be a vector of observed values or a list returned by |
vecR |
the sample data for reference product, can be a vector of observed values or a list returned by |
alpha |
the nominal size, default = 0.05 |
marginX |
the margin multiplier, default = 1.5 |
sampleSizeX |
the sample size adjustment coefficient, default = 1.5 |
qa |
a string representing the name of the quality attribute, default = "" |
sigmaTOverride |
a numeric value to override the estimate for standard deviation of the test product |
labelT |
the name of the test product, default = "Proposed" |
labelR |
the name of the reference product, default = "Reference" |
show.message |
a logic value indicating whether messages are to be shown, default = FALSE |
method |
a string indicating the method used in the equivalence test. |
Value
a list of objects summarizing the data and test results, in particular, rslt
= 1 if H_0
is rejected, and rslt
= 0 if H_0
is not rejected.
References
Tsong Y, Dong X, Shen M (2017). “Development of statistical methods for analytical similarity assessment.” Journal of biopharmaceutical statistics, 27(2), 197–205.
Examples
vecT = rnorm(20,-1.5,1)
vecR = rnorm(20,0,1)
et = equivTestFixedMargin(vecT, vecR)
Provide a combined plot for equivvalence test
Description
Provide a combined plot for equivalence test, including both scatter plot of the sample data and a bar plot indicating the test result, where the null hypothesis is rejected if the red line representing the mean value of the test product lies within a grey rectangle centered at a blue line representing the mean value of the reference product.
Usage
equivTestFixedMarginCombPlot(et)
Arguments
et |
the list returned by |
Examples
vecR = rnorm(20,0,1)
vecT = rnorm(20,-1.5,1)
et = equivTestFixedMargin(vecT,vecR)
equivTestFixedMarginCombPlot(et)
Equivalence test by Modified Wald test with standard error estimated by RMLE (MWCMLE)
Description
Equivalence test by Modified Wald test with standard error estimated by RMLE (MWCMLE).
Usage
equivTestMWCMLE(vecT, vecR, alpha = 0.05, marginX = 1.7,
method = "MWCMLE")
Arguments
vecT |
the sample data for test product, can be a vector of observed values or a list returned by |
vecR |
the sample data for reference product, can be a vector of observed values or a list returned by |
alpha |
the nominal size, default = 0.05 |
marginX |
the margin multiplier, default = 1.5 |
method |
a string indicating the method used in the equivalence test. |
Details
See Weng et al. (2018).
Value
a list containing the test result
References
Weng Y, Tsong Y, Shen M, Wang C (2018). “Improved Wald Test for Equivalence Assessment of Analytical Biosimilarity.” International Journal of Clinical Biostatistics and Biometrics, 4(1), 1–10.
Plot the equivalence test result
Description
Plot the equivalence test result including the margin, confidence intervals of the mean difference, and estimated mean difference.
Usage
equivTestPlot(meanDif, ci, alpha, margin, qaNameLong, testDrugName = "",
refDrugName = "", showDrugName = FALSE, showQA = FALSE,
showCINumbers = FALSE)
Arguments
meanDif |
difference between mean of test and reference product |
ci |
confidence interval for mean difference, a vector of two values |
alpha |
nominal level of the hypothesis test |
margin |
a vector consisting of lower margin and upper margin |
qaNameLong |
the quality attribute name |
testDrugName |
test drug name |
refDrugName |
reference drug name |
showDrugName |
logic value indicating if the drug names are to be shown. |
showQA |
logic value indicating if the quality attribute (QA) is to be shown. |
showCINumbers |
whether CI values are shown in the figure. |
Examples
equivTestPlot(0.623,c(-2,2),0.05,c(-9.79,9.79),
"q a","test","reference")
equivTestPlot(0.623,c(-2,2),0.05,c(-9.79,9.79),
"Relative Potency","test","reference",showDrugName = TRUE,showQA=TRUE,showCINumbers = TRUE)
equivTestPlot(0.5,c(-1.05,2.05),0.05,c(-9.79,9.79),
"Relative Potency","test","reference",showQA=TRUE,showCINumbers = TRUE)
Histogram with a fitted normal density function
Description
Provide a histogram with a fitted normal density.
Usage
histWNormDensity(x, main = "")
Arguments
x |
the data |
main |
the title of the plot |
Examples
x = rnorm(20)
histWNormDensity(x)
Provide a side-by-side scatter plot of two or three datasets for equivalence test.
Description
Provide a side-by-side scatter plot of two samples for equivalence test.
Usage
scatterPlotEquivTestData(vecT, vecR, vecR1 = NULL, qa = "",
labelT = "Test", labelR = "Reference", labelR1 = "Reference1")
Arguments
vecT |
a vector of the sample for test product |
vecR |
a vector of the sample for reference product |
vecR1 |
a vector of the sample for reference product R1 |
qa |
a string representing the name of the quality attribute, default = "" |
labelT |
the name of the test product, default = "Proposed" |
labelR |
the name of the reference product, default = "Reference" |
labelR1 |
label for reference product R1 |
Examples
vecT = rnorm(20,-1.5,1)
vecR = rnorm(20,0,1)
vecR1 = rnorm(20,0,1)
scatterPlotEquivTestData(vecT,vecR,labelT="T",labelR="R",qa="potency")
scatterPlotEquivTestData(vecT,vecR,vecR1,labelT="T",labelR="R",labelR1="R1",qa="potency")
Summarize data for equivalence test
Description
Summarize data for equivalence test, can be two datasets or three datasets.
Usage
summarizeSample(vecT, labelT, vecR, labelR, vecR1 = NULL, labelR1 = "")
Arguments
vecT |
vector of sample for T |
labelT |
label for T |
vecR |
vector of sample for R |
labelR |
label for R |
vecR1 |
vector of sample for R1 |
labelR1 |
label for R1 |
Value
a data.frame consisting the sample size, min, max, mean, SD, and percentage coefficient of variation for the samples
Examples
vecT = rnorm(10,-1.5,1)
vecR = rnorm(10)
vecR1 = rnorm(15,1,2)
ss = summarizeSample(vecT,"T",vecR,"R",vecR1,"R1")