Created
December 2, 2019 19:48
-
-
Save cbgoodman/e0f399f3e8d691a9907285a406d050ec to your computer and use it in GitHub Desktop.
Example standardized coefplot (by hand)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| library(tidyverse) | |
| library(readxl) | |
| plot.data <- read_excel("popgrow-coeff.xlsx", sheet = "popgrow", col_types = c("guess", "numeric", "numeric", "numeric", "guess")) | |
| multiplier <- qnorm(1 - 0.05 / 2) | |
| plot.data <- plot.data %>% | |
| mutate(std.est = estimate * sd, | |
| std.se = se * sd, | |
| ymin = std.est - (multiplier * std.se), | |
| ymax = std.est + (multiplier * std.se), | |
| term = factor(term, levels = rev(c("Central city population share", | |
| "Suburban municipal fragmentation", | |
| "Suburban unincorporated population", | |
| "School district decentralization", | |
| "Special district overlap", | |
| "ln population", | |
| "Real per capita money income", | |
| "Growth in log population, 1950-1960", | |
| "Unemployment rate", | |
| "Manufacturing share", | |
| "% population with 16+ year education")), ordered = TRUE), | |
| group = factor(group, levels = c("1960 to 1970", | |
| "1960 to 1980", | |
| "1960 to 1990", | |
| "1960 to 2000"), ordered = TRUE)) | |
| p <- ggplot(plot.data, aes(x = term, y = std.est)) + | |
| geom_hline(yintercept = 0, colour = "#000000", size = 0.75) + # Line at 0 | |
| geom_pointrange(aes(ymin = ymin, ymax = ymax, group = rev(group), color = group), position = position_dodge(width = 0.75), size = 1, fatten = 1.25, | |
| show.legend = T) + # Ranges for each coefficient | |
| labs(x="Coefficient", y="Standardized Estimate", title="Population Growth") + # Labels | |
| coord_flip() + # Rotate the plot | |
| theme_bw() + | |
| theme(legend.position="bottom", | |
| legend.title = element_blank()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi Chris,
I would like to reproduce your example but I cannot find the popgrow-coeff.xlsx excel file. Is there a chance you would upload it?
Cheers!
Eduardo.