Algebra [Power / Sample Size]
❝ Even I am getting around CV = 156% (pooled variance estimate) considering N=140 (N=70/group).
❝ Only when N=70 is considered, I am getting CV~92%.
How did you calculate it?
The lower and upper limits \(\small{\{L,U\}}\) of a \(\small{1-2\,\alpha}\) confidence interval for given sample sizes \(\small{n_1,\,n_2}\)1 are calculated by $$\{L,U\}=\exp\left(\log_e(PE)\mp t_{1-\alpha,n_1+n_2-2}\cdot \sqrt{MSE\cdot(1/n_1+1/n_2)} \right)\textsf{.}\tag{1}$$ Hence, for given \(\small{1-2\,\alpha}\), \(\small{\{L,U\}}\), and \(\small{n_1,\,n_2}\) we can derive the \(\small{MSE}\) and subsequently calculate the \(\small{CV}\):
- Calculate the point estimate \(\small{PE}\) and \(\small{\Delta_\text{CL}}\):$$PE=\sqrt{L\cdot U}\tag{2}$$$$\Delta_\text{CL}=\log_{e}PE-\log_{e}L\;\small{\textsf{or}}\tag{3a}$$$$\Delta_\text{CL}=\log_{e}U-\log_{e}PE\textsf{,}\phantom{\small{\textsf{or}}}\tag{3b}$$ where \(\small{\Delta_\text{CL}}\) is the difference between one of the confidence limits and the point estimate in \(\small{\log_{e}\textsf{-}}\)scale (aka the ‘log half-width’). In practice select \(\small{(3\text{a})}\) or \(\small{(3\text{b})}\) which is based on the most significant digits.
- \(\small{\log_{e}}\)-transform \(\small{(1)}\):$$\log_e\{L,U\}=\log_e(PE)\mp t_{1-\alpha,n_1+n_2-2}\cdot \sqrt{MSE\cdot(1/n_1+1/n_2)}\tag{4}$$
- Rearrange \(\small{(3)}\), substitute in \(\small{(4)}\), and cancel \(\small{\log_e(PE)}\):$$\require{cancel}\eqalign{\Delta_\text{CL}&=\cancel{\log_e(PE)-\log_e(PE)+}t_{1-\alpha,n_1+n_2-2}\cdot \sqrt{MSE\cdot(1/n_1+1/n_2)}\\
&=t_{1-\alpha,n_1+n_2-2}\cdot \sqrt{MSE\cdot(1/n_1+1/n_2)}}\tag{5}$$ - Solve \(\small{(5)}\) for \(\small{MSE}\): $$\eqalign{\sqrt{MSE\cdot(1/n_1+1/n_2)}&=\Delta_\text{CL}/t_{1-\alpha,n_1+n_2-2}\\
MSE\cdot(1/n_1+1/n_2)&=\left(\Delta_\text{CL}/t_{1-\alpha,n_1+n_2-2}\right)^2\\
MSE&=\frac{\left(\Delta_\text{CL}/t_{1-\alpha,n_1+n_2-2}\right)^2}{1/n_1+1/n_2}\\
\small{\color{Blue}{\textsf{Note that if }}}\color{Blue}{n_1=n_2:}MSE&=\frac{\color{Blue}{N}\cdot\left(\Delta_\text{CL}/t_{1-\alpha,\color{Blue}{N}-2}\right)^2}{\color{Blue}{4}}}\tag{6}$$ If only the total sample size \(\small{N}\) is known and \(\small{n_1 \neq n_2}\), the calculated \(\small{MSE}\) will be larger than the true one. Hence, if used in a sample size estimation it will be conservative.
- Finally as usual:$$CV=\sqrt{\exp(MSE)-1}\tag{7}$$
CI2CV()
of PowerTOST
.With Sereng’s numbers:$$\{L,U\}=\{0.87,1.35\},\,n_1=n_2=70,\,N=n_1+n_2=140\\\nu=N-2=138,\,\alpha=0.05,\,t_{1-\alpha,\nu}=1.65597$$ $$PE\approx\sqrt{0.87\times1.35}\approx1.08374\tag{←2}$$ $$\Delta_\text{CL}\approx\log_e1.35-\log_e1.08374\approx\log_e1.08374-\log_e0.87\approx0.21968\tag{←3}$$ $$MSE\approx\frac{\left(0.21968/1.65597\right)^2}{1/70+1/70}\approx\frac{140\times\left(0.21968/1.65597\right)^2}{4}\approx0.61595\tag{←6}$$ $$CV\approx\sqrt{\exp(0.61595)-1}\approx\color{DarkGreen}{0.92272}\tag{←7}$$ Check whether the recalculated \(\small{MSE}\) is correct: $$\{L,U\}\approx100\exp\left(\log_e 1.08374\mp 1.65597\times \sqrt{0.61595\times(1/70+1/70)}\right)\sim\color{DarkGreen}{\{87,135\}}\;\tiny{\blacksquare}\tag{←1}$$ If results don’t match:
- Check the data you used;
- if the correct data was used, the confidence interval was calculated by the Welch-test and not by the conventional t-test (see this post). I haven’t tried yet to derive the \(\small{MSE}\) from it.
Consequently, the \(\small{MSE}\) doubles and the \(\small{CV}\) is much larger than the correct \(\small{\approx92\%}\): $$\eqalign{MSE&\approx\frac{140\times\left(0.21968/1.65597\right)^2}{\color{Red}{2}}\approx1.23193\\
CV&\approx100\sqrt{\exp(1.23193)-1}\approx\color{Red}{156\%}
}$$ Try:
library(PowerTOST)
print(known.designs()[c(1, 3), c(2:3, 6, 9)], row.names = FALSE)
design df bk name
parallel n-2 4 2 parallel groups
2x2x2 n-2 2 2x2x2 crossover
design
argument to be used in the functions CI2CV()
and CI.BE()
, the second are the degrees of freedom (where n
is the total sample size), and bk
is the ‘design constant’ or the denominator used in \(\small{(6)}\).You will see that with your \(\small{CV}\) the backcalculated confidence interval does not match the original \(\small{\left\{87,135\right\}}\):
CV <- 1.558152
MSE <- log(CV^2 + 1) # trivial
CI <- round(100 * exp(log(1.083744) + c(-1, +1) *
1.65597 * sqrt(MSE * (1 / 70 + 1 / 70))), 2) # (1)
cat("CI =", paste0("{", paste(CI, collapse = ", ") , "}\n"))
isTRUE(all.equal(c(87, 135), CI)) # check
CI = {79.43, 147.86}
[1] FALSE
In
PowerTOST
without rounding:library(PowerTOST)
CV <- CI2CV(lower = 0.87, upper = 1.35, n = c(70, 70), design = "parallel")
CI <- 100 * CI.BE(CV = CV, pe = sqrt(0.87 * 1.35), n = c(70, 70), design = "parallel")
cat("CV =", CV, "\nCI =", paste0("{", paste(CI, collapse = ", ") , "}\n"))
isTRUE(all.equal(100 * c(0.87, 1.35), as.numeric(CI))) # check
CV = 0.9227379
CI = {87, 135}
[1] TRUE
If you don’t trust in the functions of
PowerTOST
, use the formulas from above in Base :L <- 87 / 100
U <- 135 / 100
n1 <- n2 <- 70
N <- n1 + n2
PE <- sqrt(L * U) # (2)
signif.L <- nchar(as.character(signif(L * 100, 12)))
signif.U <- nchar(as.character(signif(U * 100, 12)))
if (signif.L >= signif.U) {
Delta.CL <- log(PE) - log(L) # (3a)
} else {
Delta.CL <- log(U) - log(PE) # (3b)
}
alpha <- 0.05
nu <- N - 2
t.value <- qt(p = 1 - alpha, df = nu)
MSE <- (Delta.CL / t.value)^2 / (1 / n1 + 1 / n2) # (6)
CV <- sqrt(exp(MSE) - 1) # (7)
CI <- exp(log(PE) + c(-1, +1) *
t.value * sqrt(MSE * (1 / n1 + 1 / n2))) # (1)
txt <- paste(
paste0("\n", paste(rep("—", 30), collapse = "")),
"\nGiven",
paste0("\n", paste(rep("—", 30), collapse = "")),
"\nn1 =", sprintf("%3.0f", n1),
"\nn2 =", sprintf("%3.0f", n2),
"\nalpha =", sprintf("%6.5g", alpha),
"\nL =", sprintf("%6.2f%%", 100 * L),
"\nU =", sprintf("%6.2f%%", 100 * U),
paste0("\n", paste(rep("—", 30), collapse = "")),
"\nCalculated Formula",
paste0("\n", paste(rep("—", 30), collapse = "")),
"\nN =", sprintf("%3.0f", N),
"\nPE =", sprintf("%6.2f%%", 100 * PE),
" (2)",
"\nDelta =", sprintf("%9.5f", Delta.CL),
" (3)",
"\nnu =", sprintf("%3.0f", nu),
"\nt =", sprintf("%9.5f", t.value),
"\nMSE =", sprintf("%9.5f", MSE),
" (6)",
"\nCV =", sprintf("%6.2f%%", 100 * CV),
" (7)",
paste0("\n", 100 * (1 - 2 * alpha), "% CI ="),
sprintf("{%.2f%%,", 100 * CI[1]),
sprintf("%.2f%%} (1)", 100 * CI[2]),
paste0("\n", paste(rep("—", 30), collapse = "")))
if (isTRUE(all.equal(100 * c(L, U), round(100 * CI, 2)))) {
txt <- paste0(txt, "\nThe calculated CI agrees with\nthe given one.\n")
} else {
txt <- paste0(txt, "\nThe calculated CI does not\nagree with given one! ",
"Please\ncheck.\n")
}
cat(txt)
——————————————————————————————
Given
——————————————————————————————
n1 = 70
n2 = 70
alpha = 0.05
L = 87.00%
U = 135.00%
——————————————————————————————
Calculated Formula
——————————————————————————————
N = 140
PE = 108.37% (2)
Delta = 0.21968 (3)
nu = 138
t = 1.65597
MSE = 0.61597 (6)
CV = 92.27% (7)
90% CI = {87.00%, 135.00%} (1)
——————————————————————————————
The calculated CI agrees with
the given one.
- In a parallel design the indices refer to the groups and in a crossover to the sequences.
- Schütz H. Sample Size Estimation for BE Studies. Bucarest, 19 March 2013. Slides 26–29.
- Yuan J, Tong T, Tang M-L. Sample Size Calculation for Bioequivalence Studies Assessing Drug Effect and Food Effect at the Same Time With a 3-Treatment Williams Design. Regul Sci. 2013; 47(2): 242–7. doi:10.1177/2168479012474273.
Dif-tor heh smusma 🖖🏼 Довге життя Україна!
Helmut Schütz
The quality of responses received is directly proportional to the quality of the question asked. 🚮
Science Quotes
Complete thread:
- Back Calculating Sample Size Sereng 2022-05-12 17:40 [Power / Sample Size]
- Back Calculating Sample Size ElMaestro 2022-05-12 22:29
- Back Calculating Sample Size Helmut 2022-05-12 23:10
- Back Calculating Sample Size ElMaestro 2022-05-13 01:38
- Back Calculating Sample Size Sereng 2022-05-18 05:32
- PowerTOST: Total sample size Helmut 2022-05-18 08:55
- Back Calculating Sample Size dshah 2022-05-13 11:54
- AlgebraHelmut 2022-05-16 15:01
- Algebra d_labes 2022-05-16 18:58
- AlgebraHelmut 2022-05-16 15:01
- Back Calculating Sample Size Helmut 2022-05-12 23:10
- Parallel designs: Don’t use the (conventional) t-test! Helmut 2022-05-17 14:17
- Back Calculating Sample Size ElMaestro 2022-05-12 22:29