R/DIDpolya.R

#' Fit nonparametric diff-in-diff with Polya tree prior
#' 
#' Given an input of continuous outcomes, binary treatment, and binary time indicators
#' (pre- and post-treatment), this function computes the changes-in-changes estimate
#' from Athey and Imbens (2005) using a nonparametric Bayesian prior.
#' 
#' @author Bret Zeldow \email{zeldow@pm.me}
#' 
#' @param y
#' @param trt
#' @param tp
#' @param n.iters
#' @param n.levels
#' 
#' @importFrom Rcpp evalCpp
#'
DIDpolya <- function(y, trt, tp, n.iters, n.levels) {
  
  ##############################################################
  ## y:        vector of outcomes (continuous for now)
  ## trt:      vector of treatment (must be 0 or 1)
  ## tp:       vector of timepoints (must be 0 or 1)
  ## n.iters:  number of MCMC iterations
  ## n.levels: number of levels for polya tree
  ###############################################################

  # Check inputs are OK ---------------------------------
  

  
  y00 <- y[which(a == 0 & tp == 0)]
  y01 <- y[which(a == 0 & tp == 1)]
  y10 <- y[which(a == 1 & tp == 0)]
  y11 <- y[which(a == 1 & tp == 1)]
  
  n00 <- length(y00); n01 <- length(y01); n10 <- length(y10); n11 <- length(y11)
  
  
  ####### Polya tree boundaries for observed distributions ######
  ## B00: boundaries for a = 0 and tp = 0
  ## B01: boundaries for a = 0 and tp = 1
  ## B10: boundaries for a = 1 and tp = 0
  ## B11: boundaries for a = 1 and tp = 1
  ###############################################################
  
  # step 1: set boundaries
  
  
  # step 2: set priors/posteriors in boundaries
  
  
  
  
  
  
  
}
zeldow/DIDpolya documentation built on May 9, 2019, 7:39 p.m.