mcf_main.ModifiedCausalForest.analyse#

ModifiedCausalForest.analyse(results, new_keywords=None)#

Analyse estimated IATEs with various descriptive tools.

Parameters:
  • results (Dictionary) – Results from predict(), or one nonempty dictionary returned by predict_iv(): results_global or results_local. For IV estimation, pass that dictionary rather than the two-element return tuple. Use results from this trained instance, with IATE estimation and IATE DataFrame return enabled; see ‘post_est_stats’. For IV results, correlations and sorted-effect/density analyses cover LIATEs, first-stage IATEs and reduced-form IATEs. Clustering and descriptive random-forest and regression-tree analyses use LIATEs only.

  • 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 (some of these will however not influence the results of this method, but of other other used with the same instance): ‘gen_output_type’; ‘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_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. 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. ‘cs_type’ is also accepted, but only with value 0. ‘p_iv_aggregation_method’ is accepted only if predict_iv() has set self.predict_iv_done to True; otherwise, ValueError is raised. These settings persist on the instance. They do not rerun common-support checks or recompute the supplied effects when analyse() is called. A dictionary, including {}, requires an instance already used for prediction by predict() or predict_iv(); otherwise, ValueError is raised. None skips this check.

Raises:

ValueError – Some of the attribute are not compatible with running this method.

Returns:

results_plus_cluster – If ‘post_kmeans_yes’ is True, a copy of results with cluster labels added to ‘iate_data_df’. ‘IATE_Cluster’ contains integer labels starting at 0. If ‘post_kmeans_single’ is True, additional ‘IATE_Cluster_<effect>’ columns contain labels from separate clustering runs for the selected effects. The returned ‘iate_data_df’ may contain fewer observations when ‘_int_max_obs_kmeans’ limits the sample used for clustering. If ‘post_kmeans_yes’ is False, returns None; the other enabled analyses still run.

Return type:

Dictionary or None