Skip to content

Instantly share code, notes, and snippets.

@sumtxt
sumtxt / 20211010_IRS_990_P84.R
Created October 10, 2021 17:57
Scatter plot: Foreign-born population vs. IRS 990 P84 organisations ("Ethnic, Immigrant Centers, Services") per 100k capita
setwd("")
library(tidyverse)
library(censusapi)
library(ggrepel)
data(fips_codes)
###############
@sumtxt
sumtxt / ext_game.tex
Created July 14, 2013 12:00
TeX code to draw (1) Extensive form game with two embedded normal form games and (2) Extensive form game with an embedded normal form game using TikZ.
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc}
\usetikzlibrary{matrix}
\usetikzlibrary{positioning}
\usetikzlibrary{arrows}
\usetikzlibrary{decorations.markings}
\begin{document}
@sumtxt
sumtxt / gist:5856688
Created June 25, 2013 07:40
Animated Beta Distribution beta(x,2,0:7) with gnuplot.
Binv(p,q)=exp(lgamma(p+q)-lgamma(p)-lgamma(q))
beta(x,p,q)=p<=0||q<=0?1/0:x<0||x>1?0.0:Binv(p,q)*x**(p-1.0)*(1.0-x)**(q-1.0)
ymax = 3.2
xmin = 0.0
xmax = 1.0
set term gif animate delay 4
set output "betapdf.gif"
@sumtxt
sumtxt / hazChange.R
Last active December 11, 2015 09:38
R function, calculates the "percentage change in hazard rate", see Box-Steffensmeier / Jones (2004, 60). The function not only calculates this quantity, but also uses a simulation approach to derive a distribution for it.
# FN calcualtes Box-Steffensmeier %h(t), (Box-Steffensmeier / Jones, 2004, 60)
#
# %h(t) = ( exp(b*X_1) - exp(b*X_2) ) /exp(b*X_2)
#
# Input:
# - x: a vector of two values for the quantity of interest that changes from the first value to the second value
# - xname: the variable name of the covariate that is the quantity of interest
# - Xfix: a dataframe of all other covariate values that are kept constant
# - model: the coxph model
# Output: