Skip to content

Instantly share code, notes, and snippets.

View michaelstepner's full-sized avatar

Michael Stepner michaelstepner

View GitHub Profile
@michaelstepner
michaelstepner / LICENSE
Last active June 20, 2023 20:19
Split a PDF at a specific bookmark; preserve bookmarks in each output PDF (using pdftk)
Zero-Clause BSD
===============
Permission to use, copy, modify, and/or distribute this software for
any purpose with or without fee is hereby granted.
THE SOFTWARE IS PROVIDED “AS IS” AND THE AUTHOR DISCLAIMS ALL
WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE
FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY
@michaelstepner
michaelstepner / vam_datasim.ado
Created October 25, 2019 20:32
Value-Added Model: data simulation
*! version 1.0 27jul2013 Michael Stepner, stepner@mit.edu
program define vam_datasim
version 11
syntax , var_mu(real) var_w(real) delta(real) var_lambda(real) var_ind(real) num_teachers(integer) max_T(integer) max_C(integer) max_I(integer) ///
[teacher(name) year(name) class(name) score(name) ///
randomize_num_classes randomize_class_sizes randomize_class_years ///
debug]
@michaelstepner
michaelstepner / supremes_survival.do
Created July 19, 2018 19:15
Expected survival probabilities of Supreme Court Justices, accounting for age, sex and income
* Load Health Inequality Project data
use "https://healthinequality.org/dl/health_ineq_online_table_16.dta", clear
* Combine all information from 2001-2014
isid gnd indv_pctile age age_at_d yod
collapse (mean) mortrate indv_inc [w=count], by(gnd indv_pctile age_at_d)
* Use income percentiles that approximate associate justice salary (~$213,900)
* https://en.wikipedia.org/wiki/Federal_judge_salaries_in_the_United_States
@michaelstepner
michaelstepner / American Upward Mobility - by Race x Gender.do
Created March 23, 2018 12:50
Upward Mobility in the United States by Race x Gender
*! 23mar2018 Michael Stepner
* Code released to public domain under CC0 license: https://creativecommons.org/publicdomain/zero/1.0/
* Use it and adapt it as you like.
/*** Plot intergenerational mobility by Race x Gender for multiple races
***/
* Load quintile transition matrices from Chetty, Hendren, Jones, and Porter (2018). http://www.equality-of-opportunity.org/data/
use "http://www.equality-of-opportunity.org/data/race/table_2.dta", clear
@michaelstepner
michaelstepner / stata.toc
Last active September 22, 2023 08:52
A Stata program to output a number or string to YAML
v 0.0.2
d Michael Stepner, stepner@mit.edu
p 'yamlout': export key, value, and comment to a YAML file
@michaelstepner
michaelstepner / test_domainerror.R
Last active February 28, 2016 19:40
Julia GLM: Domain Error
dfpass = read.table("test_domainerror_pass.csv", header=TRUE, sep=",")
dffail = read.table("test_domainerror_fail.csv", header=TRUE, sep=",")
glm(mortrate ~ age_at_d, dfpass, family=binomial(link = "log"), weights=dfpass[, "count"])
glm(mortrate ~ age_at_d, dffail, family=binomial(link = "log"), weights=dffail[, "count"], start=c(-10,0.1))
glm(mortrate ~ age_at_d, dffail, family=binomial(link = "log"), weights=dffail[, "count"])