# How to visualise coefficients of a Binomial Logistic Regression?

Hello all!

Do you have an idea how best visualise the data from this table knowing they are coefficients of binomial logistic regressions? What I would like to visualise is a confrontation between the predictors likely to influence 'paying intent'

Also what is the difference is between 'beta' and 'exponential(beta)'?

edit: All of the variables are binomial but for the age variable that is continuous.

## 3 Answers

With binary predictors and a binary outcome, there are only 4 cells (conditions, or possibilities) to display: predictor = either 0 or 1 and outcome = either 0 or 1. Thus one can use a very simple format like a table or bar chart to show the connections between the two variables.

With a continuous predictor, the relationship may be more complex. One effective way to display this is through a sunflower plot.

Each circle represents one case, and each sunflower "petal" represents an additional case that has the same Predictor and Outcome values as the rest of the cases in that circle.

With such a chart one can see exactly how many cases have each pair of values; to what extent the relationship departs from a linear one; and where the slope discriminating between "No" and "Yes" outcomes is steepest.

    # See http://stat.ethz.ch/R-manual/R-patched/library/graphics/html/sunflowerplot.html

require(stats); require(grDevices); library(lattice)

x=c(0,0,1,1,1,1,1,2,2,2,2,2,3,5,8,9,13,13,13,13,14,14,16,16,16,16,16,16)
y=c(0,0,0,1,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,0,1,1,1,1,1,1,1,1)
d=data.frame(x,y)

model = glm(y~x, family=binomial) ; fitted=predict(model, type="response")

sunflowerplot(x,y, rotate = F,  cex = 5, cex.fact = 1,  pch = 1,  yaxt = 'n', xlab='', ylab='',
cex.axis=1.4,  col = "maroon",  seg.col = "maroon",  seg.lwd = 3)
title(xlab='Predictor', ylab='Outcome', line=2, cex.lab=1.4)
# line=2 determines axis title's distance from axis
axis(2, at= c(0,1), las = 1, labels=c('No', 'Yes'), cex.axis=1.4, cex.lab=1.4)
lines(x, fitted(model),col= "maroon", lwd = 1.7)

# Alt ways to get fitline
lines (lowess(y~x), lwd=2, col= "red")
lines (scatter.smooth(y~x), lwd=2)

# cex = size of plotted points
# size = petal size; 1/8 may work, or skip
# cex.fact = shrinkage ratio (points shrink compared to petals)
# seg.col = petal color
# seg.lwd = petal line width
# par(las=1) or simply "las=1" within a command will make axis labels horizontal


As for 'beta' and 'exponential(beta)', any general source on logistic regression will explain the difference, but in short: with the latter one raises beta to a power (the coefficient), base e. This yields the odds ratio associated with a case being 1 higher than another on the predictor. For example, when Music is '1' the odds of the outcome being '1' are 1.6 times the odds when Music is '0'.

• Actually my answer deals with visualizing relationships; the other answers, with coefficients, as asked. Commented Apr 25, 2018 at 13:59

As mentioned by @rolando2, the B and exp(B) are the logged odds of the outcome and the odds of the outcome, respectively. So you can take the exp(B) value, subtract 1, and multiply by 100 to get the expected percent change in odds of the outcome for a one unit change in the predictor.

That said, while the logged odds to odds ratio conversion gets us a little bit of the way closer to something the typical person can intuititively understand, my experience (and others, I’ve heard) is that people tend not to understand odds well, either.

My opinion is that you should export predicted probabilities from your model(s), after which you have several options, including the plot from @rolando2, bar charts, box and whisker plots, etc.

• (+1 I like the idea of a boxplot to show the uncertainty around each coefficient. We so often forget the importance of that. Commented Apr 25, 2018 at 13:30

A logistic regression aims to model the probability of success of an event (here, the intent to pay). The associated formula to the model is the following.

$${\rm logit}(p(1 |X)) = \log\!\Bigg(\frac{p(1|X)}{p(0|X)}\Bigg) = \beta_0 + \beta_1 x_1 + \beta_2 x_2 + ... + \beta_j x_j$$

Here, $p(1|X)$ stands for the probability of success (intent to pay), $p(0|X)$ for the probability of failure (not paying), $\beta_i$ the coefficients of your regression and $x_i$ your predictors (whether they are discrete or continuous).

Basically, coefficient $\beta_i$ explains the influence of predictor $x_i$ over the outcome.

• A positive $\beta_i$ implies that the occurrence of the predictor increases the odds ratio (chances of success) for a binary predictor. For a continuous predictor, this implies that the odds ratio increases as the predictor increases.

• A negative $\beta_i$ implies that the occurrence of the predictor reduces the odds ratio for a binary predictor. For a continuous predictor, the odds ratio will decrease as the predictor increases (and vice-versa).

• A null $\beta_i$ implies that the predictor has no effect on the outcome.

The exponential version of these coefficients only changes the scale of the interpretation values.

• $\exp(\beta_i) > 1\;\; \Leftrightarrow\;\; \beta_i > 0$
• $\exp(\beta_i) < 1\;\; \Leftrightarrow\;\; \beta_i < 0$
• $\exp(\beta_i) = 1\;\; \Leftrightarrow\;\; \beta_i = 0$

For visualization purposes, I would simply use a bar plot, and privilege restitution of $\beta_i$ coefficients, especially if you are presenting these results to non-statisticians. Why these coefficients ? Because from personal experience, non-statisticians visualize better the idea of positive / negative impact of a predictor if they see positive / negative values rather than values below / above 1. Most will pay little attention to the numbers.

You can however complete this graph with another bar plot to represent the exponential coefficients. They give you directly the odds ratio, but in my opinion, this should come in second for high-level visualization. People will get the general idea with the first graph, and only those who are willing to dig in the numbers will be interested by the second graph.

• +1 but please explain "privilege". Commented Apr 25, 2018 at 13:26
• @rolando2 I have edited my answer to explain my choice Commented Apr 25, 2018 at 14:03