

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!


To better understand the connections between the log-odds of an outcome, the odds of an outcome, and the probability of an outcome, it is helpful to work with a range of values on one scale and convert it to the others. It’s also helpful to visualize the relationships with some plots. Recall that if the probability of an event is 0.2, that
ln
or ln (0_._ 25) = − 1_._ 3863
odds 1 + odds
exp ( ln ( odds )) 1 + exp ( ln ( odds ))
exp (− 1_._ 3683) 1 + exp (− 1_._ 3683)
In R, you can
Probability values range from 0 to 1. It turns out that for (^) 1+ expexp ( x () x ) , values of x ranging from -5 to +5 create probabilities that range from just above 0 to very close to 1. Values of x ranging from -1 to +1 create probabilities that range from about 0.25 to 0.75. The material below will let you explore the relationships for yourself.
library (ggplot2) log_odds = seq (from = -5, to = 5, by = 0.25) odds = exp (log_odds) # use 'plogis' function to calculate exp(x)/(1 + exp(x)) p = plogis (log_odds) # use odds/(1+odds) to calculate p a different way p2 = odds/(1 + odds) # store probability of failure (1-p) q = 1 - p # store log_odds and y in data frame for use with ggplot
d = data.frame (log_odds, odds, p, p2, q) head (d, 4)
d[19:23, ]
tail (d, 4)
Below, we plot the relationship, so you can see the pattern among the values for log-odds and associated probabilities. You might wonder what happens if you get log-odds values that are very very small (e.g., -24, -147, or -2421) or very big (e.g.,14, 250, or 1250). You should use the plogis function on such values (no commas in your numbers, e.g., plogis(-2421)) to find out for yourself. ggplot (d, aes (x = log_odds, y = odds)) + geom_line () + scale_x_continuous (breaks = seq (-5, 5, by = 1)) + labs (title = "odds versus log-odds")
0
50
100
150
−5 −4 −3 −2 −1 0 1 2 3 4 5
odds versus log−odds
ggplot (d, aes (x = odds, y = p)) + geom_line () +