# NOT RUN {
###################################################
## Example 1: Treatment-Covariate Interaction
###################################################
data(LaLonde)
## The model includes a treatment variable,
## nine covariates to be interacted with the treatment variable,
## and the same nine covariates to be adjusted.
# }
# NOT RUN {
## Run to find the LASSO parameters
F1 <-FindIt(model.treat= outcome ~ treat,
model.main= ~ age+educ+black+hisp+white+
marr+nodegr+log.re75+u75,
model.int= ~ age+educ+black+hisp+white+
marr+nodegr+log.re75+u75,
data = LaLonde,
type="binary",
treat.type="single")
# }
# NOT RUN {
## Fit with uncovered lambda parameters.
F1 <-FindIt(model.treat= outcome ~ treat,
model.main= ~ age+educ+black+hisp+white+
marr+nodegr+log.re75+u75,
model.int= ~ age+educ+black+hisp+white+
marr+nodegr+log.re75+u75,
data = LaLonde,
type="binary",
treat.type="single",
search.lambdas=FALSE,
lambdas = c(-3.8760,-4.0025) )
summary(F1)
## Returns all the estimated treatment effects.
pred1 <- predict(F1)
## Top10
head(pred1$data, n=10)
## Bottom 10
tail(pred1$data ,n=10)
## Visualize all the estimated treatment effects.
# }
# NOT RUN {
plot(pred1)
# }
# NOT RUN {
###################################################
## Example 2: Treatment-Treatment Interaction
###################################################
# }
# NOT RUN {
data(GerberGreen)
## The model includes four factorial treatments and
## all two, three, four-way interactions between them.
## Four pre-treatment covariates are adjusted.
## Run to search for lambdas.
F2<- FindIt(model.treat= voted98 ~ persngrp+phnscrpt+mailings+appeal,
nway=4,
model.main= ~ age+majorpty+vote96.1+vote96.0,
data = GerberGreen,
type="binary",
treat.type="multiple")
## Fit, given selected lambdas.
F2<- FindIt(model.treat= voted98 ~ persngrp+phnscrpt+mailings+appeal,
nway=4,
model.main= ~ age+majorpty+vote96.1+vote96.0,
data = GerberGreen,
type="binary",
treat.type="multiple",
search.lambdas=FALSE,
lambdas=c(-15.000,-6.237))
## Returns coefficient estimates.
summary(F2)
## Returns predicted values for unique treatment combinations.
pred2 <- predict(F2,unique=TRUE)
## Top 10
head(pred2$data, n=10)
## Bottom 10
tail(pred2$data, n=10)
## Visualize predicted values for each treatment combination.
plot(pred2)
# }
# NOT RUN {
# }
Run the code above in your browser using DataLab