# Coefficient Plots in R

##### Posted on June 30th, 2012

One popular trend in presenting results is the "coefficient plot," an alternative to the table of regression coefficients. I am seeing this a little more often in political science research and have received a few requests for code, so I thought I'd write a post about it. One function (that I know of) is available in R to do this automatically, but I often want more customization than the function provide. In this post, I walk through my approach to building these coefficient plots and provide carefully commented code that I use to create them.

## Using the coefplot() function in the arm library

One good place to start is to create a quick plot using the coefplot() function in the arm library.

This function is written by Andrew Gelman and his team, but isn't publication quality. The function has several options that allow it to be customized somewhat, but I prefer total control. I like to build these plots up from scratch.

## An initial cut by hand

The first plot basically replicates the coefplot() output, but looks a lot better and offers more detailed descriptions of the variables.

I like this plot a little better than the coefplot() defaults, though I should point out the I could create something very similar to this using the options in the coefplot() function. However, there are a few things I don't like.

## Labelling the points directly

First, I think the graph is a little easier to read if the points are label directly. Rather than trace an imaginary line from left to right to decide what the points refer to, readers can simply read the labels directly from the plot.

This plot is a little better, but the scaling across the variables is much different, making them harder to compare.

## Making the points more comparable

Rather than plot the regression coefficients, I prefer to plot first-differences as explanatory variables move from their observed minimum to the observed maximum. This gives a sense of what variables have the largest substantive impact. This works similar to standardization, but generalizes a little easier to generalized linear models.

I feel pretty comfortable with this plot and it is not hard to create in R.

## Extending to generalized linear models

As a final example, I made a similar plot for a logistic regression.

## Concluding Remarks

There are a couple of things to keep in mind when using coefficient plots. First, each of these plot should probably contain a detailed caption explaining the graphs in detail. Second, while I feel that this style of plot improves upon a table of coefficients, one should consider carefully whether this type of plot is necessary at all.

The R code used to make these plots is available here.