diff_diff.trop.TROPResults

class diff_diff.trop.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

__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)
Parameters:
Return type:

None

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

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.

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

att: float
se: float
t_stat: float
p_value: float
conf_int: Tuple[float, float]
n_obs: int
n_treated: int
n_control: int
n_treated_obs: int
unit_effects: Dict[Any, float]
time_effects: Dict[Any, float]
treatment_effects: Dict[Tuple[Any, Any], float]
lambda_time: float
lambda_unit: float
lambda_nn: float
factor_matrix: ndarray
effective_rank: float
loocv_score: float
alpha: float = 0.05
n_pre_periods: int = 0
n_post_periods: int = 0
n_bootstrap: int | None = None
__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)
Parameters:
Return type:

None

bootstrap_distribution: ndarray | None = None
__repr__()[source]

Concise string representation.

Return type:

str

summary(alpha=None)[source]

Generate a formatted summary of the estimation results.

Parameters:

alpha (float, optional) – Significance level for confidence intervals. Defaults to the alpha used during estimation.

Returns:

Formatted summary table.

Return type:

str

print_summary(alpha=None)[source]

Print the summary to stdout.

Parameters:

alpha (float | None)

Return type:

None

to_dict()[source]

Convert results to a dictionary.

Returns:

Dictionary containing all estimation results.

Return type:

Dict[str, Any]

to_dataframe()[source]

Convert results to a pandas DataFrame.

Returns:

DataFrame with estimation results.

Return type:

pd.DataFrame

get_treatment_effects_df()[source]

Get individual treatment effects as a DataFrame.

Returns:

DataFrame with unit, time, and treatment effect columns.

Return type:

pd.DataFrame

get_unit_effects_df()[source]

Get unit fixed effects as a DataFrame.

Returns:

DataFrame with unit and effect columns.

Return type:

pd.DataFrame

get_time_effects_df()[source]

Get time fixed effects as a DataFrame.

Returns:

DataFrame with time and effect columns.

Return type:

pd.DataFrame

property is_significant: bool

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

property significance_stars: str

Return significance stars based on p-value.