6.2 Graph: Coefficient plots

  • Here we will work with the ‘famous’ swiss data set (?swiss)
  • Figure 6.1 below provides a simple coefficient plot.
  • Questions:
    • What does the graph show? What are the underlying variables (and data)?
    • How many scales/mappings does it use? Could we reduce them?
    • What do you like, what do you dislike about the figure? What is good, what is bad?
    • What kind of information could we add to the graph (if any)?
    • How would you approach a replication of the graph?
Coefficient plot

Figure 6.1: Coefficient plot

6.2.1 Lab: Data & code

  • Learning objectives
    • How to plot the results of statistical models
    • How to use the broom package and the tidy function
    • How to plot different confidence intervals

We start by preparing the data, i.e., estimating the model and extracting the coefficients of interest. Importantly, the table you see below is all you need as a basis for the ggplot functions.

Variable Coefficient SE statistic p.value conf.low_95 conf.high_95 conf.low_90 conf.high_90
Catholic 0.1452013 0.0301466 4.816504 0.0000184 0.0844049 0.2059978 0.0945227 0.1958800
Agriculture -0.2030377 0.0711516 -2.853591 0.0066235 -0.3465286 -0.0595467 -0.3226486 -0.0834268
Education -1.0721468 0.1558018 -6.881477 0.0000000 -1.3863512 -0.7579425 -1.3340607 -0.8102329

Subsequently, we feed those estimates into the ggplot function.

  • geom_point(), geom_linerange(): Plot estimates and intervals
  • geom_hline(): Plot 0 line
  • coord_flip(): Flip the plot