Calculating odds-ratios
In the previous exercise, we saw how to compare the effects of a friend's recommendation on sales. However, regression outputs can be hard to describe and sometimes odds-ratios can be easier to use. Using the outputs from the previous exercise, we're going to calculate odds-ratios.
Refresher on odds-ratios:
- If an odds-ratio is 1.0, then both events have an equal chance of occurring. For example, if the odds-ratio for a friend's recommendation was 1.0, then a friend would have no influence on a purchase decision.
- If an odds-ratio is less than 1, then a friend's recommendation would decrease the chance of a purchase occurring. For example, an odds-ratio of 0.5 would mean a friend's recommendation has odds of 1:2 or 1 purchase occurring for every 2 passes.
- If an odds-ratio is greater than 1, then a friend's recommendation would increase the chance of a purchase occurring. For example, an odds-ratio of 3.0 would mean a friend's recommendation has odds of 3:1 or 3 purchases occurring for every 1 passes.
Note on course code: Since this course launched, the broom package has dropped support for lme4::lmer() models. If you try to repeat this on your own, you will need the broom.mixed package, which is on cran.
Diese Übung ist Teil des Kurses
Hierarchical and Mixed Effects Models in R
Anleitung zur Übung
- Look at the
summary()ofmodel_out. - Extract the coefficients from
model_outwithfixef()and then convert to an odds-ratio by taking exponential. Repeat withconfint()to get the confidence intervals. - Calculate the confidence intervals and then exponentiate the effect of
friendson a purchase usingtidy(). Make sure to set theconf.intandexponentiateparameters.
Interaktive Übung
Vervollständige den Beispielcode, um diese Übung erfolgreich abzuschließen.
# Run the code to see how to calculate odds ratios
summary( ___)
exp(___(model_out))
exp(___(model_out))
# Create the tidied output
tidy(model_out, conf.int = ___, exponentiate = ___)