odds.ratio
From HH v2.1-23
by Richard Heiberger
Calculate or plot the odds ratio for a 2x2 table of counts.
Calculate or plot the odds ratio for a 2x2 table of counts. The plot shows the confidence intervals on the probability of row2 for fixed odds ratio and specified probability for row1.
Usage
odds.ratio(x, alpha = 0.05)
plot.odds.ratio(x,
ylab = "prob(col1 | row1)", xlab = "prob(col1 | row2)",
alpha = c(0.05, 0.5),
legend.x=1.05,
oma=c(0,0,0,5), ...)
Arguments
- x
- 2 x 2 table of counts
- alpha
- Significance levels of test.
odds.ratio
requires a single number in the range [0,1].plot.odds.ratio
accepts more than one number on the range [0,1] and draws confidence lines at each value. - xlab, ylab
- x- and y-labels for the plot. Sensible defaults are generated.
- ...
- other arguments, currently ignored.
- legend.x
- x position of left-hand side of legend.
- oma
- outer margin
par()$oma
, needed to make room for legend.
Value
plot.odds.ratio
draws a plot and invisibly returns the same list asodds.ratio
for the first value ofalpha
.odds.ratio
returns the list:p1, p2 proportion of each row total observed in the first column. omega1, omega2 odds for each row, p/(1-p) psihat odds ratio, omega2/omega1 s.ln.psihat standard deviation of ln(psihat)
ci.ln.psihat confidence interval for ln(psihat)
using normal approximationci.psihat confidence interval for psihat
calculated asep(ci.ln.psihat)
prob1 seq(0,1,.05)
, set of p1 values for plotting.odds1 p1/(1-p1)
odds2 odds for the second row needed to retain psihat
with the specifiedodds1
, calculated asodds1*psihat
.ci.odds2 confidence interval for odds2
prob2 odds2 / (odds2+1)
ci.prob2 ci.odds2 / (ci.odds2+1)
References
Heiberger, Richard~M. and Holland, Burt (2004b). Statistical Analysis and Data Display: An Intermediate Course with Examples in S-Plus, R, and SAS. Springer Texts in Statistics. Springer. ISBN 0-387-40270-5.
Examples
glasses <- read.table(hh("datasets/glasses.dat"), header=FALSE)
glasses <- matrix(unlist(glasses),
nrow=2,
dimnames=list(
c("glasses","no.glasses"),
c("delinq","non.del")))
## draw the iso-odds ratio plot with 50\% CI and 95\% CI,
## invisibly return the 95\% CI
plot.odds.ratio(glasses)
Community examples
Looks like there are no examples yet.