# NOT RUN {
GenerateData.MAD <- function(n)
{
x1 <- runif(n)
x2 <- runif(n)
tp <- exp(-1+1*(x1+x2))/(1+exp(-1+1*(x1+x2)))
a<-rbinom(n = n, size = 1, prob=tp)
error <- rnorm(length(x1))
y <- (1 + a*0.6*(-1+x1+x2<0) + a*-0.6*(-1+x1+x2>0)) * error
return(data.frame(x1=x1,x2=x2,a=a,y=y))
}
# The true MAD optimal treatment regime for this generative model
# can be deduced trivially, and it is: c( -0.5773503, 0.5773503, 0.5773503).
# }
# NOT RUN {
# With correctly specified propensity model ####
# }
# NOT RUN {
n <- 400
testData <- GenerateData.MAD(n)
fit1 <- IPWE_MADopt(data = testData, regimeClass = a~x1+x2,
moPropen=a~x1+x2, cl.setup=2)
fit1
# }
# NOT RUN {
# With incorrectly specified propensity model ####
# }
# NOT RUN {
fit2 <- IPWE_MADopt(data = testData, regimeClass = a~x1+x2,
moPropen="BinaryRandom", cl.setup=2)
fit2
# }
# NOT RUN {
# }
Run the code above in your browser using DataLab