2.3.2. doubleml.did.DoubleMLDIDAggregation#
- class doubleml.did.DoubleMLDIDAggregation(frameworks, aggregation_weights, overall_aggregation_weights=None, aggregation_names=None, aggregation_method_name='Custom', additional_information=None, additional_parameters=None)#
Class for aggregating multiple difference-in-differences (DID) frameworks.
This class enables weighted aggregation of multiple DoubleMLFramework objects, allowing for both multiple separate aggregations and an overall aggregation across them. It provides methods for summarizing and visualizing aggregated treatment effects.
- Parameters:
frameworks (list) – List of DoubleMLFramework objects to aggregate. Each framework must be one-dimensional (n_thetas = 1).
aggregation_weights (numpy.ndarray) – 2D array of weights for aggregating frameworks. Shape should be (n_aggregations, n_frameworks), where each row corresponds to a separate aggregation of the frameworks.
overall_aggregation_weights (numpy.ndarray, optional) – 1D array of weights for aggregating across the aggregated frameworks. Length should equal the number of rows in aggregation_weights. If None, equal weights are used. Default is None.
aggregation_names (list of str, optional) – Names for each aggregation. Length should equal the number of rows in aggregation_weights. If None, default names like “Aggregation_0”, “Aggregation_1”, etc. are used. Default is None.
aggregation_method_name (str, optional) – Name describing the aggregation method used. Default is “Custom”.
additional_information (dict, optional) – Dictionary containing additional information to display in the string representation. Default is None.
additional_parameters (dict, optional) – Dictionary containing additional parameters used by the class methods. For example, can contain ‘aggregation_color_idx’ for plot_effects(). Default is None.
Methods
plot_effects([level, joint, figsize, ...])Plot aggregated treatment effect estimates with confidence intervals.
Attributes
additional_informationAdditional information
additional_parametersAdditional parameters
aggregated_frameworksAggregated frameworks
aggregated_summaryA summary for the aggregated effects.
aggregation_method_nameAggregation method name
aggregation_namesAggregation names
aggregation_weightsAggregation weights
base_frameworksUnderlying frameworks
n_aggregationsNumber of aggregations
overall_aggregated_frameworkOverall aggregated framework
overall_aggregation_weightsOverall aggregation weights
overall_summaryA summary for the overall aggregated effect.
- DoubleMLDIDAggregation.plot_effects(level=0.95, joint=True, figsize=(12, 6), sort_by=None, color_palette='colorblind', title='Aggregated Treatment Effects', y_label='Effect')#
Plot aggregated treatment effect estimates with confidence intervals.
- Parameters:
level (float) – Confidence level for the intervals. Default is
0.95.joint (bool) – Indicates whether joint confidence intervals are computed. Default is
True.figsize (tuple) – Figure size as (width, height). Default is
(12, 6).sort_by (str or None) – How to sort the results - ‘estimate’, ‘name’, or None. Default is
None.color_palette (str or list) – Seaborn color palette name or list of colors. Default is
"colorblind".title (str) – Title for the plot. Default is
"Aggregated Treatment Effects".y_label (str) – Label for y-axis. Default is
"Effect".
- Returns:
fig (matplotlib.figure.Figure) – The created figure object.
ax (matplotlib.axes.Axes) – The axes object for further customization.
Notes
If
joint=Trueand bootstrapping hasn’t been performed, this method will automatically perform bootstrapping with default parameters and issue a warning.