#####################
### Conference #8 ###
#####################
library("arm")
###########
### 9.4 ###
###########
categoryZ <- 1:8
nbpersZ <- c(300, 300, 500, 500, 200, 200, 200, 200)
xZ <- rep(c(0,1),4)
xZ
TZ <- rep(rep(c(0,1),c(2,2)),2)
T
y0Z <- rep(c(4,10), c(4,4))
y1Z<- rep(c(6,12), c(4,4))
base <- data.frame(category = rep(categoryZ, nbpersZ),
x = rep(xZ, nbpersZ),
T = rep(TZ, nbpersZ),
y0 = rep(y0Z, nbpersZ),
y1 = rep(y1Z, nbpersZ))
str(base)
base$y <- ifelse(base$T == 0, base$y0, base$y1)
base$z <- ifelse(base$y0 == 4, 0, 1)
### a
# ATE = 2
# estimations
fit1 <- lm(y ~ T, data=base)
display(fit1)
mean(base$y[base$T==1]) - mean(base$y[base$T==0])
fit2 <- lm(y ~ T + x, data=base)
display(fit2)
fit3 <- lm(y ~ T + x + T:x, data=base)
display(fit3)
m0 <- mean(base$y[base$T==1 & base$x==0]) - mean(base$y[base$T==0 & base$x==0])
m1 <- mean(base$y[base$T==1 & base$x==1]) - mean(base$y[base$T==0 & base$x==1])
m0
m1
####
fit4 <- lm(y ~ T + z + T:z, data=base)
display(fit4)
Sunday, November 22, 2009
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment