Results¶
A fit’s result has hdfe-stream’s reporting: summary(), tidy(),
confint(), summary_json() and etable().
- class rd_stream.RDResult[source]¶
One outcome’s RD estimate, as rdrobust reports it: three rows.
Conventional: the local-polynomial estimate with its conventional standard error.Bias-corrected: the bias-corrected estimate with the conventional standard error.Robust: the bias-corrected estimate with the robust standard error (Calonico, Cattaneo and Titiunik 2014). Its interval is the one to report.
betaholds the three estimates andvcovtheir variances on the diagonal. The off-diagonal entries are zero, because rdrobust does not compute the covariances. A Wald test across the rows is not meaningful.with_rowspicks the rows to report (intidy,confint,summaryandetable), and adds a fourth,"Conventional, robust inference": the conventional estimate shown with the robust standard error, and the robust test and interval (which are about the bias-corrected estimate), as papers often report rdrobust’s results.The attributes below are beyond hdfe-stream’s
RegressionResult’s (beta,vcov,se,n_obs, …).- Attributes:
running (str) – The running variable.
cutoff (float)
bandwidth, bias_bandwidth (tuple of float) – h and b, (left, right).
bandwidth_selector (str) – The selector (“mserd”, …), or “manual”.
polynomial_order, bias_order, derivative (int)
kernel (str)
n_left, n_right (int) – Observations on each side.
n_bandwidth (tuple of int) – Observations within h on each side.
n_bias_bandwidth (tuple of int) – Observations within b on each side.
n_distinct (tuple of int) – Distinct values of the running variable on each side.
side_estimates (dict) – The intercepts (or derivatives) on each side: conventional and bias-corrected.
donut ((left, right) or None) – The donut hole’s radii, when observations near the cutoff were left out.
donut_closed (str or None) – Which ends of the hole were left out too (see
rd_estimate).collapsed (bool) – Whether the fit ran on one row per distinct value of the running variable (which gives the same results; see
memory).memory (str) – How the data were held: “rows” (the sorted rows), “by_value” (grouped by the running variable as they were read) or “window” (the rows near the cutoff, or slabs of them on disk).
- with_rows(rows)[source]¶
This fit, reporting only
rows, in that order: any of “Conventional”, “Bias-corrected”, “Robust” and “Conventional, robust inference” (or “conventional_robust”; the names are case-insensitive). The new result’stidy,confint,summaryandetableshow those rows. It takes a fit with rdrobust’s three rows.
- 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%").
- property estimate¶
The conventional point estimate (the first row’s estimate, once
with_rowshas chosen the rows).
- property robust_ci¶
The robust bias-corrected 95% interval.
- __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', running, cutoff, bandwidth, bias_bandwidth, bandwidth_selector, polynomial_order, bias_order, derivative, kernel, n_left, n_right, n_bandwidth, n_bias_bandwidth, n_distinct, side_estimates=<factory>, collapsed=False, memory='rows', treatment=None, first_stage=None, donut=None, donut_closed=None, timings=<factory>, inference_center=None)¶
- classmethod __new__(*args, **kwargs)¶
- class rd_stream.RDMulti[source]¶
Several RD fits from one read and sort of the data (several outcomes, or several bandwidths).
- with_rows(rows)[source]¶
Every fit with only
rows(seeRDResult.with_rows).
- estimates()[source]¶
One row per fit: outcome, bandwidths, estimate, robust interval (from the fits’ three rows).
- classmethod __new__(*args, **kwargs)¶
- class rd_stream.BandwidthResult[source]¶
Selected bandwidths:
tablehas one row per selector.- __init__(table, selector, outcome, running, cutoff)¶
- classmethod __new__(*args, **kwargs)¶
- class rd_stream.PlaceboResult[source]¶
rd_placebo’s result.
- Attributes:
table (polars.DataFrame) – One row per outcome and cutoff:
outcome,cutoff,kind(“placebo”, or “actual” for the true cutoff),side(the side of the true cutoff whose observations were used),estimate(the conventional estimate),se,robust_se,robust_low,robust_highandrobust_p(the robust bias-corrected interval and p-value),h_left,h_right,n_left,n_right(the observations within h) andnote(why a cutoff has no estimate).fits (RDMulti) – The fits, as
rd_estimatereturns them.cutoff (float) – The true cutoff.
running (str)
- plot(*, outcomes=None, ncols=2, panel_size=(5.0, 3.5), xlabel=None, color_placebo='C0', color_actual='C3')[source]¶
The estimates against the cutoff, with their robust intervals: a panel per outcome, the true cutoff’s estimate in
color_actual. Needs matplotlib (pip install rd-stream[plot]).- Returns:
matplotlib.figure.Figure
- __init__(table, fits, cutoff, running)¶
- classmethod __new__(*args, **kwargs)¶
- class rd_stream.RDPlot[source]¶
rd_plot’s result: the bins, the global polynomial fit and the bin selection, as rdplot reports them;
plot()draws them.- Attributes:
bins (polars.DataFrame) – One row per non-empty bin, left to right:
bin(-J..-1 on the left, 1..J on the right),x_mid(the bin’s midpoint, where rdplot draws it),x_mean,y_mean,x_low,x_high(the bin’s edges),n,se(of the mean) andci_low,ci_high(theciinterval, from the t distribution).fit (polars.DataFrame) – The global polynomial on each side:
side,x,yat 500 points from the cutoff to the bandwidth’s edge.coef (polars.DataFrame) – The polynomial’s coefficients on each side (
power,left,right), in powers of x - cutoff.n_bins, n_bins_imse, n_bins_mimicking (tuple of int) – The bins used, the IMSE-optimal number and the mimicking-variance number, (left, right) (rdplot’s J, J_IMSE and J_MV).
bin_scale, relative_scale (tuple of float) – The scale applied, and the bins used over the IMSE-optimal number (rdplot’s scale and rscale).
bin_length_mean, bin_length_median (tuple of float)
bin_method (str) – The bin selection, described as rdplot describes it.
- plot(*, ax=None, ci=False, shade=False, title=None, xlabel=None, ylabel=None, color_points='C0', color_lines='C3')[source]¶
Draw the binned means, the polynomial fits and the cutoff, as rdplot draws them. Needs matplotlib, which is not a dependency (
pip install rd-stream[plot]).- Parameters:
ax (matplotlib.axes.Axes, optional) – Draw here instead of on a new figure.
ci (bool, default False) – Error bars: each bin’s
ciinterval.shade (bool, default False) – The intervals as a shaded band.
title (str, optional) – Default: no title, the running variable and the outcome.
xlabel (str, optional) – Default: no title, the running variable and the outcome.
ylabel (str, optional) – Default: no title, the running variable and the outcome.
- Returns:
matplotlib.figure.Figure
- __init__(outcome, running, cutoff, bins, fit, coef, n_bins, n_bins_imse, n_bins_mimicking, bin_scale, relative_scale, bin_length_mean, bin_length_median, polynomial_order, bandwidth, n, n_bandwidth, bin_method, kernel, ci, covariate_coef=None, memory='rows', donut=None, donut_closed=None, timings=<factory>)¶
- classmethod __new__(*args, **kwargs)¶
- class rd_stream.RDPlotMulti[source]¶
rd_plot’s result for several outcomes, from one read and sort of the data: an
RDPlotper outcome, each with its own bins. Iterate over it, take one by outcome or position (plots["y2"],plots[0]), or draw them side by side withplot();len()counts them.- plot(*, outcomes=None, ncols=2, panel_size=(5.0, 3.5), sharex=True, ci=False, shade=False, xlabel=None, titles=True, color_points='C0', color_lines='C3')[source]¶
Draw the outcomes as small multiples: a panel each,
ncolsto a row, with a shared x axis (sharex) and each outcome’s own y axis. Needs matplotlib (pip install rd-stream[plot]).- Parameters:
outcomes (list of str, optional) – The outcomes to draw, in this order; default all.
ncols (int, default 2)
panel_size ((width, height), default (5, 3.5)) – Inches per panel.
sharex (bool, default True)
ci – As in
RDPlot.plot.shade – As in
RDPlot.plot.color_points – As in
RDPlot.plot.color_lines – As in
RDPlot.plot.xlabel (str, optional) – Default: the running variable, under the bottom row.
titles (bool, default True) – Each panel titled by its outcome (its y axis is then unlabeled).
- Returns:
matplotlib.figure.Figure
- classmethod __new__(*args, **kwargs)¶