Results¶
- class dpd_stream.DPDResult[source]¶
A fitted difference or system GMM model.
- Attributes:
fml, depvar, coefnames, beta, vcov, vcov_type, df_t, n_obs, all_vcovs, n_clusters, collin_vars, diagnostics, weights, weights_type – As in
hdfe_stream.HDFEResult.n_obscounts the observations of the levels equation in system GMM, of the transformed equation in difference GMM (as xtabond2).vcov_typeis"iid"or"robust"("CRV1:<vars>"when clustered); for a two-step fit, robust means Windmeijer-corrected, and"iid"the uncorrected two-step variance.estimator (str) –
"difference"or"system".steps (int or str) – 1, 2 or
"iterated".transform (str) –
"fd"or"fod".n_groups (int) – Panels with observations.
obs_per_group (dict) –
min,avgandmax.n_instruments (int) – Instruments, less any the generalized inverse drops (xtabond2’s count).
ar (list of dict) – Arellano-Bond tests for AR(1), AR(2), … in the first-differenced residuals:
order,z,p.sargan (dict) – Sargan test of the overidentifying restrictions (
statistic,df,p): not robust, from the one-step residuals.hansen (dict or None) – Hansen’s J test (robust); None for a one-step non-robust fit.
diff_hansen (list of dict) – Difference-in-Hansen (or -Sargan) tests of each instrument group’s exogeneity:
group, the test of the model without it (excluded,excluded_df,excluded_p) and of the difference (difference,difference_df,difference_p).model_test (dict or None) – Wald test that all coefficients are zero: chi2, or F with
small.sigma2 (float) – xtabond2’s sigma^2 (e(sig2)).
mmsc (dict or None) – Andrews and Lu’s (2001) model and moment selection criteria (
bic,aic,hqic; lower is better), from Hansen’s J.onestep (DPDResult or None) – For two-step and iterated fits, the one-step estimates (free).
idtests (dict or None) – Identification tests (Windmeijer 2025; Stata’s underid
kp sw), robust to the fit’s clustering, with the regressors that are their own IV-style instruments (and any absorbed effect) partialled out:kp_lm, Kleibergen and Paap’s rk LM test of underidentification (rank of the first stage K - 1; rejecting means identified);kp_wald, its Wald form, withFthe weak-identification statistic with ivreg2’s small-sample factor (no Stock-Yogo critical values apply with robust variances and many instruments);sanderson_windmeijer, the conditional underidentification test of each endogenous regressor;partial_r2, each one’s first-stage partial R^2 and Shea’s partial R^2;effective_f, Montiel Olea and Pflueger’s effective F with its 2SLS critical value (one endogenous regressor; else None);anderson_rubin, the weak-instrument-robust test that the endogenous regressors’ coefficients are 0 (from the moment conditions, with the reduced form of y), and with one of them its 95% confidence set (confidence_set["intervals"]). No endogeneity test: the lagged dependent variable is endogenous in the transformed equation by construction, and the other regressors’ exogeneity is what the difference-in-Hansen test of their IV-style group checks. None with no endogenous regressor, or when skipped (seeidtests=). The algebra ishdfe_stream.core.ivtests.nl (dict or None) – With Ahn-Schmidt moments: their
kind("noserial"or"iid"), number (moments), the first step’sweighton them, and whether the nonlinear stepconverged.absorbed (dict or None) – The absorbed fixed effect: its
term, the number ofeffectsestimated (cells with observations), and themethod:"dummies"for time effects (| year), estimated as dummies and not reported, so every statistic is exact;"cells"for a period effect by group (| g^year, difference GMM), partialled out of the moments (see the user guide).pca (dict or None) – With
pca=True: the number ofcomponents, theeigenvalues,kmoandr2(the share of the variance kept).
- summary(logger=None, level=20)[source]¶
Print the report, or write it to
logger(one record, atlevel).
- tidy()[source]¶
Coefficient table. p-values use the t distribution with
df_tdegrees of freedom, or the normal for GLMs, as in pyfixest.
- confint(alpha=0.05, keep=None, drop=None, exact_match=False, joint=False, reps=10000, seed=None)[source]¶
Confidence intervals, one coefficient at a time or simultaneous.
Pointwise intervals use the t distribution with
df_tdegrees of freedom, or the normal for GLMs, astidydoes. Withjoint=True, the intervals cover all the selected coefficients at once with probability 1 - alpha: the critical value is the 1 - alpha quantile of the largest absolute t statistic, simulated from the normal with the coefficients’ correlation (the multiplier bootstrap of pyfixest’sconfint(joint=True); Chernozhukov et al., Applied Causal Inference Powered by ML and AI, remark 4.4.1).- Parameters:
alpha (float, default 0.05) – One minus the coverage.
keep (str or list of str, optional) – Regular expressions selecting coefficients by name, as in pyfixest: those matching a
keeppattern, in the order of the patterns (all, by default), less those matching adroppattern. A joint interval covers exactly these.drop (str or list of str, optional) – Regular expressions selecting coefficients by name, as in pyfixest: those matching a
keeppattern, in the order of the patterns (all, by default), less those matching adroppattern. A joint interval covers exactly these.exact_match (bool, default False) – Match names exactly instead of as regular expressions.
joint (bool, default False) – Simultaneous intervals.
reps (int, default 10000) – Draws for the joint critical value.
seed (int, optional) – Seed for those draws.
- Returns:
polars.DataFrame –
Coefficientand the lower and upper bounds, in columns named by their percentiles ("2.5%","97.5%").
- wald_test(R=None, q=None, distribution=None, keep=None, drop=None, exact_match=False)[source]¶
Wald test of the linear hypothesis R beta = q, under the current vcov (see
with_vcov).By default the hypothesis is that every coefficient is zero;
keepanddropnarrow it to some of them (the coefficients of an event study’s leads, say), andRandqstate any other.The statistic is W = (R b - q)’ (R V R’)^+ (R b - q), and F = W / m for m restrictions. F is referred to the F distribution with m and
df_tdegrees of freedom, so that for one coefficient the p-value is the onetidyreports; W, to the chi-squared with m. Two differences from pyfixest’swald_test: it reports chi-squared whenever R is not the identity or q is not zero, where this test reports what is asked for; and its F’s denominator degrees of freedom, without clustering, subtract every fixed-effect level, including the redundant ones thatdf_tdoes not.- Parameters:
R (array-like, optional) – m x k, one row per restriction, one column per coefficient in the order of
coefnames; a 1-d array is one restriction.q (float or array-like, optional) – The m right-hand sides; zero by default.
distribution ({"F", "chi2"}, optional) – Default “F” for OLS and “chi2” for GLMs, whose
tidyp-values are normal.keep – Without
R: test that the coefficients they select are zero (orq), as inconfint.drop – Without
R: test that the coefficients they select are zero (orq), as inconfint.exact_match – Without
R: test that the coefficients they select are zero (orq), as inconfint.
- Returns:
dict –
statistic(F or W),pvalue,df1(m),df2(df_tfor F, None for chi-squared) anddistribution.
- with_vcov(vcov)[source]¶
A copy with the other variance computed at fit time:
"iid"(for two-step: uncorrected) or"robust"(the fit’s clustering, Windmeijer-corrected for two-step).
- long_run(var, ldv=None)[source]¶
The long-run effect of
var: the sum of its coefficients (the variable and its lags) over one minus the sum of the lagged dependent variable’s, with a delta-method standard error.
- predict(newdata=None)[source]¶
The linear prediction x_it’b in levels (without the panel effect), as a lazy frame of the panel, time and
fitted, over the fit’s data ornewdata(which must have the columns the formula uses). Lags are taken by time value, as in the fit.
- resid(transform='levels', newdata=None)[source]¶
Residuals as a lazy frame of the panel, time and
resid:"levels", y - x’b (which includes the panel effect), or"fd", their first differences (the transformed equation’s residuals in difference GMM).
- sample()[source]¶
The estimation sample, as a lazy frame of the panel, time and whether the observation enters the
transformedequation (its first difference, or its forward orthogonal deviation) and, in system GMM, thelevelsequation; one row per observation of the fit’s data that enters either. Computed from the data as the fit selects its rows: the outcome, the regressors (with the lags they take by time) and the weight present, and the IV-style instruments (unlessmz) in the equation they instrument.
- summary_dict(coefficients=False)[source]¶
The model-level information of summary() as a dict of plain Python types (JSON-ready; nan is None). Fit statistics not defined for the model (e.g. r2 for a GLM) are absent.
coefficients=Trueadds thetidy()table as a list of row dicts.
- summary_json(path=None, indent=2, coefficients=False)[source]¶
The model-level information of summary() as a JSON string (see
summary_dict); withpath, also written there as UTF-8. Reload withjson.loadsorjson.load.
- to_pyfixest()[source]¶
A pyfixest
Feols(Feivfor IV) view of this result, forpf.etable,pf.summary,pf.coefplotandpf.iplot. Only the stored results are available; methods that need the data (recomputing the vcov, the wild bootstrap) are not, andpredictis this result’s ownpredict.
- __init__(*, fml, depvar, coefnames, beta, vcov, vcov_type, df_t, n_obs, all_vcovs=<factory>, n_clusters=<factory>, collin_vars=<factory>, diagnostics=<factory>, weights=None, weights_type='aweights', estimator='difference', steps=2, transform='fd', n_groups=0, obs_per_group=<factory>, n_instruments=0, ar=<factory>, sargan=<factory>, hansen=None, diff_hansen=<factory>, model_test=None, sigma2=nan, mmsc=None, onestep=None, pca=None, small=False, instrument_list=<factory>, time_effects=None, absorbed=None, idtests=None, nl=None, _model=<factory>)¶
- classmethod __new__(*args, **kwargs)¶