ci.pd {Epi} | R Documentation |
The usual formula for the c.i. of at difference of proportions is inaccurate. Newcombe has compared 11 methods and method 10 in his paper looks like a winner. It is implemented here.
ci.pd(aa, bb, cc, dd, alpha = 0.05, print = TRUE)
aa |
Numeric vector of successes in sample 1. Can also be a matrix (see details). |
bb |
Successes in sample 2. |
cc |
Failures in sample 1. |
dd |
Failures in sample 2. |
alpha |
Significance level |
print |
Should an account of the two by two table be
printed. Ignored if more than difference is computed, i.e. if
aa , bb , cc and dd are vectors or if aa
is a 3-dimensional matrix. |
aa
, bb
, cc
and dd
can be vectors.
If aa
is a matrix, the elements [1:2,1:2]
are used, with
successes aa[,1:2]
. If aa
is a three-way table or array,
the elements aa[1:2,1:2,]
are used.
A matrix with three columns: probability difference, lower and upper
limit. The number of rows equals the length of the vectors aa
,
bb
, cc
and dd
or, if aa
is a 3-way matrix,
dim(aa)[3]
.
Bendix Carstensen, http://www.biostat.ku.dk/~bxc
RG Newcombe: Interval estimation for the difference between independent proportions. Comparison of eleven methods. Statistics in Medicine, 17, pp. 873-890, 1998.
( a <- matrix( sample( 10:40, 4 ), 2, 2 ) ) ci.pd( a ) twoby2( t(a) ) prop.test( t(a) ) ( A <- array( sample( 10:40, 20 ), dim=c(2,2,5) ) ) print( ci.pd( A ) )