estimate_p#
- SuperGLM.estimate_p(
- X: object,
- y: NDArray,
- sample_weight: NDArray | None = None,
- offset: NDArray | None = None,
- *,
- fit_mode: str = 'fit',
- search_fit_mode: str | None = None,
- p_bounds: tuple[float, float] = (1.05, 1.95),
- xatol: float = 0.001,
- ci_alpha: float | None = None,
- max_reml_iter: int | None = None,
- progress_callback: Callable[[...], None] | None = None,
Estimate Tweedie p via profile likelihood, refit, and return result.
At each candidate
pthe mean is refitted andphiis its maximum-likelihood value at that mean;pminimises the resulting profile negative log-likelihood by bounded Brent search (Dunn & Smyth 2005), and the published fit is refitted at the selectedp. The search is local: if the profile has more than one interior minimum inp_bounds, it can return one that is not the global minimum, with no warning. Only an estimate on a bound is flagged.- Parameters:
- Xpandas or eager Polars DataFrame
Feature matrix. Lazy frames must be collected before fitting.
- yarray-like
Response variable.
- sample_weightarray-like, optional
Finite, strictly positive EDM prior weights, not replication or frequency weights. The Tweedie variance convention is
Var(Y_i | x_i) = phi * mu_i**p / w_i. Remove zero-weight rows consistently fromX,y,sample_weight, andoffsetbefore calling this method.- offsetarray-like, optional
Offset added to the linear predictor.
- fit_mode{“fit”, “reml”, “inherit”}
Fitting regime for the published final fit, and by default for each candidate
pevaluation too.- search_fit_mode{“fit”, “reml”, “inherit”}, optional
Fitting regime for the candidate
pevaluations alone, when it should differ from the regime the final fit is published under. The defaultNonesearches underfit_mode.fit_mode="reml", search_fit_mode="fit"selectspunder ordinary ML and then publishes one REML fit at the selectedp, the cost of one smoothing-parameter search rather than one per candidate. Selectingpunder a different objective than the one that publishes it is an approximation, so check it on your own data. Either way the published refit runs at the publication tolerance and re-profiles dispersion against its own mean. A coupled REML search warns when its optimum is pinned against the certifiable-region boundary; a decoupled refit may fail at the selectedpwith asuperglm.PublicationModeErrornaming the ways out, and its likelihood-ratio intervals describe thesearch_fit_modeprofile.- p_boundstuple of float
Search interval for
p, strictly inside(1, 2). An estimate on a bound is warned about and recorded inresult.warnings: a maximum asp -> 1can be an artefact of rounded responses. Nearp = 1the dispersion profile is multimodal and its global search grows like1 / (p - 1); a power whose search would exceed its bound (superglm.NearPoissonDispersionError) is skipped as infeasible and recorded.- xatolfloat
Absolute resolution of the Brent search in
p.- ci_alphafloat, optional
Significance level for an explicitly requested likelihood-ratio profile confidence interval. For example,
0.05computes a 95% interval and caches it formodel.summary(alpha=0.05). The defaultNoneperforms no confidence-interval evaluations. If the searched winner’s fit, or a fit the interval evaluates, did not converge, the interval is still computed, and the cause is warned and recorded inresult.warnings.- max_reml_iterint, optional
Outer-iteration budget for the REML publication refit alone; candidate search fits keep their own budget. Requires
fit_mode="reml"– a pure-ML publication has no REML iteration to budget and refuses the parameter. The defaultNoneresolves asfit_reml’s does, to 20.- progress_callbackcallable, optional
Called as
progress_callback(phase, payload):"profiling"with{"profile_trace": [row]}for each feasible search candidate, then"best_found"and"final_refit"with{"profile_estimate": ...}.