diff_diff.YatchewTestResults#

class diff_diff.YatchewTestResults[source]#

Bases: object

Result of yatchew_hr_test() (paper Theorem 7 / Equation 29).

Heteroskedasticity-robust specification test using Yatchew’s difference-based variance estimator. Two nulls are supported via the null= argument on yatchew_hr_test() and reflected on the null_form attribute below: "linearity" (default; paper Theorem 7, the same null as stute_test(), residuals from OLS dy ~ 1 + d) and "mean_independence" (R-parity extension mirroring R YatchewTest::yatchew_test(order=0), residuals from intercept-only OLS dy ~ 1). The test statistic T_hr = sqrt(G) * (sigma2_lin - sigma2_diff) / sigma2_W is asymptotically N(0, 1) under H_0 in both modes; rejection uses the one-sided standard-normal critical value. Only the residual definition (and therefore sigma2_lin) differs between modes — the sigma2_diff / sigma2_W / sort-by-d machinery is shared.

t_stat_hr#

Test statistic T_hr from paper Equation 29. NaN when G < 3.

Type:

float

p_value#

1 - Phi(T_hr). NaN when the statistic is NaN.

Type:

float

reject#

True iff T_hr >= critical_value. False on NaN.

Type:

bool

alpha#

Significance level used.

Type:

float

critical_value#

One-sided standard-normal critical value z_{1 - alpha}.

Type:

float

sigma2_lin#

Residual variance under the chosen null. Under null_form="linearity": residual variance from OLS of dy on d. Under null_form="mean_independence": (1/G) * sum((dy - mean(dy))^2), the population variance of dy.

Type:

float

sigma2_diff#

Yatchew differencing variance (1 / (2G)) * sum((dy_{(g)} - dy_{(g-1)})^2) - divisor is 2G (paper-literal), NOT 2(G-1).

Type:

float

sigma2_W#

Heteroskedasticity-robust scale sqrt((1 / (G-1)) * sum(eps_{(g)}^2 * eps_{(g-1)}^2)).

Type:

float

n_obs#

Number of observations.

Type:

int

null_form#

"linearity" (default; H_0: E[dY|D] is linear in D, residuals from OLS dy ~ 1 + d) or "mean_independence" (H_0: E[dY|D] = E[dY], residuals from intercept-only OLS dy ~ 1). Mirrors R YatchewTest::yatchew_test’s order argument (order=1"linearity"; order=0"mean_independence").

Type:

str

Methods

__init__(t_stat_hr, p_value, reject, alpha, ...)

print_summary()

Print the summary to stdout.

summary()

Formatted summary table.

to_dataframe()

Return a one-row DataFrame of the result dict.

to_dict()

Return results as a JSON-safe dict.

Attributes

__init__(t_stat_hr, p_value, reject, alpha, critical_value, sigma2_lin, sigma2_diff, sigma2_W, n_obs, null_form='linearity')#
Parameters:
Return type:

None

classmethod __new__(*args, **kwargs)#