## ----setup, include = FALSE--------------------------------------------------- knitr::opts_chunk$set( collapse = TRUE, comment = "#>" ) library(AugBalWeight) ## ----lalonde_example---------------------------------------------------------- # Load canonical LaLonde dataset data(lalonde_data) # Specify covariates covariates <- c("age", "educ", "black", "hisp", "married", "re74", "re75", "age2", "educ2", "re742") X <- as.matrix(lalonde_data[, covariates]) Y <- lalonde_data$re78 Z <- lalonde_data$treat # Estimate ATT using Ridge-augmented L2 balancing weights fit_att <- aug_bal_att( Y = Y, Z = Z, X = X, type = "l2", outcome_model = "ridge", tuning_method = "cv_outcome" ) # Print ATT estimate and confidence interval print(fit_att) ## ----summary_example---------------------------------------------------------- summary(fit_att) ## ----plot_example, fig.width = 7, fig.height = 5------------------------------ # Plot covariate balance diagnostic plot(fit_att, which = 1) # Plot distribution of estimated balancing weights plot(fit_att, which = 2) ## ----double_lasso_example----------------------------------------------------- fit_lasso <- double_lasso( Y = Y[Z == 0], X_p = X[Z == 0, ], target_mean = colMeans(X[Z == 1, ]), lambda = 0.05, delta = 0.05 ) cat("Active outcome features :", fit_lasso$active_outcome, "\n") cat("Active balance features :", fit_lasso$active_balance, "\n") cat("Active union features :", fit_lasso$active_union, "\n")