causal_agent.methods.regression_discontinuity package
Submodules
causal_agent.methods.regression_discontinuity.diagnostics module
Diagnostic checks for Regression Discontinuity Design (RDD).
- causal_agent.methods.regression_discontinuity.diagnostics.run_rdd_diagnostics(df, outcome, running_variable, cutoff, covariates=None, bandwidth=None)[source]
Runs diagnostic checks for RDD analysis.
Currently includes: - Covariate Balance Check (t-tests) Placeholders for: - Density Test (McCrary) - Placebo Cutoff Tests - Bandwidth Sensitivity
- Parameters:
df (DataFrame) – Input DataFrame.
outcome (str) – Name of the outcome variable.
running_variable (str) – Name of the running variable.
cutoff (float) – The threshold value.
covariates (List[str] | None) – Optional list of covariate names to check for balance.
bandwidth (float | None) – Optional bandwidth to restrict the analysis. If None, a default is used.
- Returns:
Dictionary containing diagnostic results.
- Return type:
causal_agent.methods.regression_discontinuity.estimator module
Regression Discontinuity Design (RDD) Estimator.
Tries to use DoWhy’s RDD implementation first, falling back to a basic comparison of linear fits around the cutoff if DoWhy fails.
- causal_agent.methods.regression_discontinuity.estimator.estimate_effect_dowhy(df, treatment, outcome, running_variable, cutoff_value, covariates, **kwargs)[source]
Estimate RDD effect using DoWhy.
- causal_agent.methods.regression_discontinuity.estimator.estimate_effect_fallback(df, treatment, outcome, running_variable, cutoff_value, covariates, **kwargs)[source]
Estimate RDD effect using simple linear regression comparison fallback.
- causal_agent.methods.regression_discontinuity.estimator.effect_estimate_rdd(df, outcome, running_variable, cutoff_value, treatment=None, covariates=None, bandwidth=None, **kwargs)[source]
Estimates RDD effect using the ‘evan-magnusson/rdd’ package. Uses IK optimal bandwidth selection from the same package by default.
- causal_agent.methods.regression_discontinuity.estimator.estimate_effect(df, treatment, outcome, running_variable, cutoff_value, covariates=None, bandwidth=None, query=None, llm=None, **kwargs)[source]
Estimates the causal effect using Regression Discontinuity Design.
Tries DoWhy implementation first if use_dowhy=True, otherwise uses fallback.
- Parameters:
df (DataFrame) – Input DataFrame.
treatment (str) – Name of the treatment variable (often implicitly defined by cutoff). DoWhy might still need it, fallback doesn’t use it directly.
outcome (str) – Name of the outcome variable.
running_variable (str) – Name of the variable determining treatment assignment.
cutoff – The threshold value for the running variable.
covariates (List[str] | None) – Optional list of covariate names (support varies).
bandwidth (float | None) – Optional bandwidth around the cutoff. If None, a default is used.
use_dowhy – Whether to attempt using the DoWhy library first.
query (str | None) – Optional user query for context.
llm (langchain.chat_models.base.BaseChatModel | None) – Optional Language Model instance.
**kwargs – Additional keyword arguments for underlying methods.
- Returns:
Dictionary containing estimation results.
- Return type:
causal_agent.methods.regression_discontinuity.llm_assist module
LLM assistance functions for Regression Discontinuity Design (RDD).
- causal_agent.methods.regression_discontinuity.llm_assist.suggest_rdd_parameters(df_cols, query, llm=None)[source]
(Placeholder) Use LLM to suggest RDD parameters (running variable, cutoff).
- Parameters:
- Returns:
Dictionary containing suggested ‘running_variable’ and ‘cutoff’, or empty.
- Return type: