Open ChristelSwift opened 2 years ago
hi there,
is it possible that there might be an error in the R code in the simulation part? in the generateData function in Box 27, we currently have:
generateData
generateData <- function(n){ w1 <- round(runif(n, min=1, max=5), digits=0) w2 <- rbinom(n, size=1, prob=0.45) w3 <- round(runif(n, min=0, max=1), digits=0 + 0.75*w2 + 0.8*w1) w4 <- round(runif(n, min=0, max=1), digits=0 + 0.75*w2 + 0.2*w1) A <- rbinom(n, size=1, prob= plogis(-1 - 0.15*w4 + 1.5*w2 + 0.75*w3 + 0.25*w1 + 0.8*w2*w4)) # Counterfactuals Y.1 <- rbinom(n, size=1, prob = plogis(-3 + 1 + 0.25*w4 + 0.75*w3 + 0.8*w2*w4 + 0.05*w1)) Y.0 <- rbinom(n, size=1, prob = plogis(-3 + 0 + 0.25*w4 + 0.75*w3 + 0.8*w2*w4 + 0.05*w1)) # Observed outcome Y <- Y.1*A + Y.0*(1 - A) # return data.frame data.frame(w1, w2, w3, w4, A, Y, Y.1, Y.0) }
As w3 and w4 are meant to be categorical variables, shouldn't it be this instead:
w3 <- round(runif(n, min=0, max=1) + 0.75*w2 + 0.8*w1, digits=0) w4 <- round(runif(n, min=0, max=1) + 0.75*w2 + 0.2*w1, digits=0)
Also, still in box 27, what's the reason for choosing family = poisson(link="log") in the ATE naive approach rather than family = binomial(link = "logit") ?
family = poisson(link="log")
family = binomial(link = "logit")
many thanks,
Christel
hi there,
is it possible that there might be an error in the R code in the simulation part? in the
generateData
function in Box 27, we currently have:As w3 and w4 are meant to be categorical variables, shouldn't it be this instead:
Also, still in box 27, what's the reason for choosing
family = poisson(link="log")
in the ATE naive approach rather thanfamily = binomial(link = "logit")
?many thanks,
Christel