Log Odds Ratio Plot

Navigation:  Resources > R Code samples >

Log Odds Ratio Plot

Previous pageReturn to chapter overviewNext page

This sample creates the graph shown in the Confidence Intervals section, Odds Ratio.

R Code

## load vcd library

library(vcd)

## load Coal Miners data

data("CoalMiners")

## compute log odds ratios

lor <- oddsratio(CoalMiners)

lor

## summary with z tests

summary(lor)

## confidence intervals

confint(lor)

## visualization

plot(lor,xlab = "Age Group",main = "Breathlessness and Wheeze in Coal Miners")

## add quadratic model

g <- seq(25, 60, by = 5)

m <- lm(lor ~ g + I(g^2))

lines(fitted(m), col = "red")