Last active
January 12, 2017 06:48
-
-
Save bgweber/633386c85501fbe1f868103e8c011e46 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(boot) | |
data <- read.csv("UserSessions.csv") | |
# Function for computing the difference of differences | |
run_DiD <- function(data, indices){ | |
d <- data[indices,] | |
new <- mean(d$postval[d$group=='Test'])/mean(d$priorval[d$group=='Test']) | |
old <-mean(d$postval[d$expgroup=='Control'])/mean(d$priorval[d$expgroup=='Control']) | |
return((new - old)/old * 100.0) | |
} | |
# perform the bootstrapping and output the results | |
boot_est <- boot(data, run_DiD, R=1000, parallel="multicore", ncpus = 8) | |
quantile(boot_est$t, c(0.025, 0.975)) | |
plot(density(boot_est$t), xlab = "% Increase vs. Control") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment