Skip to content

Instantly share code, notes, and snippets.

@grayclhn
grayclhn / wuzzit_solver.ipynb
Last active December 29, 2015 09:13
Solver for wuzzit trouble (http://wuzzittrouble.com)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@grayclhn
grayclhn / RDROBUST-description
Last active December 28, 2015 17:32
Temporary mirror of the R code from CCT's rdrobust package (for linking and commenting purposes). The full version of this package is available at https://sites.google.com/site/rdpackages/rdrobust
Package: rdrobust
Type: Package
Title: Robust Data-Driven Statistical Inference in
Regression-Discontinuity Designs
Version: 0.80
Date: 2015-03-18
Author: Sebastian Calonico <[email protected]>, Matias D. Cattaneo <[email protected]>, Rocio Titiunik <[email protected]>
Maintainer: Sebastian Calonico <[email protected]>
Description: Regression-discontinuity (RD) designs are quasi-experimental research designs popular in social, behavioral and natural sciences. The RD design is usually employed to study the (local) causal effect of a treatment, intervention or policy. This package provides tools for data-driven graphical and analytical statistical inference in RD designs: rdrobust to construct local-polynomial point estimators and robust confidence intervals for average treatment effects at the cutoff in Sharp, Fuzzy and Kink RD settings, rdbwselect to perform bandwidth selection for the different procedures implemented, and rdplot to conduct exploratory data analysis (RD plots).
Depends:
@grayclhn
grayclhn / loop_ts.jl
Last active October 5, 2015 21:54
Simple loop-construction macro for Julia
using Base.Meta
macro loop_ts(ex)
l, r = ex.args
# Determine which symbol should become the loop index. We've assumed that
# the equation has the form `y[t+1] = ...` or `y[t] = ...`. In the first case
# we need to parse 't+1' to find the symbol (t); in the second case, we can
# just read it off.
idx =
@grayclhn
grayclhn / macros.jl
Last active July 14, 2021 07:16
Utility macros and functions for Julia
## Some useful and/or interesting Julia macros. I haven't seen many
## examples online, so I hope this might be useful for people trying
## to understand macros. Caveat Emptor; I don't understand them that
## well myself. Additions and improvements are more than welcome.
##
## Everything here is available under the MIT license (see bottom of
## file)
##
## - Gray Calhoun (@grayclhn) 10/17/2014
@grayclhn
grayclhn / julia_macros_code.jl
Last active August 29, 2015 14:07
Code for Julia Macros post
# Copyright (c) 2014 Gray Calhoun.
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
# distribute, sublicense, and/or sell copies of the Software, and to
# permit persons to whom the Software is furnished to do so, subject to
# the following conditions:
#
@grayclhn
grayclhn / idempotence_test.R
Last active December 18, 2015 03:19
Code for LU vs. QR decomposition in regression. Idempotence of projection matrices using the LU decomposition fails faster.
# Explicitly calculate the inverse by LU decomposition: LAPACK DGESV,
# then calculate the projection matrix X(X'X)^(-1)X'
projection.LU1 <- function(x)
x %*% solve(crossprod(x)) %*% t(x)
# Use DGESV but without explicitly calculating the inverse
projection.LU2 <- function(x)
crossprod(t(x), solve(crossprod(x), t(x)))
# Calculate the projection matrix using the QR decomposition
@grayclhn
grayclhn / reinhart_rogoff_data.txt
Last active December 16, 2015 14:09
Supporting code for blog post on Reinhart Rogoff debate, <http://gray.clhn.co/blog/2013/04/24/reinhart-rogoff-thoughts>. The data and almost all of the code are from Herndon, Ash, and Pollin's "Does High Public Debt Consistently Stifle Economic Growth? A Critique of Reinhart and Rogoff", available at http://www.peri.umass.edu/236/hash/31e2ff374b…
Country|Year|Debt|RGDP|GDP|GDPI|GDP1|GDP2|RGDP1|RGDP2|GDPI1|GDPI2|Infl|Debt1|Debt2|dRGDP|Debtalt|GDP2alt|GDPalt|RGDP2alt|debtgdp|GDP3|GNI
Australia|1800|||||0.608||||||||||||||||
Australia|1801|||||0.72||||||||||||||||
Australia|1802|||||0.716||||||||||||||||
Australia|1803|||||0.768||||||||||||||||
Australia|1804|||||0.884||||||||||||||||
Australia|1805|||||0.952||||||||||||||||
Australia|1806|||||1.044||||||||||||||||
Australia|1807|||||1.112||||||||||||||||
Australia|1808|||||1.096||||||||||||||||
@grayclhn
grayclhn / basketball_2013_overview.md
Last active December 15, 2015 04:09
csv files with game-by-game outcomes for the college basketball season (men's, 2013). A csv bracket too. Let me know when you find errors. Enjoy.

college_basketball_2013.csv has game outcomes for the 2012-2013 men's college basketball season.

  • Date: the date the game was played

  • HomeId: a unique numeric identifier for the home team

  • AwayId: a unique numeric identifier for the away team

  • HomeName: the name of the home team

  • AwayName: the name of the away team

  • HomeConf: the conference the home team belongs to

  • AwayConf: the conference the away team belongs to