DiffProp {tolerance} | R Documentation |
Difference Between Two Proportions Distribution
Description
Density (mass), distribution function, quantile function, and random generation for the difference between two proportions. This is determined by taking the difference between two independent beta distributions.
Usage
ddiffprop(x, k1, k2, n1, n2, a1 = 0.5, a2 = 0.5,
log = FALSE, ...)
pdiffprop(q, k1, k2, n1, n2, a1 = 0.5, a2 = 0.5,
lower.tail = TRUE, log.p = FALSE, ...)
qdiffprop(p, k1, k2, n1, n2, a1 = 0.5, a2 = 0.5,
lower.tail = TRUE, log.p = FALSE, ...)
rdiffprop(n, k1, k2, n1, n2, a1 = 0.5, a2 = 0.5)
Arguments
x , q |
Vector of quantiles. |
p |
Vector of probabilities. |
n |
The number of observations. If |
k1 , k2 |
The number of successes drawn from groups 1 and 2, respectively. |
n1 , n2 |
The sample sizes for groups 1 and 2, respectively. |
a1 , a2 |
The shift parameters for the beta distributions. For the fiducial approach, we know that the lower and upper limits are set at |
log , log.p |
Logical vectors. If |
lower.tail |
Logical vector. If |
... |
Additional arguments passed to the Appell |
Details
The difference between two proportions distribution has a fairly complicated functional form. Please see the article by Chen and Luo (2011), who corrected a typo in the article by Nadarajah and Kotz (2007), for the functional form of this distribution.
Value
ddiffprop
gives the density (mass), pdiffprop
gives the distribution function, qdiffprop
gives the quantile function, and rdiffprop
generates random deviates.
References
Chen, Y. and Luo, S. (2011), A Few Remarks on 'Statistical Distribution of the Difference of Two Proportions', Statistics in Medicine, 30, 1913–1915.
Nadarajah, S. and Kotz, S. (2007), Statistical Distribution of the Difference of Two Proportions, Statistics in Medicine, 26, 3518–3523.
See Also
runif
and .Random.seed
about random number generation.
Examples
## Randomly generated data from the difference between
## two proportions distribution.
set.seed(100)
x <- rdiffprop(n = 100, k1 = 2, k2 = 10, n1 = 17, n2 = 13)
hist(x, main = "Randomly Generated Data", prob = TRUE)
x.1 <- sort(x)
y <- ddiffprop(x = x.1, k1 = 2, k2 = 10, n1 = 17, n2 = 13)
lines(x.1, y, col = 2, lwd = 2)
plot(x.1, pdiffprop(q = x.1, k1 = 2, k2 = 10, n1 = 17,
n2 = 13), type = "l", xlab = "x",
ylab = "Cumulative Probabilities")
qdiffprop(p = 0.20, k1 = 2, k2 = 10, n1 = 17, n2 = 13,
lower.tail = FALSE)
qdiffprop(p = 0.80, k1 = 2, k2 = 10, n1 = 17, n2 = 13)