TweedieLSS#

class superglm.TweedieLSS(power_lower: float = 1.05, power_upper: float = 1.95)#

Bases: TweediePredictors

Nonnegative responses with mean, dispersion and variance-power predictors.

Declare all three predictors with family.mu(...), family.phi(...) and family.p(...). Their result and offset names are mean, dispersion and power. 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_lower and be less than two. The fitted power stays strictly between the two bounds.

See also

SuperLSS

Construct and fit a model with these predictors.

response_boundaries(
links: Sequence[Link],
) → tuple[tuple[str, ...], ...]#

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 as log mu -> -inf or log phi -> +inf; the power predictor is bounded on its interior walls.

cdf(
y: NDArray,
theta: NDArray,
) → NDArray[float64]#

P(Y <= y) per row at unit prior weight.

quantile(
p: NDArray,
theta: NDArray,
) → NDArray[float64]#

The p-quantile per row at unit prior weight, p inside (0, 1).

cdf_left_limit(
y: NDArray,
theta: NDArray,
weights: NDArray | None = None,
) → NDArray[float64]#

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,
) → NDArray[float64]#

P(Y <= y) per row with a prior weight entering as the dispersion phi / w.

quantile_prior_weighted(
p: NDArray,
theta: NDArray,
weights: NDArray,
) → NDArray[float64]#

The prior-weighted p-quantile per row, p inside (0, 1).

Probabilities at or below the row’s zero mass return the atom itself.

variance(
theta: NDArray,
) → NDArray[float64]#

Var(Y) = phi mu^p per row at unit prior weight.

variance_prior_weighted(
theta: NDArray,
weights: NDArray,
) → NDArray[float64]#

Var(Y) = phi mu^p / w per row: the prior weight enters as phi / w.