Skip to content

Instantly share code, notes, and snippets.

Avatar

Guillaume Basse gwb

View GitHub Profile
@gwb
gwb / stack_plots-v1.R
Created Aug 3, 2012
A low-level way to organize plots in a grid
View stack_plots-v1.R
"""
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){
@gwb
gwb / cc_neymanian-basic-example.R
Created Mar 12, 2021
Code example for post `Randomization-based inference: the Neymanian approach'
View cc_neymanian-basic-example.R
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])