Specifically, the dependent variable is TI98, the perceived corruption score calculated by Transparency International for 1998. The variable whose effect we seek is an indicator that equals 1 if the country is a former British colony or the UK, and 0 otherwise. I took the coefficients and associated standard errors on British colonial status from Tables 2 and 3 across the 5 different specifications where TI98 is the dependent variable. I then entered them into a data frame with the following structure:
Note that I calculated the upper bound (ub) and lower bound (lb) of the 95% confidence interval using the standard errors provided in the table (I assumed normality holds due to the Central Limit Theorem, which may be questionable in some specifications given small sample sizes).
I then generated the following plot:
Here is the code for making this plot in ggplot2 from the dataframe I provided above:
geom_errorbar() function plots the confidence intervals. Note that I use the
position_dodge() function to horizontally shift the coefficients and confidence intervals for the same specifications for clarity. The
height=NULL option can be omitted. The color and shape for the legend is controlled manually.
What would happen if I just set
name="Method" for the
scale_color_manual command, but left out the
scale_shape_manual command, letting it be automatically determined:
This would be the plot:
This happens because I also set the shape of the points to be determined by the method variable, just as for color. I thus I need to manually give the same name to both scales, or else otherwise they are automatically broken up into two legends, one manual titled “Method” and one automatic title “method”.
What if I wanted to reorder the ordering of the methods in the plot; that is, if we wanted WLS to be plotted first, then OLS?
This can be achieved with the following command before running the first block of code on this page.
The result is the following:
Finally, suppose that we wanted to customize the x-axis labels by tilting them diagonally and changing them to a dark grey. Adding the following extra piece of code to the blocks of code above would accomplish that: