Skip to content

Instantly share code, notes, and snippets.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
qualititative coding package
https://github.com/ropenscilabs/qcoder
Packages
lavaan, blavaan, blavaan.fimlm, lavaan.survey
panelView: Visualizing Panel Data with Dichotomous Treatments
ggstatsplot: 'ggplot2' Based Plots with Statistical Details
ggplotify: Convert Plot to 'grob' or 'ggplot' Object
@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
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)
---
title: "Rmarkdown Exercises"
author: "Your Name"
date: "`r Sys.Date()`"
output:
html_document:
toc: true
toc_float: true
number_sections: true
df_print: paged
# 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"))
@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)
@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
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 / 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){