View source: R/ciss.liubailey.R
ciss.liubailey | R Documentation |
Calculate sample size for a binomial proportion based on the confidence interval width specification in Liu and Bailey (2002).
ciss.liubailey(alpha, d, lambda.grid = 0:30)
alpha |
a |
d |
half width of the confidence interval |
lambda.grid |
range of lambda values to try |
The objective is to find the minimum sample size n
so that the
minimum coverage probability (aka. as the coverage coefficient) of the
confidence interval for the binomial parameter is larger than
1-\alpha
. In the present approach the confidence interval is of
form
(C_n(\hat{p}_n)-d,C_n(\hat{p}_n)+d)
as suggested in equation (3.1) of Liu & Bailey (2002):
(\hat{p}_l,\hat{p}_u) = \hat{p}_n + \frac{\lambda z^2
(0.5-\hat{p}_n)}{n+z^2} \pm d
where \hat{p}_n = x/n
. The interval is then expanded to a full
length of 2d
using the following transformation:
\hat{p}_l^* = \max(0,\min( 1-2d, \hat{p}_l))
\hat{p}_u^*
= \min(1,\max( 2d, \hat{p}_u))
As a consequence, the computed
interval will always have length 2d
.
Given d
, fixed lambda
and a sample size n
, the
proportion p
in [0,1] where the coverage probability is minimum
is computed. The sample size is then gradually increased until this
minimum coverage probability becomes larger than 1-\alpha
. We
then change the value of \lambda
, and search the minimum sample
size that guarantee the 1-\alpha
confidence level for this
lambda value. The smallest minimum sample size over a set of lambda
values in lambda.grid
is then used as the required sample size;
this sample size and the corresponding lambda value are used to
calculate the confidence interval given above.
For a general overview of coverage probabilities of confidence
intervals for a binomial proportion see Agresti and Coull (1998). Once
actual binomial data are obtained the function
binom.liubailey
can be used to compute the actual
confidence interval.
The R function code calls the original Fortran code developed for the Liu and Bailey (2002) article. NAG calls were replaced by R API calls and an R wrapper calling the code as a subroutine was created.
a vector containing the following three elements
nstar |
sample size at most favorable lambda value in |
cp |
coverage probability |
lambda |
value in lambda.grid giving the lowest |
M. Höhle and W. Liu
Agresti, A. and Coull, B.A. (1998), Approximate is Better than "Exact" for Interval Estimation of Binomial Proportions, The American Statistician, 52(2):119-126.
Liu, W. and Bailey, B.J.R. (2002), Sample size determination for constructing a constant width confidence interval for a binomial success probability. Statistics and Probability Letters, 56(1):1-5.
binom.liubailey
ciss.liubailey(alpha=0.1,d=0.05)
ciss.liubailey(alpha=0.1,d=0.05,lambda.grid=5)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.