Visualization of Reading Level Frequency by Congressional Bill Stage

[This article was first published on Bommarito Consulting, LLC » r, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

  Here’s a fun example of how you might use my data on Congressional bill length and complexity.  Imagine you want to understand the empirical distribution of Flesch-Kincaid reading level for Congressional bills and how this distribution is related to bill stage.  A first step might be to visualize this relationship.

  Based on this visualization, you might infer that engrossed bills tend to have less right-skew and have a lower mean reading level.  The story behind this might be that Senators and Representatives are less likely to accept legislation they do not understand.  To test this, you might run a simple KS test to see if the introduced bill reading levels are greater than engrossed bill reading levels.

> ks.test(introduced, engrossed, alternative="less")

	Two-sample Kolmogorov-Smirnov test

data:  introduced and engrossed
D^- = 0.094, p-value = 0.006299
alternative hypothesis: the CDF of x lies below that of y

Sample source below.

# Clear and load libraries
rm(list=ls())
library(ggplot2)
library(stats)
# Read data
data <- read.csv("bills-all.csv", comment.char='')
# Plot and save.
ggplot(data) +
geom_bar(aes(x=Reading.Level, fill=Stage), alpha=0.75, binwidth=1) +
scale_x_continuous("Reading Level") +
scale_y_continuous("Count") +
opts(title="Reading Level and Bill Stage")
ggsave(file="reading_level_bill_stage_20120415.jpg", width=8, height=6)
# Run KS test.
introduced <- (data$Reading.Level[which(data$Stage %in% c("Introduced-in-House", "Introduced-in-Senate"))])
engrossed <- (data$Reading.Level[which(data$Stage %in% c("Engrossed-in-House", "Engrossed-in-Senate"))])
print(ks.test(introduced, engrossed, alternative="less"))

To leave a comment for the author, please follow the link and comment on their blog: Bommarito Consulting, LLC » r.

R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)