diff_diff.TROPResults#

class diff_diff.TROPResults[source]#

Bases: object

Results from a Triply Robust Panel (TROP) estimation.

TROP combines nuclear norm regularized factor estimation with exponential distance-based unit weights and time decay weights.

att#

Average Treatment effect on the Treated (ATT).

Type:

float

se#

Standard error of the ATT estimate.

Type:

float

t_stat#

T-statistic for the ATT estimate.

Type:

float

p_value#

P-value for the null hypothesis that ATT = 0.

Type:

float

conf_int#

Confidence interval for the ATT.

Type:

tuple[float, float]

n_obs#

Number of observations used in estimation.

Type:

int

n_treated#

Number of treated units.

Type:

int

n_control#

Number of control units.

Type:

int

n_treated_obs#

Number of treated unit-time observations.

Type:

int

unit_effects#

Estimated unit fixed effects (alpha_i).

Type:

dict

time_effects#

Estimated time fixed effects (beta_t).

Type:

dict

treatment_effects#

Individual treatment effects for each treated (unit, time) pair.

Type:

dict

lambda_time#

Selected time weight decay parameter from grid. 0.0 = uniform time weights (disabled) per Eq. 3.

Type:

float

lambda_unit#

Selected unit weight decay parameter from grid. 0.0 = uniform unit weights (disabled) per Eq. 3.

Type:

float

lambda_nn#

Selected nuclear norm regularization parameter from grid. inf = factor model disabled (L=0); converted to 1e10 internally for computation.

Type:

float

factor_matrix#

Estimated low-rank factor matrix L (n_periods x n_units).

Type:

np.ndarray

effective_rank#

Effective rank of the factor matrix (sum of singular values / max).

Type:

float

loocv_score#

Leave-one-out cross-validation score for selected parameters.

Type:

float

alpha#

Significance level for confidence interval.

Type:

float

n_pre_periods#

Number of pre-treatment periods.

Type:

int

n_post_periods#

Number of post-treatment periods (periods with D=1 observations).

Type:

int

n_bootstrap#

Number of bootstrap replications (if bootstrap variance).

Type:

int, optional

bootstrap_distribution#

Bootstrap distribution of estimates.

Type:

np.ndarray, optional

Methods

__init__(att, se, t_stat, p_value, conf_int, ...)

get_time_effects_df()

Get time fixed effects as a DataFrame.

get_treatment_effects_df()

Get individual treatment effects as a DataFrame.

get_unit_effects_df()

Get unit fixed effects as a DataFrame.

print_summary([alpha])

Print the summary to stdout.

summary([alpha])

Generate a formatted summary of the estimation results.

to_dataframe()

Convert results to a pandas DataFrame.

to_dict()

Convert results to a dictionary.

Attributes

alpha

bootstrap_distribution

coef_var

SE / abs(ATT).

is_significant

Check if the ATT is statistically significant at the alpha level.

n_bootstrap

n_post_periods

n_pre_periods

significance_stars

Return significance stars based on p-value.

survey_metadata

att

se

t_stat

p_value

conf_int

n_obs

n_treated

n_control

n_treated_obs

unit_effects

time_effects

treatment_effects

lambda_time

lambda_unit

lambda_nn

factor_matrix

effective_rank

loocv_score

__init__(att, se, t_stat, p_value, conf_int, n_obs, n_treated, n_control, n_treated_obs, unit_effects, time_effects, treatment_effects, lambda_time, lambda_unit, lambda_nn, factor_matrix, effective_rank, loocv_score, alpha=0.05, n_pre_periods=0, n_post_periods=0, n_bootstrap=None, bootstrap_distribution=None, survey_metadata=None)#
Parameters:
Return type:

None

classmethod __new__(*args, **kwargs)#