Last active
December 28, 2018 03:13
-
-
Save koro485/50530c2663f95f614b37282447c320b1 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(tidyverse) | |
set.seed(1) | |
Untreated <- rnorm(20, 20, sd = 5) #Outcome among the treated: 20 observations from N(20,25) | |
Treated <- rnorm(20,15, sd = 5) #Outcome among the untreated: 20 observations from N(15,25) | |
Outcome <- c(Treated, Untreated) | |
trt.num <- c(rep(0,20), rep(1,20)) #A=0 if untreated, A=1 if treated | |
df <- as.data.frame(cbind(as.numeric(Outcome), as.numeric(trt.num))) | |
df.summary <- as.data.frame(cbind(c(mean(Treated), mean(Untreated)), c(1,2))) | |
colnames(df) <- c('Outcome', 'Treatment') | |
q <- ggplot(data=df, mapping = aes(x=as.factor(Treatment), y=Outcome)) + geom_point() + geom_point(data=df.summary, mapping = aes(x=V2, y=V1), col = 'red', size = 4) + labs(x = "介入A") + labs(y = "アウトカムY") | |
mean(Treated) | |
mean(Untreated) | |
lm(Outcome ~ Treatment, data=df) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment