Title: | Equivalence Test for the Means of Two Normal Distributions |
---|---|
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. |
Authors: | Chao Wang [aut, cre] |
Maintainer: | Chao Wang <[email protected]> |
License: | GPL-3 |
Version: | 0.0.1.1 |
Built: | 2025-02-14 06:27:18 UTC |
Source: | https://github.com/cran/equivalenceTest |
Create a list of summary statistics of a dataset for equivalence test.
createEquivTestSmpl(smpl)
createEquivTestSmpl(smpl)
smpl |
a vector representing the dataset |
a list of objects summarizing the dataset
vecT = rnorm(n=20) s = createEquivTestSmpl(vecT)
vecT = rnorm(n=20) s = createEquivTestSmpl(vecT)
Compute the Satterthwaite approximation of degree of freedom for t distribution.
dfSatterthwaite(s1, n1, n1s, s2, n2, n2s)
dfSatterthwaite(s1, n1, n1s, s2, n2, n2s)
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 |
degree of freedom
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).
Let for
and
, where
stands for test distribution and
for reference distribution.
The equivalence test here considers the following hypotheses,
where is the equivalence margin.
Let and
be the sample mean and unbiased sample variance estimates respectively for
.
Tsong et al. (2017) define the follows test statistics,
and
where and
are possibly adjusted sample sizes proposed by Dong et al. (2017).
The null hypothesis is rejected at nominal size
if both
and
where
is the
-th quantile of the t-distribution with degree of freedom
, which is approximated by the Satterthwaite method with sample size adjusted and given as follows,
The above assumes that is a predetermined constant. However, in many studies, such constant is not available, and
must be determined by the study data. A popular choice is
. In this case, the above test may not control type I error well.
Replacing by
, the hypotheses becomes
Weng et al. (2018) proposed an improved Wald test with the following test statistics,
where and
and
are the restricted maximum likelihood estimator of
and
respectively with the constraint
.
The null hypothesis is rejected at nominal size
if both
and
where
is the
-th quantile of the standard normal distribution.
For more details, see the cited reference.
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.
Conduct the equivalence test with fixed margin.
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")
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")
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. |
a list of objects summarizing the data and test results, in particular, rslt
= 1 if is rejected, and
rslt
= 0 if is not rejected.
Tsong Y, Dong X, Shen M (2017). “Development of statistical methods for analytical similarity assessment.” Journal of biopharmaceutical statistics, 27(2), 197–205.
vecT = rnorm(20,-1.5,1) vecR = rnorm(20,0,1) et = equivTestFixedMargin(vecT, vecR)
vecT = rnorm(20,-1.5,1) vecR = rnorm(20,0,1) et = equivTestFixedMargin(vecT, vecR)
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.
equivTestFixedMarginCombPlot(et)
equivTestFixedMarginCombPlot(et)
et |
the list returned by |
vecR = rnorm(20,0,1) vecT = rnorm(20,-1.5,1) et = equivTestFixedMargin(vecT,vecR) equivTestFixedMarginCombPlot(et)
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).
equivTestMWCMLE(vecT, vecR, alpha = 0.05, marginX = 1.7, method = "MWCMLE")
equivTestMWCMLE(vecT, vecR, alpha = 0.05, marginX = 1.7, method = "MWCMLE")
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. |
See Weng et al. (2018).
a list containing the test result
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 including the margin, confidence intervals of the mean difference, and estimated mean difference.
equivTestPlot(meanDif, ci, alpha, margin, qaNameLong, testDrugName = "", refDrugName = "", showDrugName = FALSE, showQA = FALSE, showCINumbers = FALSE)
equivTestPlot(meanDif, ci, alpha, margin, qaNameLong, testDrugName = "", refDrugName = "", showDrugName = FALSE, showQA = FALSE, showCINumbers = FALSE)
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. |
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)
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)
Provide a histogram with a fitted normal density.
histWNormDensity(x, main = "")
histWNormDensity(x, main = "")
x |
the data |
main |
the title of the plot |
x = rnorm(20) histWNormDensity(x)
x = rnorm(20) histWNormDensity(x)
Perform restricted MLE (RMLE) to estimate parameters under the constraint defined by the boundary of null hypothesis, where
is the margin multiplier.
RMLE_equivTest(nT, nR, smplMuT, smplMuR, smplSigmaT, smplSigmaR, vecT, vecR, eta)
RMLE_equivTest(nT, nR, smplMuT, smplMuR, smplSigmaT, smplSigmaR, vecT, vecR, eta)
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 |
a list containing the RMLE for the means and standard deviations for both test and reference data
Provide a side-by-side scatter plot of two samples for equivalence test.
scatterPlotEquivTestData(vecT, vecR, vecR1 = NULL, qa = "", labelT = "Test", labelR = "Reference", labelR1 = "Reference1")
scatterPlotEquivTestData(vecT, vecR, vecR1 = NULL, qa = "", labelT = "Test", labelR = "Reference", labelR1 = "Reference1")
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 |
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")
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, can be two datasets or three datasets.
summarizeSample(vecT, labelT, vecR, labelR, vecR1 = NULL, labelR1 = "")
summarizeSample(vecT, labelT, vecR, labelR, vecR1 = NULL, labelR1 = "")
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 |
a data.frame consisting the sample size, min, max, mean, SD, and percentage coefficient of variation for the samples
vecT = rnorm(10,-1.5,1) vecR = rnorm(10) vecR1 = rnorm(15,1,2) ss = summarizeSample(vecT,"T",vecR,"R",vecR1,"R1")
vecT = rnorm(10,-1.5,1) vecR = rnorm(10) vecR1 = rnorm(15,1,2) ss = summarizeSample(vecT,"T",vecR,"R",vecR1,"R1")