Skip to main content

Section B.8 Presenting Your Regression Results

Communicating your results in a clear manner is incredibly important. We have seen the tabular results produced by R. If you want to use them in a paper, you may need to do some tidying up of those results. There are a number of packages (textreg, stargazer) that automatise that process. They take your lm objects and produce tables that you can put straight away in your reports or papers. One popular trend in presenting results is the coefficient plot as an alternative to the table of regression coefficients. There are various ways of producing coefficient plots with R for a variety of models.
We are going to use instead the plot_model() function of the sjPlot package, that makes it easier to produce this sort of plots.
library(sjPlot)
Let’s try with a more complex example:
fit_4 <- lm(HR90 ~ RD90 + SOUTH_f + DV90 + MA90 + PS90, data=ncovr)
plot_model(fit_4, breakLabelsAt = 30)
Figure B.8.1. Regression forest plot for the results of a regression
What you see plotted here is the point estimates (circles), the confidence intervals around those estimates (the longer the line the less precise the estimate), and the colours represent whether the effect is negative (red) or positive (blue). There are other packages that also provide similar functionality, like the dotwhisker package that you may want to explore.
The sjPlot package also allows you to produce html tables for more professional presentation of your regression tables. For this we use the tab_model() function.
tab_model(fit_4)
You can customise this table. For example, you can change the name that is displayed for the dependent variable with the dv.labels = parameter, and you could change the labels for the independent variables with the pred.labels = parameter.
tab_model(fit_4,
          dv.labels = "Homicide rate 1990",
          pred.labels = c("(Intercept)",
                          "Resource deprivation","South",
                          "Percent divorced males", "Median age",
                          "Population structure"))
The tab_model() function is great if you have an html output. In case you’re making your tables for a PDF output, you might want to consider the stargazer package, from which the function stargazer() produces LaTeX code, HTML code and ASCII text for well-formatted tables.
library(stargazer)
stargazer(fit_4, header = FALSE, title = "Model summary table using stargazer package")
You could also use this to show the results of several models side-by-side.
stargazer(fit_3, fit_4, header = FALSE, title = "Example table to display two models in one table")
Besides tables, visual display of the effects of the variables in the model are particularly helpful. The effects package allows us to produce plots to visualise these relationships (when adjusting for the other variables in the model). Here’s an example going back to our model fit_3 which contained SOUTH and RD90 predictor variables:
library(effects)
plot(allEffects(fit_3), ask=FALSE)
Figure B.8.2. Effect plots for a regression
Notice that the line has a confidence interval drawn around it and that the predicted means for southern and northern counties (when controlling for RD90) also have a confidence interval.