Skip to content

Instantly share code, notes, and snippets.

View jlsutherland's full-sized avatar

Dr. Joe Sutherland jlsutherland

View GitHub Profile
@jlsutherland
jlsutherland / gronke_levendusky_rep.R
Last active December 6, 2018 01:23
Replicate Levendusky (2009) Fig 3.7, add ANES 2016
library(tidyverse)
library(survey)
library(scales)
anes16 <- readstata13::read.dta13("~/Downloads/anes_timeseries_2016.dta")
anescdf <- readstata13::read.dta13("~/Downloads/anes_timeseries_cdf.dta") %>%
filter(VCF0004 %in% c(1984, 2004))
preference_vars <- c(
@jlsutherland
jlsutherland / loess_fill_forward.R
Created July 27, 2016 15:03
Performs daily pooling, fill forward, and loess on bank data. Can set bandwidth with variable `days`.
vector.is.empty <- function (x) return(length(x) == 0 )
smoothFillForward <- function (bank, days) {
## Assumes there is a csv of raw scores in the working directory for the bank.
## Assumes that the name of that csv is ${BANK}_scores.csv.
## Assumes that the csv has a score, a date, and a residual column.
## Get data from CSV.
all_scores <- read.csv(sprintf('%s_scores.csv', bank))
all_scores$date <- as.Date(all_scores$date, format="%Y-%m-%d")

Keybase proof

I hereby claim:

  • I am jlsutherland on github.
  • I am jlsutherland (https://keybase.io/jlsutherland) on keybase.
  • I have a public key whose fingerprint is B8C0 A714 05CF C23A 521E 0D2B 4DA4 6A8F 5B13 DB7E

To claim this, I am signing this object: