Skip to content

Instantly share code, notes, and snippets.

@medewitt
medewitt / ws_qwi.R
Last active January 3, 2020 21:07
pulling QWI information for Winston Salem
library(tidyverse)
library(tidyqwi)
# see census.gov/population/estimates/metro-city/0312msa.txt
yearz <- 2009:2018
state <- 37
arguments <- data.frame(yearz, state)
@medewitt
medewitt / paper_summary_template.Rmd
Last active November 18, 2019 14:16
paper summary template
---
title: "Paper summary"
date: "`r Sys.Date()`"
bibliography: my_bib.bib
---
# Paper:
## Author:
## Journal:
## Keywords:
@medewitt
medewitt / multi-data-sim
Last active November 15, 2019 11:23
looking at a simulation
library(dplyr)
library(glmnet)
library(furrr)
plan("multisession")
run_simulation <- function(n = 100, num_pred = 50,
rho = 0, true_beta= -.1,
error = 0.01){
library(Synth)
data(synth.data)
synth.data$dummy <- rnorm(168, 0, .00001)
# create matrices from panel data that provide inputs for synth()
dataprep.out<-
dataprep(
foo = synth.data,
predictors = c("dummy"),
@medewitt
medewitt / impeachment.csv
Last active October 22, 2019 14:31
details from some impeachment polling for Mr Trump
date approve n moe pollster
2019-09-29 47 1009 3.5 ssr
2019-05-31 41 1009 3.5 ssr
2019-04-28 37 1009 3.5 ssr
2019-03-17 36 1009 3.5 ssr
2018-12-09 43 1009 3.5 ssr
2018-09-09 47 1009 3.5 ssr
2018-06-17 42 1009 3.5 ssr
2019-09-30 45 2234 2.4 ipsos
2019-09-30 47 1115 3.6 Quinnipiac
@medewitt
medewitt / explore-loss.R
Created September 16, 2019 15:57
Exploring Loss Functions and Integrating Over the Loss
# Parameters
set.seed(42)
n <- 100L
#true model
x <- rnorm(n, 5, 1)
treat <- rep(c(0,1), n/2)
# Coefficient Plot Implemented in ggplot2 From Faraway's Linear Models with R
#'@description Building a Gelman-esque coefplot in ggplot based on the code
#' in Julian Faraway's Linear Models with R
#'@param fit a lm or glm object
#'@param ci the confidence levels to consider
#'@export
ggcoef_plot <- function(fit, ci = 0.95){
stopifnot(class(fit) %in% c("lm", "glm"))
---
title: "Rmarkdown Exercises"
author: "Your Name"
date: "`r Sys.Date()`"
output:
html_document:
toc: true
toc_float: true
number_sections: true
df_print: paged
library(tidyverse)
humphries <- tribble(
~"Year", ~"G", ~"Rec", ~"Yards", ~"Avg", ~"TD",
2011, 14, 15, 130, 8.7, 0,
2012, 13, 41, 280, 6.8, 1,
2013, 12, 41, 483, 11.8, 2,
2014, 13, 30, 204, 6.8, 0) %>%
mutate(player = "Humphries") %>%
select(Year, Rec, Avg, TD, player)
@medewitt
medewitt / medewitt
Last active November 27, 2018 18:56
https://app.powerbi.com/Redirect?action=OpenApp&appId=0ebba6cb-7c99-4e6e-8dbf-a1aae3066680&ctid=3ce4c247-6019-4439-a614-97d7bdab77f3
https://app.powerbi.com/Redirect?action=OpenApp&appId=0ebba6cb-7c99-4e6e-8dbf-a1aae3066680&ctid=3ce4c247-6019-4439-a614-97d7bdab77f3