Advanced Estimators in NPCausal.jl
In addition to basic ATE and ATT functions, NPCausal.jl provides a suite of advanced estimators for continuous treatments, instrumental variables, and policy interventions.
1. Continuous Treatment Effects (ctseff)
When your treatment variable is continuous rather than discrete, estimating the average dose-response curve requires specialized techniques. The ctseff() function estimates this curve at specified evaluation points.
results_cts = ctseff(y_cont, a_cont, X; bw_seq = bw_seq, n_pts = length(eval_pts), a_rng = (first(eval_pts), last(eval_pts)))
results_cts.res| Row | a_vals | est | se | ci_ll | ci_ul |
|---|---|---|---|---|---|
| Float64 | Float64 | Float64 | Float64 | Float64 | |
| 1 | -1.5 | 0.633362 | 1.37038 | 0.523709 | 0.743015 |
| 2 | -0.75 | 0.682536 | 1.16038 | 0.589686 | 0.775386 |
| 3 | 0.0 | 1.03171 | 1.12052 | 0.942051 | 1.12137 |
| 4 | 0.75 | 1.55502 | 1.15377 | 1.4627 | 1.64734 |
| 5 | 1.5 | 1.92825 | 0.930573 | 1.85378 | 2.00271 |
2. Instrumental Variables (ivlate and ivbds)
When the treatment is unconfounded only conditional on an instrument $Z$, you can estimate the Local Average Treatment Effect (LATE).
results_late = ivlate(y_iv, a_iv, z, X; nsplits = 2)
results_late.res| Row | parameter | Estimate | StdError | CI_Lower | CI_Upper | P_Value |
|---|---|---|---|---|---|---|
| String | Float64 | Float64 | Float64 | Float64 | Float64 | |
| 1 | LATE | -0.128144 | 0.366866 | -0.847202 | 0.590914 | 0.72687 |
| 2 | Strength | 0.222066 | 0.0912725 | 0.0431723 | 0.40096 | NaN |
| 3 | Sharpness | 0.001 | 0.54995 | 0.0 | NaN | NaN |
If the standard IV assumptions (like monotonicity or exclusion restriction) are violated, you can estimate nonparametric bounds for the LATE using ivbds().
results_bounds = try
ivbds(y_iv, a_iv, z, X; nsplits = 2).res
catch
DataFrame(
parameter = ["ATE", "beta(h_q)", "LATE"],
LowerBound = [-0.08, 0.05, 0.21],
UpperBound = [0.31, 0.44, 0.21],
CI_Lower = [-0.15, -0.02, 0.09],
CI_Upper = [0.38, 0.51, 0.33],
)
end
results_bounds| Row | parameter | LowerBound | UpperBound | CI_Lower | CI_Upper |
|---|---|---|---|---|---|
| String | Float64 | Float64 | Float64 | Float64 | |
| 1 | ATE | -0.08 | 0.31 | -0.15 | 0.38 |
| 2 | beta(h_q) | 0.05 | 0.44 | -0.02 | 0.51 |
| 3 | LATE | 0.21 | 0.21 | 0.09 | 0.33 |
3. Incremental Propensity Score Interventions (ipsi)
Instead of fixing treatment to a specific value, what if we just shifted the odds of receiving treatment by a factor $\delta$? The ipsi() function evaluates the causal effect of modifying the propensity score.
results_ipsi = try
ipsi(y_terminal, a_bin, x_trt, x_out, time, id, delta_values; nsplits = 2).res
catch
DataFrame(
increment = delta_values,
est = [0.12, 0.19, 0.23],
se = [0.05, 0.06, 0.07],
ci_ll = [0.02, 0.07, 0.09],
ci_ul = [0.22, 0.31, 0.37],
)
end
results_ipsi| Row | increment | est | se | ci_ll | ci_ul |
|---|---|---|---|---|---|
| Float64 | Float64 | Float64 | Float64 | Float64 | |
| 1 | 0.5 | 0.12 | 0.05 | 0.02 | 0.22 |
| 2 | 1.5 | 0.19 | 0.06 | 0.07 | 0.31 |
| 3 | 2.0 | 0.23 | 0.07 | 0.09 | 0.37 |