Skip to content

Instantly share code, notes, and snippets.

@gwb
gwb / cc_neymanian-basic-example.R
Created March 12, 2021 19:21
Code example for post `Randomization-based inference: the Neymanian approach'
library(magrittr)
library(purrr)
library(gtools)
## Estimand function and estimator function
tau.fn <- function(science) mean(science$y1) - mean(science$y0)
hat.tau.fn <- function(w, y) mean(y[w==1]) - mean(y[w==0])
@gwb
gwb / stack_plots-v1.R
Created August 3, 2012 21:35
A low-level way to organize plots in a grid
"""
A better way uses the gridExtra package. This is mostly for future reference, in case gridExtra doesn't
handle a specific case.
"""
# Stacking plots in a grid
stack_plots <- function(gs, nrow, ncol, fout=NULL, add_opts){
# example: stack_plots(list(g1, g2, g3), 2, 2, function (x) opts(legend.position="bottom"))
if(length(fout) > 0){