# \donttest{
# Sample from DGP borrowed from grf documentation
n = 200
p = 5
X = matrix(rbinom(n * p, 1, 0.5), n, p)
Z = rbinom(n, 1, 0.5)
Q = rbinom(n, 1, 0.5)
W = Q * Z
tau = X[, 1] / 2
Y = rowSums(X[, 1:3]) + tau * W + Q + rnorm(n)
# Run outcome regression and extract smoother matrix
# Run DML and look at results
dml = dml_with_smoother(Y,W,X,Z)
results_dml = summary(dml)
plot(dml)
# Get weights
omega_dml = get_outcome_weights(dml)
# Observe that they perfectly replicate the original estimates
all.equal(as.numeric(omega_dml$omega %*% Y),
as.numeric(as.numeric(results_dml[,1])))
# The weights can then be passed to the cobalt package for example.
# }
Run the code above in your browser using DataLab