statspai.quasi¶
quasi ¶
Lightweight pre/post quasi-experimental designs.
These wrap StatsPAI's OLS machinery into named, assumption-surfacing designs so non-experts reach for the right estimator:
- :func:
ancova— covariate-adjusted comparison of group means. - :func:
negd— pre/post non-equivalent group design (ANCOVA or change-score).
Both return the unified :class:~statspai.core.results.CausalResult.
negd ¶
negd(data: DataFrame, group: str, *, pre: str, post: str, covariates: Optional[Sequence[str]] = None, method: str = 'ancova', robust: str = 'hc1', cluster: Optional[str] = None, alpha: float = 0.05, group_value: Any = None) -> CausalResult
Pre/post non-equivalent group design (NEGD).
A treated and a non-randomised comparison group are each measured before and after the intervention. Two estimators are offered:
method='ancova'(default): regressposton treatment andpre(plus any covariates). Conditions on baseline; robust to baseline imbalance and generally preferred (Lord's paradox).method='change_score': regress the changepost - preon treatment (plus covariates). Identifies under parallel pre/post trends and is more vulnerable to regression to the mean when baseline differs across groups.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
DataFrame
|
One row per unit (wide format: a |
required |
group
|
str
|
Treatment-group column (see :func: |
required |
pre
|
str
|
Baseline and follow-up outcome columns. |
required |
post
|
str
|
Baseline and follow-up outcome columns. |
required |
covariates
|
sequence of str
|
Additional adjustment covariates. |
None
|
method
|
('ancova', 'change_score')
|
Estimator (see above). |
'ancova'
|
robust
|
str
|
As in :func: |
'hc1'
|
cluster
|
str
|
As in :func: |
'hc1'
|
alpha
|
str
|
As in :func: |
'hc1'
|
group_value
|
str
|
As in :func: |
'hc1'
|
Returns:
| Type | Description |
|---|---|
CausalResult
|
|
Examples: