*! version 30aug2024

ddml overlap utility - Overlap plots with interactive models (ATE etc.)

We use the default of 5 cross-fit folds
and specify 2 resamplings with 2 supervised learners:
linear regression and gradient boosted trees, stacked using pystacked.
Note that we use gradient boosted regression trees for E[Y|X,D],
but gradient boosted classification trees for E[D|X].

. webuse cattaneo2, clear

. global Y bweight

. global D mbsmoke

. global X prenatal1 mmarried fbaby mage medu

. set seed 42

. ddml init interactive, reps(2)

. ddml E[Y|X,D]: pystacked $Y $X || method(ols) || method(gradboost) || , type(reg)

. ddml E[D|X]: pystacked $D $X || method(logit) || method(gradboost) || , type(class)

. ddml crossfit

. ddml estimate

Default behavior of ddml overlap is to use all cross-fit resamples
and plot the stacked (ensemble) learner generated by pystacked:

. ddml overlap

Use just resample 1:

. ddml overlap, replist(1)

Overlap plots for the predicted values of
the separate logit (#1) and gradboost (#2) learners:

. ddml overlap, pslist(D1_pystacked_L1 D1_pystacked_L2)

Save the overlap plot using the default triangle kernel,
generate an overlap plot using the Epanechnikov, kernal,
and combine the two into a single graph:

. ddml overlap, name(triangle, replace) title(Propensity score - triangle kernel)

. ddml overlap, kernel(epanechnikov) name(epanechnikov, replace) title(Propensity score - epanechnikov kernel)

. graph combine triangle epanechnikov