ci_p_wald_t | R Documentation |
This function calculates the Wald-t confidence interval for a Binomial
proportion using the method XIX proposed by Pan (2002).
It incorporates the use of a t-distribution with adjusted degrees of
freedom \nu
, as specified in equation (2.8).
The function is vectorized, allowing for evaluation of single
values or vectors.
ci_p_wald_t(x, n, conf.level = 0.95)
x |
A number or a vector with the number of successes. |
n |
A number or a vector with the number of trials. |
conf.level |
Confidence level for the returned confidence interval. By default, it is 0.95. |
The Wald-t confidence interval is a modification of the classical
Wald interval that uses the t-distribution instead of the normal
distribution for greater accuracy in small samples. The estimated
proportion \hat{p}
is adjusted as:
\hat{p} = \frac{x + 2}{n + 4},
which reduces bias in the interval estimation. The variance
V(\hat{p}, n)
is given by:
V(\hat{p}, n) = \frac{\hat{p}(1 - \hat{p})}{n}.
The degrees of freedom \nu
are calculated using equation (2.8):
\nu = \frac{2 V(\hat{p}, n)^2}{\Omega(\hat{p}, n)},
where \Omega(\hat{p}, n)
is defined as:
\Omega(\hat{p}, n) = \frac{\hat{p} - \hat{p}^2}{n^3} + \frac{\hat{p} + (6n - 7)\hat{p}^2 + 4(n - 1)(n - 3)\hat{p}^3 - 2(n - 1)(2n - 3)\hat{p}^4}{n^5} - \frac{2(\hat{p} + (2n - 3)\hat{p}^2 - 2(n - 1)\hat{p}^3)}{n^4}.
The confidence interval is then calculated as:
\text{Lower} = \max\left(0, \hat{p} - t \cdot \sqrt{V(\hat{p}, n)}\right),
\text{Upper} = \min\left(1, \hat{p} + t \cdot \sqrt{V(\hat{p}, n)}\right),
where t
is the critical value from the t-distribution
with \nu
degrees of freedom.
A vector with the lower and upper limits of the confidence interval.
David Esteban Cartagena Mejía, dcartagena@unal.edu.co
Pires, Ana M., and Conceiçao Amado. "Interval estimators for a binomial proportion: Comparison of twenty methods". REVSTAT-Statistical Journal 6.2 (2008): 165-197.
ci_p.
ci_p_wald_t(x = 0, n = 50, conf.level = 0.95)
ci_p_wald_t(x = 15, n = 50, conf.level = 0.95)
ci_p_wald_t(x = 50, n = 50, conf.level = 0.95)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.