RegressionKink#
- class causalpy.experiments.regression_kink.RegressionKink[source]#
A class to analyse regression kink designs.
- Parameters:
data (
NativeDataFrame) – Any eager dataframe Narwhals supports, such as pandas, Polars, or PyArrow. Converted to pandas internally.formula (
str) – A statistical model formula.kink_point (
float) – A scalar value at which the kink occurs.model (
PyMCModel|None) – A PyMC model. Defaults toLinearRegression.running_variable_name (
str) – The name of the running variable column.epsilon (
float) – A small scalar for evaluating the causal impact above/below the kink.bandwidth (
float) – Data outside of the bandwidth (relative to the kink) is not used to fit the model.
Notes
Estimate extraction
The class predicts the conditional expectation at
kink_point - epsilon,kink_point, andkink_point + epsilon. It forms finite-difference slopes on the left and right and stores their difference asgradient_change. This is a local prediction contrast on derivatives, not a population-standardized effect.Methods
Run the experiment algorithm: fit model, predict, and evaluate gradient change.
RegressionKink.effect_summary(*[, ...])Generate a decision-ready summary of causal effects for Regression Kink.
RegressionKink.generate_report(*[, ...])Generate a self-contained HTML report for this experiment.
Validate the input data and model formula for correctness.
RegressionKink.plot(*[, round_to, ci_prob, ...])Plot the regression kink results.
RegressionKink.print_coefficients([round_to])Ask the model to print its coefficients.
RegressionKink.set_maketables_options(*[, ...])Set optional maketables rendering options for this experiment.
RegressionKink.summary([round_to])Print summary of main results and model coefficients.
Attributes
idataReturn fitted DataTree when the model backend supports it.
supports_bayessupports_olssupports_pymc_forecastlabelsdata- __init__(data, formula, kink_point, model=None, running_variable_name='x', epsilon=0.001, bandwidth=inf)[source]#
- classmethod __new__(*args, **kwargs)#