## ----setup, include = FALSE---------------------------------------------------
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  eval = requireNamespace("MatchIt", quietly = TRUE) &&
    requireNamespace("psAve", quietly = TRUE) &&
    requireNamespace("rpart", quietly = TRUE)
)

## ----eval = FALSE-------------------------------------------------------------
# fit <- oal(treat ~ x1 + x2 + ..., data = dat, outcome = ~ y, estimand = "ATT")
# ma  <- psAve::psave(treat ~ x1 + x2 + ..., data = dat, outcome = ~ y,
#                     ps.append = cbind(oal = fit$ps))

## ----message = FALSE----------------------------------------------------------
library(oalasso)
data("lalonde", package = "MatchIt")

fit <- oal(treat ~ age + educ + race + married + nodegree + re74 + re75,
           data = lalonde, outcome = ~ re78, estimand = "ATT")
fit$lambda            # the selected (delta, gamma) tuning point

## -----------------------------------------------------------------------------
set.seed(1234)
ma <- psAve::psave(treat ~ age + educ + race + married + nodegree + re74 + re75,
                   data = lalonde, outcome = ~ re78,
                   ps.methods   = c("glm", "rpart"),
                   prog.methods = c("glm", "rpart"),
                   ps.append    = cbind(oal = fit$ps))
ma

