Trials to a given precision; Sample size [Power / Sample Size]
Dear all,
in clinical development one often performs trials in order to estimate possible effects instead of testing whether there is a significant effect or not. Therefore one is more interested in the confidence interval itself and requires this to be no larger than a pre-specified width 2w. The question what sample size should be used boils down to solving w >= qantile*sqrt(Var(S)) iteratively, where Var(S) depends on n. As the focus is on the confidence interval it is however recommended to assure that with a certain probability 1-gamma (the so called coverage probability) the half-width of the CI is actually not greater than w, see Kupper and Hafner in their 1989 article "How Appropriate Are Popular Sample Size Formulas?" (The American Statistician, vol 43, pp 101-105). They consider the one-sample and the two-sample case. nQuery also has a way to calculate the desired sample size, but again only for a two group design (module MTG) and a 2x2 design (module MOC) (actually nQuery calls it paired design). So I tried to implement the procedure, extending it a little bit to allow for more possible designs (as in the function CVfromCI from the R package PowerTOST).
I played a little bit and some issues/questions came up.
Best,
Ben
in clinical development one often performs trials in order to estimate possible effects instead of testing whether there is a significant effect or not. Therefore one is more interested in the confidence interval itself and requires this to be no larger than a pre-specified width 2w. The question what sample size should be used boils down to solving w >= qantile*sqrt(Var(S)) iteratively, where Var(S) depends on n. As the focus is on the confidence interval it is however recommended to assure that with a certain probability 1-gamma (the so called coverage probability) the half-width of the CI is actually not greater than w, see Kupper and Hafner in their 1989 article "How Appropriate Are Popular Sample Size Formulas?" (The American Statistician, vol 43, pp 101-105). They consider the one-sample and the two-sample case. nQuery also has a way to calculate the desired sample size, but again only for a two group design (module MTG) and a 2x2 design (module MOC) (actually nQuery calls it paired design). So I tried to implement the procedure, extending it a little bit to allow for more possible designs (as in the function CVfromCI from the R package PowerTOST).
require(PowerTOST)
ss_ci <- function(w, sigma, design="2x2", alpha=0.1, gamma=0.05) {
# w is the desired precision
# 1-alpha is the confidence level
# 1-gamma is the coverage probability
# get degrees of freedom
# and design constant
# (copied from CVfromCI)
d.no <- .design.no(design)
if (is.na(d.no))
stop("Unknown design!", call. = FALSE)
desi <- .design.props(d.no)
dfe <- parse(text = desi$df[1], srcfile = NULL)
bk <- desi$bk
# Calculate n: precision CI w/o coverage probability
#
n <- 1
while ( eval(dfe) < 1 ) {
n <- n+1
}
n_start <- n
t_n <- qt(1-alpha/2, eval(dfe))
while ( n < bk*((sigma/w) * t_n)^2 ) {
n <- n+1
t_n <- qt(1-alpha/2, eval(dfe))
}
n_nocp <- n
cat("n w/o coverage probability = ", n_nocp, "\n")
# Calculate new n: precision CI with coverage probability
#
n <- n_start
chi <- qchisq(1-alpha, 1)
chi_n <- qchisq(1-gamma, eval(dfe))
f_n <- qf(1-alpha, 1, eval(dfe))
while ( bk*n*(n-1)/n_nocp < (chi_n*f_n)/chi ) {
n <- n+1
chi_n <- qchisq(1-gamma, eval(dfe))
f_n <- qf(1-alpha, 1, eval(dfe))
}
cat("final n with coverage probability:", "\n")
return(n)
}I played a little bit and some issues/questions came up.
- Using ss_ci with design "2x2", some precision w and sigma s I do not get the same sample sizes as nQuery's (version 6) paired means module MOC. I do get the same results as MOC (which by the way uses s*sqrt(2) as variability because it enables nQuery to use the same formula for both the two group design and the crossover design) when using the "parallel" design (with s as input variability). So the first two questions that pop into my mind are: Are my calculations in error or those of nQuery? Does nQuery use the correct degrees of freedom?
- The second issue I observed when using the 2x2 design is the following. As the half-width w decreases (less than or equal to 0.1 if sigma=0.2) and all other parameters remain the same the initial sample size (based only on w >= quantile*sqrt(Var(S))) will be larger than the final sample size that includeds the coverage probability. The reason for that is the new degrees of freedom, but this does not make any sense, does it?
- The final sample size in the 2x2 case will be less than the final sample size obtained from a 3x3, 4x4, 2x2x3 or a 2x2x4 design, which again does not make sense?
Best,
Ben
Complete thread:
- Trials to a given precision; Sample sizeBen 2011-11-14 19:16
- Sample size for a given precision of CI d_labes 2011-11-16 09:40
- Sample size for a given precision of CI Ben 2011-11-18 16:57
- Sample size for a given precision of CI Ben 2011-11-21 19:13
- Some minor comments d_labes 2011-11-22 15:37
- Some minor comments Ben 2011-11-23 21:12
- Some minor comments Ben 2011-11-25 17:28
- Using undocumented functions - PowerTOST v0.9-0 d_labes 2011-12-15 09:28
- Using undocumented functions - PowerTOST v0.9-0 Ben 2011-12-16 19:06
- Using undocumented functions - PowerTOST v0.9-0 d_labes 2011-12-15 09:28
- Some minor comments Ben 2011-11-25 17:28
- Some minor comments Ben 2011-11-23 21:12
- Some minor comments d_labes 2011-11-22 15:37
- Sample size for a given precision of CI Ben 2011-11-21 19:13
- Sample size for a given precision of CI Ben 2011-11-18 16:57
- Sample size for a given precision of CI d_labes 2011-11-16 09:40
