TweedieLSS#
- class superglm.TweedieLSS(power_lower: float = 1.05, power_upper: float = 1.95)#
Bases:
TweediePredictorsNonnegative responses with mean, dispersion and variance-power predictors.
Declare all three predictors with
family.mu(...),family.phi(...)andfamily.p(...). Their result and offset names aremean,dispersionandpower. The mean and dispersion use log links; power uses a bounded link between the configured limits.For power between one and two, the distribution has a point mass at zero and a continuous positive part. At unit prior weight, variance is
dispersion * mean**power.- Parameters:
- power_lowerfloat, default=1.05
Lower bound on fitted power. Must be greater than one.
- power_upperfloat, default=1.95
Upper bound on fitted power. Must exceed
power_lowerand be less than two. The fitted power stays strictly between the two bounds.
See also
SuperLSSConstruct and fit a model with these predictors.
- response_boundaries(
- links: Sequence[Link],
All-zero rows drive the mean to 0 (log link) or the dispersion to infinity.
With every response at zero the row log-likelihood is
-w mu^(2-p) / (phi (2-p)), which increases without bound aslog mu -> -inforlog phi -> +inf; the power predictor is bounded on its interior walls.
- cdf(
- y: NDArray,
- theta: NDArray,
P(Y <= y)per row at unit prior weight.
- quantile(
- p: NDArray,
- theta: NDArray,
The
p-quantile per row at unit prior weight,pinside(0, 1).
- cdf_left_limit(
- y: NDArray,
- theta: NDArray,
- weights: NDArray | None = None,
P(Y < y)per row: zero on the atom at zero,P(Y <= y)above it.The atom interval a randomised PIT samples on a zero row is therefore
[0, P(Y = 0)]; the law is continuous everywhere else.
- cdf_prior_weighted(
- y: NDArray,
- theta: NDArray,
- weights: NDArray,
P(Y <= y)per row with a prior weight entering as the dispersionphi / w.
- quantile_prior_weighted(
- p: NDArray,
- theta: NDArray,
- weights: NDArray,
The prior-weighted
p-quantile per row,pinside(0, 1).Probabilities at or below the row’s zero mass return the atom itself.
- variance(
- theta: NDArray,
Var(Y) = phi mu^pper row at unit prior weight.
- variance_prior_weighted(
- theta: NDArray,
- weights: NDArray,
Var(Y) = phi mu^p / wper row: the prior weight enters asphi / w.