mcf_main.ModifiedCausalForest.predict_iv#

ModifiedCausalForest.predict_iv(data_df, new_keywords=None)#

Compute all effects for instrument mcf (possibly in 2 differnt ways).

train_iv() method must be run beforehand.

Parameters:
  • data_df (DataFrame) – Data used to compute the predictions. It must contain information about features (and treatment if effects for treatment specific subpopulations are desired as well).

  • new_keywords (Dictionary (or None). Default is None.) –

    Parameters of mcf instance to be changed. The keys in the dictionary are the parameters to be changed when running this method (and all methods that are run subsequently, like analyse or sensitivity), and the values corresponding to the keys are the new value (None is allowed only for ignored variable-name entries; see below). However, not all parameters can differ from those used during training. The following parameters can be changed, and thus specified as keys in this dictionary: ‘gen_output_type’, ‘cs_type’ (can only be changed to 0, use only if prediction data are already on common

    support);

    ’var_x_name_balance_test_ord’, ‘var_x_name_balance_test_unord’, ‘var_x_name_balance_bgate’, ‘var_x_name_ba’, ‘var_z_name_ord’, ‘var_z_name_unord’, ‘p_ba’, ‘p_ba_adj_method’, ‘p_ba_pos_weights_only’, ‘p_ba_use_x’, ‘p_ba_use_prop_score’, ‘p_ba_use_prog_score’, ‘p_ba_ridge’, ‘p_ate_no_se_only’, ‘p_atet’, ‘p_gatet’, ‘p_bgate’, ‘p_cbgate’, ‘p_iate’, ‘p_iate_se’, ‘p_iate_m_ate’, ‘p_bgate_sample_share’, ‘p_gates_minus_previous’, ‘p_gates_smooth_bandwidth’, ‘p_gates_smooth’, ‘p_gates_smooth_no_evalu_points’, ‘p_gates_no_evalu_points’, ‘p_qiate’, ‘p_qiate_se’, ‘p_qiate_m_mqiate’, ‘p_qiate_m_opp’, ‘p_qiate_no_of_quantiles’, ‘p_qiate_smooth’, ‘p_qiate_smooth_bandwidth’, ‘p_qiate_bias_adjust’, ‘p_bt_yes’, ‘p_choice_based_sampling’, ‘p_choice_based_probs’, ‘p_cond_var’, ‘p_knn’, ‘p_knn_const’, ‘p_knn_min_k’, ‘p_nw_bandw’, ‘p_nw_kern’, ‘p_ci_level’, ‘p_iv_aggregation_method’, ‘p_se_boot_ate’, ‘p_se_boot_gate’, ‘p_se_boot_iate’, ‘p_se_boot_qiate’, ‘post_bin_corr_threshold’, ‘post_bin_corr_yes’, ‘post_est_stats’, ‘post_kmeans_yes’, ‘post_kmeans_no_of_groups’, ‘post_kmeans_max_tries’, ‘post_kmeans_min_size_share’, ‘post_kmeans_replications’, ‘post_kmeans_single’, ‘post_random_forest_vi’, ‘post_relative_to_first_group_only’, ‘post_plots’, ‘post_tree’. For ‘p_ba’, ‘p_ba_use_prop_score’, ‘p_ba_use_prog_score’, ‘p_qiate’, ‘p_qiate_se’ and ‘p_bt_yes’, new_keywords accepts only False. Passing True raises ValueError, even if the flag is already enabled on the instance. A dictionary, including {}, is accepted only before the first prediction on an instance already used for training. Otherwise, ValueError is raised. For repeated predictions with different settings, create copies of the trained instance with copy.deepcopy() before its first prediction. None skips this check. Updates to variable names require a list or tuple of strings, even for one variable. Names are casefolded and must match the feature lists stored in the trained instance. ‘var_x_name_balance_test_ord’ and ‘var_z_name_ord’ require ordered features; ‘var_x_name_balance_test_unord’ and ‘var_z_name_unord’ require unordered features. ‘var_x_name_balance_bgate’ and ‘var_x_name_ba’ accept either feature type. Variable-name entries are checked only when their use is enabled after all updates. ‘var_x_name_ba’ requires both ‘p_ba’ and ‘p_ba_use_x’; an active selection must equal the trained set. Changing that set requires retraining. The balancing-test lists require ‘p_bt_yes’. ‘var_x_name_balance_bgate’ requires ‘p_bgate’ and enabled GATEs; CBGATEs do not use this balancing list. ‘p_ate_no_se_only’ disables checks of grouping and balancing-variable updates. Inactive entries, including None, are ignored and the stored lists are retained. Dictionary order does not affect which variable-name entries are checked. For unordered features, supply original names; the internal ‘_prime’ suffix is added.

Returns:

  • results_global (Dictionary.) – Contains the results. This dictionary has the following structure: ‘ate’: LATE, ‘ate_se’: Standard error of LATE, ‘ate_effect_list’: List of names of estimated effects, ‘ate_1st’: ATE 1st stage, ‘ate_1st_se’: Standard error of ATE (1st) ‘ate 1st_effect_list’: List of names of estimated effects (1st), ‘ate_redf’: ATE reduced form, ‘ate_redf_se’: Standard error of ATE of reduced form, ‘ate redf_effect_list’: List of names of estimated effects (red.f.), ‘gate’, ‘gate_se’, ‘gate_diff’, ‘gate_diff_se’: None, ‘cbgate’, ‘cbgate_diff’, ‘cbgate_diff_se’: None, ‘bgate’, ‘bgate_se’, ‘bgate_diff’, ‘bgate_diff_se’: None, ‘gate_names_values’: Dictionary: Order of gates parameters and name and values of

    LGATE effects.

    ’iate’, ‘iate_1st’, ‘iate_redf’: NumPy arrays or None

    Individual effects for the IV model, first stage and reduced form, respectively. Shape is (n_prediction, n_outcomes, 1, 2); the first stage has one outcome. The final axis contains the effect at index 0 and its deviation from the corresponding local LATE or stage ATE at index 1. Unrequested deviations are NaN. None if IATE estimation is disabled. Available even when DataFrame return is off.

    ’iate_se’, ‘iate_1st_se’, ‘iate_redf_se’: NumPy arrays or None

    Standard errors with the same axes as the corresponding individual-effect array. None if IATE estimation or IATE standard errors are disabled. Unrequested deviation standard errors are NaN.

    ’iate_data_df’: DataFrame or None

    Processed prediction data with LIATE results, including potential outcomes and, when requested, standard errors and differences from the corresponding average effects. None if IATE estimation or IATE DataFrame return is disabled; see _int_with_output and _int_return_iate_sp.

    ’iate_1st_pred_df’: DataFrame or None

    Same structure and None conditions for first-stage IATEs.

    ’iate_redf_pred_df’: DataFrame or None

    Same structure and None conditions for reduced-form IATEs.

    ’iate_names_dic’: Tuple of two dictionaries or None

    LIATE column-name metadata. The dictionaries have the same structure as ‘iate_names_dic’ returned by predict(). None if IATE estimation is disabled; otherwise available even when IATE DataFrame return is disabled.

    ’iate_1st_names_dic’: Tuple of two dictionaries or None

    Corresponding metadata and None condition for first-stage IATEs.

    ’iate_redf_names_dic’: Tuple of two dictionaries or None

    Corresponding metadata and None condition for reduced-form IATEs.

    ’qiate’, ‘qiate_se’, ‘qiate_diff’, ‘qiate_diff_se’, ‘qiate_mopp’, ‘qiate_mopp_se’: Always None; QLIATE estimation is not implemented

    for IV prediction.

    ’bala_1st’: Effects of balancing tests (1st stage), ‘bala_1st_se’: Standard error of effects of balancing tests (1st), ‘bala_1st_effect_list’: Names of effects of balancing tests (1st), ‘bala_redf’: Effects of balancing tests (reduced form), ‘bala_redf_se’: Standard error of effects of balancing tests (red.), ‘bala_redf_effect_list’: Names of effects of balancing tests (red.). ‘common_support_probabilities’: DataFrame (or None)

    Estimated probabilities of each instrument value for the prediction sample before common-support trimming, plus the observation identifier and ‘on_support’ (1 if retained, 0 if excluded). None if ‘cs_type’ is 0 or ‘_int_with_output’ is False.

    ’path_output’Path or None

    Directory in which output is saved. None if _int_with_output is False.

    It is empty if the IV estimation method ‘global’ has not been used.

  • results_local (Dictionary.) – Empty if ‘local’ is not selected in ‘p_iv_aggregation_method’. Otherwise, contains the keys listed for results_global and the additional key ‘cbgate_se’. ‘ate’ and ‘ate_se’ contain LATE and its standard error from local aggregation. Group effects also use local aggregation: ‘gate’: LGATE, ‘bgate’: LBGATE (prespecified covariates balanced), ‘cbgate’: LCBGATE (all covariates balanced). Their ‘_se’ entries contain the standard errors. Their ‘_diff’ and ‘_diff_se’ entries contain the differences selected by ‘p_gates_minus_previous’ and the corresponding standard errors. Group-effect entries are None when their estimators are disabled. The remaining entries have the same meaning as in results_global.