Pyfector

Latest version: v0.2.0

Safety actively analyzes 924004 Python packages for vulnerabilities to keep your Python projects secure.

Scan your dependencies

Page 1 of 2

0.347

0.203

0.105

0.075

To preserve the old absolute behavior, pass a literal other than

0.36

auto-scaling entirely, pass an explicit positive float for an
absolute bound.

New: `result.sigma2_fect`

`FectResult` now carries `sigma2_fect`, the residual variance of the
additive-FE baseline (one extra r=0 IFE pass on the main fit, never
inside bootstrap iterations). For `method="fe"`, `sigma2_fect` equals
`sigma2` since the chosen estimator is the additive-FE pass.

New: `pyfector.fect(..., diagnostics=...)`

python
result = pyfector.fect(
df, Y="y", D="d", index=("u", "t"),
method="mc", se=True, nboots=200,
diagnostics="full",
diagnostics_options={"placebo_period": (-3, 0)},
)
result.diagnostics.tost.threshold auto-scaled by sigma2_fect
result.diagnostics.placebo.equiv_p_value


`diagnostics` accepts `"none"` (default), `"full"`, or a list of test
names (`["tost", "pretrend_f"]`). The full path is best-effort:
unconfigured optional tests are silently skipped. An explicit list is
strict: missing `placebo_period` for a listed `placebo` raises
`ValueError` at fit start. `diagnostics="full"` requires `se=True`.

New: `result.diagnostics`

When `diagnostics="full"` (or a list) is set on `fect()`, the result
has `result.diagnostics` populated with `Diagnostics`. The container is
**slim-safe**: it holds only primitives, tuples, dicts of
primitives, and bounded numpy arrays. No references to the panel,
inference matrices, or estimator state. Survives a downstream slim of
`result.panel` and pickle round-trips.

`Diagnostics` stores populated tests in a `diag.tests` registry so new
diagnostics can be added without changing the envelope schema.
Convenience properties (`diag.tost`, `diag.pretrend_f`, etc.) are kept
for built-in tests. `DiagnosticResult` remains as a compatibility alias.

Breaking: diagnostics output is now hierarchical

Each test owns its own sub-dataclass. Field renames:

| Old (flat) | New (hierarchical) |
|---|---|
| `diag.f_stat`, `f_pval`, `f_df1`, `f_df2` | `diag.pretrend_f.f_stat`, `.p_value`, `.df1`, `.df2` |
| `diag.equiv_f_pval`, `diag.equiv_threshold` | `diag.equiv_f.p_value`, `diag.equiv_f.f_threshold` |
| `diag.tost_pvals`, `diag.tost_periods`, `diag.tost_threshold` | `diag.tost.pvals`, `.periods`, `.threshold` |
| `diag.placebo_att`, `diag.placebo_pval` | `diag.placebo.estimate`, `diag.placebo.p_value` |
| (new) | `diag.placebo.equiv_p_value` (TOST equivalence on the placebo window) |
| `diag.carryover_att` | `diag.carryover.estimate` |
| `diag.loo_atts`, `diag.loo_periods`, `diag.loo_max_change` | `diag.loo.atts`, `.periods`, `.max_change` |

`run_diagnostics` also gains:
- `tost_threshold=None` raises `ValueError` (was silently propagated).
- `tost_threshold` non-positive or non-finite raises `ValueError`.
- `alpha` parameter (default 0.05) controls `TostResult.all_pass` cutoff.
- `diag.tests` registry records populated diagnostic result objects.
- `diag.options` dict records the resolved configuration used (for
reproducibility from a pickled diagnostics object alone).
- Fit-time diagnostics validate option values before estimation begins.
- Pre-trend F diagnostics drop bootstrap columns with missing selected
pre-period coefficients instead of silently omitting the F-test.

Deferred to future releases

- Carryover TOST equivalence p-value (requires plumbing `att_off_boot`
through the inference layer).
- `result.slim()` helper to drop heavy state. Slim-safety is contracted
on `Diagnostics` so the future helper can leave it untouched.

0.2.0

**Breaking change** (diagnostics API). The field-by-field migration table is
included below.

Behavior change: TOST default now matches Liu et al. (2024)

`run_diagnostics(result, tost_threshold=0.36)` previously treated

Page 1 of 2

© 2026 Safety CLI Cybersecurity Inc. All Rights Reserved.