causal_agent.methods.diff_in_means package
Submodules
causal_agent.methods.diff_in_means.diagnostics module
Basic descriptive statistics for Difference in Means.
causal_agent.methods.diff_in_means.estimator module
Difference in Means / Simple Linear Regression Estimator.
Estimates the Average Treatment Effect (ATE) by comparing the mean outcome between the treated and control groups. This is equivalent to a simple OLS regression of the outcome on the treatment indicator.
Assumes no confounding (e.g., suitable for RCT data).
- causal_agent.methods.diff_in_means.estimator.estimate_effect(df, treatment, outcome, query=None, llm=None, **kwargs)[source]
Estimates the causal effect using Difference in Means (via OLS).
Ignores any provided covariates.
- Parameters:
df (DataFrame) – Input DataFrame.
treatment (str) – Name of the binary treatment variable column (should be 0 or 1).
outcome (str) – Name of the outcome variable column.
query (str | None) – Optional user query for context.
llm (langchain.chat_models.base.BaseChatModel | None) – Optional Language Model instance.
**kwargs – Additional keyword arguments (ignored).
- Returns:
‘effect_estimate’: The difference in means (treatment coefficient).
’p_value’: The p-value associated with the difference.
’confidence_interval’: The 95% confidence interval for the difference.
’standard_error’: The standard error of the difference.
’formula’: The regression formula used.
’model_summary’: Summary object from statsmodels.
’diagnostics’: Basic group statistics.
’interpretation’: LLM interpretation.
- Return type:
Dictionary containing estimation results
causal_agent.methods.diff_in_means.llm_assist module
LLM assistance functions for Difference in Means analysis.
- causal_agent.methods.diff_in_means.llm_assist.interpret_dim_results(results, diagnostics, treatment_var, llm=None)[source]
Use LLM to interpret Difference in Means results.
- Parameters:
results (RegressionResultsWrapper) – Fitted statsmodels OLS results object (from outcome ~ treatment).
diagnostics (Dict[str, Any]) – Dictionary of diagnostic results (group stats).
treatment_var (str) – Name of the treatment variable.
llm (langchain.chat_models.base.BaseChatModel | None) – Optional LLM model instance.
- Returns:
String containing natural language interpretation.
- Return type: