2. Inference#
2.1. Weights-based inference#
The default inference uses the representation of effect estimates as weighted averages of outcomes. It combines the expectation of conditional variance with the variance of conditional expectation, conditioning on forest weights. Conditional moments are estimated by k-nearest neighbors (default) or Nadaraya-Watson kernel regression.
With p_cond_var=False, variance is estimated directly from weighted outcomes
rather than conditional moments. See Lechner and Mareckova, Comprehensive
Causal Machine Learning for the theoretical
context and its assumptions.
2.2. Bootstrap inference#
The weight-based bootstrap resamples observations or clusters and renormalizes
weights. It does not retrain an entire forest in every replication.
p_se_boot_ate, p_se_boot_gate, p_se_boot_iate and p_se_boot_qiate
control the corresponding inference.
Use p_cluster_std with var_cluster_name for clustered inference; see
Sampling weights and clustering. When efficiency improvements are enabled through gen_ate_eff,
gen_gate_eff, gen_iate_eff or gen_qiate_eff, the variance
calculation depends on the type of treatment effect being estimated.
See Estimation of treatment effects for details.
2.3. Parameters#
Parameter |
Purpose |
|---|---|
|
Use conditional moments (default True). |
|
Use k-nearest neighbors (True) or Nadaraya-Watson (False). |
|
Weight-based bootstrap for average and group effects. |
|
Weight-based bootstrap for individual and quantile effects. |
|
Pointwise confidence level used in effect plots. |
See the API for details.
2.3.1. Example#
from mcf.example_data import example_data
from mcf.mcf_main import ModifiedCausalForest
# Generate example data using the built-in function `example_data()`
training_df, prediction_df, name_dict = example_data()
my_mcf = ModifiedCausalForest(
var_y_name="outcome",
var_d_name="treat",
var_x_name_ord=["x_cont0", "x_cont1", "x_ord1"],
# Bootstrap of standard errors for ATE
p_se_boot_ate=None,
# Conditional mean & variances are used
p_cond_var=True,
# Specifies k-NN method
p_knn=True
)
my_mcf.train(training_df)
results = my_mcf.predict(prediction_df)