<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title>R: Confidence Intervals for the Ratio of Binomial and...</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" href="R.css" />
</head><body>

<table width="100%" summary="page for BinomRatioCI {DescTools}"><tr><td>BinomRatioCI {DescTools}</td><td style="text-align: right;">R Documentation</td></tr></table>

<h2>
Confidence Intervals for the Ratio of Binomial and Multinomial Proportions
</h2>

<h3>Description</h3>

<p>A number of methods have been develeloped for obtaining confidence intervals for the ratio of two binomial proportions.  These include the Wald/Katz-log method (Katz et al. 1978), 
adjusted-log (Walter 1975, Pettigrew et al. 1986), Koopman asymptotic score (Koopman 1984), Inverse hyperbolic sine transformation (Newman 2001), the Bailey method (Bailey (1987), 
and the Noether (1957) procedure. Koopman results are found iteratively for most intervals using root finding.   
</p>


<h3>Usage</h3>

<pre>
BinomRatioCI(x1, n1, x2, n2, conf.level = 0.95, method = "katz.log", 
             bonf = FALSE, tol = .Machine$double.eps^0.25, R = 1000, r = length(x1))
</pre>


<h3>Arguments</h3>

<table summary="R argblock">
<tr valign="top"><td><code>x1</code></td>
<td>

<p>The ratio numerator number of successes.  A scalar or vector.
</p>
</td></tr>
<tr valign="top"><td><code>n1</code></td>
<td>

<p>The ratio numerator number of trials.  A scalar or vector of <code>length(y1)</code>
</p>
</td></tr>
<tr valign="top"><td><code>x2</code></td>
<td>

<p>The ratio denominator number of successes.  A scalar or vector of <code>length(y1)</code>
</p>
</td></tr>
<tr valign="top"><td><code>n2</code></td>
<td>

<p>The ratio denominator number of trials. A scalar or vector of <code>length(y1)</code>
</p>
</td></tr>
<tr valign="top"><td><code>conf.level</code></td>
<td>

<p>The level of confidence, i.e. 1 - <em>P</em>(type I error). 
</p>
</td></tr>
<tr valign="top"><td><code>method</code></td>
<td>

<p>Confidence interval method.  One of <code>"adj.log"</code>, <code>"bailey"</code>,  
<code>"boot"</code>, <code>"katz.log"</code>, <code>"koopman"</code>, <code>"sinh-1"</code> or 
<code>"noether"</code>.  Partial distinct names can be used.  
</p>
</td></tr>
<tr valign="top"><td><code>bonf</code></td>
<td>

<p>Logical, indicating whether or not Bonferroni corrections should be applied for simultaneous inference if <code>y1, y2, n1</code> and <code>n2</code> are vectors.
</p>
</td></tr>  
<tr valign="top"><td><code>tol</code></td>
<td>
<p>The desired accuracy (convergence tolerance) for the iterative root finding procedure when finding Koopman intevals. The default is taken to be the smallest positive floating-point number of the workstation implementing the function, raised to the 0.25 power, and will normally be approximately 0.0001.
</p>
</td></tr>
<tr valign="top"><td><code>R</code></td>
<td>
<p>If method <code>"boot"</code> is chosen, the number of bootstrap iterations.
</p>
</td></tr>
<tr valign="top"><td><code>r</code></td>
<td>
<p>The number of ratios to which family-wise inferences are being made.  Assumed to be <code>length(y1)</code>. 
</p>
</td></tr>
</table>


<h3>Details</h3>

<p>Let <i>Y_1</i> and <i>Y_2</i> be multinomial random variables with parameters <i>n_1, &pi;_{1i}</i>,  and  <i>n_2, &pi;_{2i}</i>, respectively; where <i>i = \{1, 2, 3, &hellip;, r\}</i>.  This encompasses the binomial case in which <i>r = 1</i>. We define the true selection ratio for the <em>i</em>th resource of <em>r</em> total resources to be:
</p>
<p style="text-align: center;"><i>&theta;_{i}=\frac{&pi; _{1i}}{&pi; _{2i}}</i></p>

<p>where <i>&pi;_{1i}</i> and <i>&pi;_{2i}</i> represent the proportional use and availability of the <em>i</em>th resource, respectively. Note that if <i>r = 1</i> the selection ratio becomes relative risk.  The maximum likelihood estimators for <i>&pi;_{1i}</i> and <i>&pi;_{2i}</i> are the sample proportions: 
</p>
<p style="text-align: center;"><i>{{\hat{&pi; }}_{1i}}=\frac{{{y}_{1i}}}{{{n}_{1}}},</i></p>
<p> and
</p>
<p style="text-align: center;"><i>{{\hat{&pi; }}_{2i}}=\frac{{{y}_{2i}}}{{{n}_{2}}}</i></p>

<p>where <i>y_{1i}</i> and <i>y_{2i}</i> are the observed counts for use and availability for the <em>i</em>th resource.  The estimator for <i>&theta;_i</i> is:
</p>
<p style="text-align: center;"><i>\hat{&theta;}_{i}=\frac{\hat{&pi;}_{1i}}{\hat{&pi; }_{2i}}.</i></p>


<table summary="Rd table">
<tr>
 <td style="text-align: left;">
Method </td><td style="text-align: left;"> Algorithm </td>
</tr>
<tr>
 <td style="text-align: left;">
</td><td style="text-align: left;"> </td>
</tr>
<tr>
 <td style="text-align: left;"> 


Katz-log </td><td style="text-align: left;"> <i>\hat&theta;_i\times</i> exp<i>(\pm z_1-&alpha;/2\hat{&sigma;}_W)</i>, </td>
</tr>
<tr>
 <td style="text-align: left;">
</td><td style="text-align: left;"> where <i>\hat&sigma;_W^2=\frac{(1-\hat{&pi;} _{1i})}{\hat{&pi;}_{1i}n_1}+\frac{(1-\hat{&pi;}_{2i})}{\hat{&pi;}_{2i}n_2}</i>.  </td>
</tr>
<tr>
 <td style="text-align: left;"> 
</td><td style="text-align: left;"> </td>
</tr>
<tr>
 <td style="text-align: left;">


Adjusted-log </td><td style="text-align: left;"> <i>\hat{&theta;}_{Ai}\times</i> exp<i>(\pm z_1-&alpha; /2\hat{&sigma;}_A)</i>, </td>
</tr>
<tr>
 <td style="text-align: left;"> 
</td><td style="text-align: left;"> where <i>\hat{&theta;}_{Ai}=\frac{y_{1i}+0.5/n_1+0.5}{y_{2i}+0.5/n_2+0.5}</i>, </td>
</tr>
<tr>
 <td style="text-align: left;"> 
</td><td style="text-align: left;"> <i>\hat{&sigma;}_A^2=\frac{1}{y_1+0.5}-\frac{1}{n_1+0.5}+\frac{1}{y_2+0.5}-\frac{1}{n_2+0.5}</i>. </td>
</tr>
<tr>
 <td style="text-align: left;">
</td><td style="text-align: left;"> </td>
</tr>
<tr>
 <td style="text-align: left;">


Bailey </td><td style="text-align: left;"> <i>\hat{&theta;} _i&le;ft[\frac{1\pm z_1-&le;ft( &alpha; /2 \right)&le;ft( \hat{&pi;}_{1i}'/y_{1i}+\hat{&pi;}_{2i}'/y_{2i}-z_1-&le;ft(&alpha;/2 \right)^2\hat{&pi;} _{1i}'\hat{&pi;}_{2i}'/9y_{1i}y_{2i} \right)^{1/2}/3}{1-z_{1-&le;ft(&alpha;/2 \right)^2}\hat{&pi;} _{2i}'/9y_{2i}} \right]^3</i>,</td>
</tr>
<tr>
 <td style="text-align: left;"> 
</td><td style="text-align: left;"> where <i>\hat{&pi;_{1i}}'</i> = 1 - <i>\hat{&pi;}_{1i}</i>, and <i>\hat{&pi;}_{2i}'</i> = 1 - <i>\hat{&pi;}_{2i}</i>.</td>
</tr>
<tr>
 <td style="text-align: left;">
</td><td style="text-align: left;"> </td>
</tr>
<tr>
 <td style="text-align: left;">


Inv. hyperbolic sine </td><td style="text-align: left;"> <i>\ln({{\hat{&theta; }}_{i}})\pm &le;ft[ 2sin{{h}^{-1}}&le;ft( \frac{{{z}_{(1-&alpha; /2)}}}{2}&radic;{\frac{1}{{{y}_{1i}}}-\frac{1}{{{n}_{1}}}+\frac{1}{{{y}_{2i}}}-\frac{1}{{{n}_{2}}}} \right) \right]</i>, </td>
</tr>
<tr>
 <td style="text-align: left;">
</td><td style="text-align: left;"></td>
</tr>
<tr>
 <td style="text-align: left;"> 


Koopman </td><td style="text-align: left;"> Find <i>X^2(&theta;_0)</i> = <i>&chi; _1^2(1 - &alpha;)</i>, where </td>
</tr>
<tr>
 <td style="text-align: left;">
</td><td style="text-align: left;">  <i>{{\tilde{&pi; }}_{1i}}=\frac{{{&theta; }_{0}}({{n}_{1}}+{{y}_{2i}})+{{y}_{1i}}+{{n}_{2}}-{{[{{\{{{&theta; }_{0}}({{n}_{1}}+{{y}_{2i}})+{{y}_{1i}}+
{{n}_{2}}\}}^{2}}-4{{&theta; }_{0}}({{n}_{1}}+{{n}_{2}})({{y}_{1i}}+{{y}_{2i}})]}^{0.5}}}{2({{n}_{1}}+{{n}_{2}})}</i>, </td>
</tr>
<tr>
 <td style="text-align: left;">
</td><td style="text-align: left;"> <i>{{\tilde{&pi; }}_{2i}}=\frac{{{{\tilde{&pi; }}}_{1i}}}{{{&theta; }_{0}}}$, and ${{X}^{2}}({{&theta;}_{0}})=\frac{{{&le;ft( {{y}_{1i}}-{{n}_{1}}{{{\tilde{&pi; }}}_{1i}} \right)}^{2}}}
{{{n}_{1}}{{{\tilde{&pi; }}}_{1i}}(1-{{{\tilde{&pi; }}}_{1i}})}&le;ft\{ 1+\frac{{{n}_{1}}({{&theta;}_{0}}-{{{\tilde{&pi; }}}_{1i}})}{{{n}_{2}}(1-{\tilde{&pi;}_{1i}})} \right\}</i>. </td>
</tr>
<tr>
 <td style="text-align: left;"> 
</td><td style="text-align: left;"> </td>
</tr>
<tr>
 <td style="text-align: left;">

Noether </td><td style="text-align: left;"> <i>\hat{&theta;}_i\pm z_1-&alpha;/2\hat{&sigma;}_N</i>,   </td>
</tr>
<tr>
 <td style="text-align: left;">
</td><td style="text-align: left;"> where <i>\hat{&sigma; }_{N}^{2}=\hat{&theta; }_{i}^{2}&le;ft( \frac{1}{{{y}_{1i}}}-\frac{1}{{{n}_{1}}}+\frac{1}{{{y}_{2i}}}-\frac{1}{{{n}_{2}}} \right)</i>.  
</td>
</tr>

</table>

<p>Exception handling strategies are generally necessary in the cases <i>y_1</i> = 0, <i>n_1</i> = <i>y_1</i>, <i>y_2</i> = 0, and <i>n_2</i> = <i>y_2</i> (see Aho and Bowyer, in review).  
</p>
<p>The bootstrap method currently employs percentile confidence intervals.
</p>


<h3>Value</h3>

<p>Returns a list of <code>class = "ci"</code>.  Default output is a matrix with the point and interval estimate. 
</p>


<h3>Author(s)</h3>

<p>Ken Aho &lt;kenaho1@gmail.com&gt;
</p>


<h3>References</h3>

<p>Agresti, A., Min, Y. (2001) On small-sample confidence intervals for parameters in discrete distributions.  <em>Biometrics</em> 57: 963-97.
</p>
<p>Aho, K., and Bowyer, T. (In review) Confidence intervals for ratios of multinomial proportions: implications for selection ratios. <em>Methods in Ecology and Evolution</em>.
</p>
<p>Bailey, B.J.R. (1987) Confidence limits to the risk ratio.  <em>Biometrics</em> 43(1): 201-205.
</p>
<p>Katz, D., Baptista, J., Azen, S. P., and Pike, M. C. (1978) Obtaining confidence intervals for the risk ratio in cohort studies. <em>Biometrics</em> 34: 469-474
</p>
<p>Koopman, P. A. R. (1984) Confidence intervals for the ratio of two binomial proportions. <em>Biometrics</em> 40:513-517.
</p>
<p>Manly, B. F., McDonald, L. L., Thomas, D. L., McDonald, T. L. and Erickson, W.P. (2002)  <em>Resource Selection by Animals: Statistical Design and Analysis for Field Studies.  2nd  edn.</em>  Kluwer, New York, NY
</p>
<p>Newcombe, R. G. (2001)  Logit confidence intervals and the inverse sinh transformation.  <em>The American Statistician</em> 55: 200-202.
</p>
<p>Pettigrew H. M., Gart, J. J., Thomas, D. G. (1986)  The bias and higher cumulants of the logarithm of a
binomial variate.  <em>Biometrika</em> 73(2): 425-435.
</p>
<p>Walter, S. D. (1975) The distribution of Levins measure of attributable risk. <em>Biometrika</em> 62(2): 371-374.
</p>


<h3>See Also</h3>

<p><code><a href="BinomCI.html">BinomCI</a>, <a href="BinomDiffCI.html">BinomDiffCI</a></code>
</p>


<h3>Examples</h3>

<pre>
# From Koopman (1984)
BinomRatioCI(x1 = 36, n1 = 40, x2 = 16, n2 = 80, method = "katz")
BinomRatioCI(x1 = 36, n1 = 40, x2 = 16, n2 = 80, method = "koop")
</pre>

<hr /><div style="text-align: center;">[Package <em>DescTools</em> version 0.99.32 <a href="00Index.html">Index</a>]</div>
</body></html>
