EPI 208: Comparison of proportions and odds

Graphic by ggplot2 package

prop.odds <- data.frame(proportion = seq(0.01, 0.99, 0.01))

prop.odds <- within(prop.odds, {
    p <- proportion
    odds <- p/(1 - p)
})

library(reshape)
prop.odds.melt <- melt(prop.odds, "p")

library(ggplot2)
gg.obj <- ggplot(prop.odds.melt) + geom_point(aes(x = p, y = value, color = variable), 
    pch = 1) + scale_y_continuous(limits = c(0, 10)) + scale_color_discrete(name = "type") + 
    opts(title = "Divergence of proportion and odds")

gg.obj

plot of chunk unnamed-chunk-1

Graphic by base package

matplot(prop.odds, col = 1:2, pch = 1, ylim = c(0, 10))

plot of chunk unnamed-chunk-2