Calculate approximate confidence intervals for ratios of proportions (risk ratios) of two samples. Three functions are available for intervals assuming the beta binomial distribution, based on a generalized assumption of overdispersion estimated from the residuals, and based on the quasibinomial assumption using a generalized linear model.

1 2 3 4 5 6 7 | ```
Betabin.ratio(x, y, conf.level=0.95, alternative="two.sided",
CImethod=c("FBB", "LBB"), iccpool=FALSE, resbin=FALSE)
ODbin.ratio(x, y, conf.level=0.95, alternative="two.sided",
CImethod=c("FOD", "LOD"), varmethod=c("res", "san"), resbin=FALSE)
Quasibin.ratio(x, y, conf.level = 0.95, alternative = "two.sided", grid = NULL)
``` |

`x` |
a matrix or data.frame of the first sample, with two columns giving the counts of successes and failures in the two columns; each row should correspond to one experimental or observational unit; first column will be treated as 'success' |

`y` |
a matrix or data.frame of the second sample, with two columns giving the counts of successes and failures in the two columns; each row should correspond to one experimental or observational unit; first column will be treated as 'success' |

`conf.level` |
a single numeric value between 0 and 1, the confidence level |

`alternative` |
a character string, |

`CImethod` |
a character string, chossing between available methods for interval computation: in |

`iccpool` |
logical, if |

`resbin` |
logical: if |

`varmethod` |
a character string specifying te type of variance estimation in |

`grid` |
optional, a numeric vector to be supplied to the profiling used internally in |

The methods in `betabin.ratio`

are described by Lui et al., (2000), where different estimates for ICC (and thus overdispersion) are computed for each sample.
For small sample size or extreme proportions, one may restrict the variance to that of the binomial distribution and/or use a pooled estimator of ICC for a joint model of overdispersion in the two samples.

The methods in `ODbin.ratio`

are described by Zaihra and Paul (2010), where different estimates for overdispersion are computed for each sample. Zaihra and Paul refer to two different methods of estimating the variance (MR, MS), here referred to as "res", "san", respectively. As above one may restrict the variance to that of the binomial distribution.

The method to compute intervals under the quasibinomial assumptions in `quasibin.ratio`

uses a quasibinomial generalized linear model to obtain profile deviance intervals (e.g. Bates and Watts, 1988; relying on package mcprofile), and then applies the MOVERR method by Donner and Zhou(2012); experimental!

a list with elements

`conf.int ` |
confidence limits for the ratio of proprotions in x over that in y |

`estimate ` |
the point estimate for the ratio of proprotions in x over that in y |

The method in `quasibin.ratio`

is experimental.

Frank Schaarschmidt

*Lui K-L, Mayer JA, Eckhardt L (2000):* Confidence intervals for the risk ratio under cluster sampling based on the beta-binomial model. Statistics in Medicine 19, 2933-2942.

*Zaihra, T and Paul, S (2010):* Interval Estimation of Some Epidemiological Measures of Association. The International Journal of Biostatistics. 6 (1), Article 35.

*Bates and Watts(1988):* Nonlinear Regression Analysis and Its Applications, Wiley, Ch.6

*Donner and Zou (2012):* Closed-form confidence intervals for functions of the normal mean and standard deviation. Statistical Methods in Medical Research 21(4):347-359.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 | ```
# Toxicologoical data: Number of Pups alive four days after birth (16 litters of rats)
# Original source: Weil, 1970: Selection of valid number[...].
# Food and Cosmetics, Toxicology, 8, 177-182.
# Cited from Zaihra and Paul(2010): Interval Estimation of Some Epidemiological
# Measures of Association. Int. J Biostatistics, 6(1), Article 35.
mchem = c(12, 11, 10, 9, 11, 10, 10, 9, 9, 5, 9, 7, 10, 6, 10, 7)
xchem = c(12, 11, 10, 9, 10, 9, 9, 8, 8, 4, 7, 4, 5, 3, 3, 0)
dchem <- cbind("alive"=xchem, "dead"=mchem-xchem)
mcon = c(13, 12, 9, 9, 8, 8, 13, 12, 10, 10, 9, 13, 5, 7, 10, 10)
xcon = c(13, 12, 9, 9, 8, 8, 12, 11, 9, 9, 8, 11, 4, 5, 7, 7)
dcon <- cbind("alive"=xcon, "dead"=mcon-xcon)
# Zaihra and Paul report: MR2: [0.714; 1.034]
ODbin.ratio(x=dchem, y=dcon, CImethod="LOD", resbin=FALSE)
# Zaihra and Paul report: MR4: [0.710; 1.029]
ODbin.ratio(x=dchem, y=dcon, CImethod="FOD", resbin=FALSE)
Betabin.ratio(x=dchem, y=dcon, CImethod="FBB", iccpool=TRUE, resbin=TRUE)
Quasibin.ratio(x=dchem, y=dcon)
# Solar protection data: intervention and control group (Mayer, 1997:)
# Number of children with adequate level of solar protection
# Source: Mayer, Slymen, Eckhardt et al.(1997): Reducing ultraviolat
# radiation exposure in children. Preventive Medicine 26, 845-861.
# Cited from: Lui et al. (2000)
mint=c(3,2,2,5,4,3,1,2,2,2,1,3,1,3,2,2,6,2,4,2,2,2,2,1,1,1,1,1,1)
xint=c(1,1,1,0,1,2,1,2,2,1,1,2,1,2,2,0,0,0,0,1,2,1,1,1,1,0,0,0,0)
dint <- cbind("adequate"=xint, "non-adequate"=mint-xint)
mcont=c(2,4,3,2,3,4,4,2,2,3,2,2,4,3,2,3,1,1,2,2,2,3,3,4,1,1,1,1,1)
xcont=c(0,0,2,2,0,4,2,1,1,3,2,1,1,3,2,3,1,0,1,2,1,1,2,4,1,1,1,0,0)
dcont <- cbind("adequate"=xcont, "non-adequate"=mcont-xcont)
# Lui et al.(2000) report for the Fieller-Bailey method
# with pooled ICC: 905% CI = [0.964; 2.281]
Betabin.ratio(x=dcont, y=dint, conf.level=0.95, alternative="two.sided",
CImethod="FBB", iccpool=TRUE, resbin=FALSE)
# and for the Log-scale delta method with pooled ICC:
# 95% CI = [0.954; 2.248]
Betabin.ratio(x=dcont, y=dint, conf.level=0.95, alternative="two.sided",
CImethod="LBB", iccpool=TRUE, resbin=FALSE)
ODbin.ratio(x=dcont, y=dint, conf.level=0.95, alternative="two.sided",
CImethod="FOD", resbin=TRUE)
Quasibin.ratio(x=dcont, y=dint, conf.level = 0.95, alternative = "two.sided")
``` |

Questions? Problems? Suggestions? Tweet to @rdrrHQ or email at ian@mutexlabs.com.

Please suggest features or report bugs with the GitHub issue tracker.

All documentation is copyright its authors; we didn't write any of that.