-
Notifications
You must be signed in to change notification settings - Fork 0
/
.Rhistory
98 lines (98 loc) · 3.25 KB
/
.Rhistory
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
setwd("~/OneDrive - National University of Singapore/AY2021 SEM 1/BT4212/HW")
load("~/OneDrive - National University of Singapore/AY2021 SEM 1/BT4212/HW/ExpData.Rda")
load("~/OneDrive - National University of Singapore/AY2021 SEM 1/BT4212/HW/ExpData.Rda")
getwd()
ls()
ls
knitr::opts_chunk$set(echo = TRUE)
options(scipen=999) # suppressing scientific notation
load(file)
set.seed(1)
file = 'ExpData.Rda'
load(file)
set.seed(1)
file = 'ExpData.Rda'
load(file)
set.seed(1)
file = 'ExpData.Rda'
load(file)
readRDS(file)
set.seed(1)
file = 'ExpData.Rda'
readRDS(file)
set.seed(1)
file = 'ExpData.Rda'
df <- readRDS(file)
df
load("/Users/bernard.chua/OneDrive - National University of Singapore/AY2021 SEM 1/BT4212/HW/ExpData.Rda")
df %>% mutate(Yi(1) = observed *Treatment)
df %>% mutate(a = observed *Treatment)
library(dplyr)
df %>% mutate(a = observed *Treatment)
df %>% mutate(one = if(Treatment == 1) Treatment)
df %>% mutate(one = if(Treatment == 1) observed else (observed -2))
library(dplyr)
df %>% mutate(one = (if(Treatment == 1) observed else (observed -2)))
df %>% mutate(one = (if(Treatment == 1) observed else if (Treatment == 0) observed -2))
library(dplyr)
df %>% mutate(one = (if(Treatment == 1) observed else if (Treatment == 0) observed -2))
ifelse
?ifelse
library(dplyr)
df %>% mutate(one = (ifelse(Treatment == 1, observed, observed -2))
library(dplyr)
df %>% mutate(one = (ifelse(Treatment == 1, observed, observed -2))
library(dplyr)
df %>% mutate(one = (ifelse(Treatment == 1, observed, observed -2)))
library(dplyr)
df %>% mutate(one = (ifelse(Treatment == 1, observed, observed -2)))
df %>% mutate(y1 = (ifelse(Treatment == 1, observed, observed -2)))
library(dplyr)
df <- df %>%
mutate(y1 = (ifelse(Treatment == 1, observed, observed - 2))) %>%
mutate(y0 = (ifelse(Treatment == 0, observed, observed - 2)))
library(dplyr)
df <- df %>%
mutate(y1 = (ifelse(Treatment == 1, observed, observed - 2))) %>%
mutate(y0 = (ifelse(Treatment == 0, observed, observed - 2)))
df
library(dplyr)
df <- df %>%
mutate(y1 = (ifelse(Treatment == 1, observed, observed + 2))) %>%
mutate(y0 = (ifelse(Treatment == 0, observed, observed - 2)))
df
library(dplyr)
df <- df %>%
mutate(y_i(1) = (ifelse(Treatment == 1, observed, observed + 2))) %>%
library(dplyr)
df <- df %>%
mutate(y1 = (ifelse(Treatment == 1, observed, observed + 2))) %>%
mutate(y0 = (ifelse(Treatment == 0, observed, observed - 2)))
df
M = 11
TreatIndex = sample(seq(1,M,1),ceiling(M/2), replace = FALSE) # a completely randomized experiment among the sample of M subjects
TreatIndex
ControlIndex = setdiff(seq(1,M,1),TreatIndex)
Treated = SampleData[TreatIndex,]
Treated = df[TreatIndex,]
Treated$Assignment = 1
Treated$Obs = Treated$Y1
Control = SampleData[ControlIndex,]
Control = df[ControlIndex,]
Control$Assignment = 0
Control$Obs = Control$Y0
M = 11
TreatIndex = sample(seq(1,M,1),ceiling(M/2), replace = FALSE) # a completely randomized experiment among the sample of M subjects
ControlIndex = setdiff(seq(1,M,1),TreatIndex)
Treated = df[TreatIndex,]
Treated$Assignment = 1
Treated$Obs = Treated$Y1
Control = df[ControlIndex,]
Control$Assignment = 0
Control$Obs = Control$Y0
Treated
Control
source('~/Documents/GitHub/5_project/main.R', echo=TRUE)
getwd()
setwd("~/Documents/GitHub/5_project")
source('~/Documents/GitHub/5_project/main.R', echo=TRUE)