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.
- predictor_rows( )#
Compiled rows in predictor coordinates, or None where these links or rows need
evaluate_natural.shared_lastsays one power serves every row.The rows decline a power at the link’s walls and the family refuses one at its own, so a link whose walls lie outside the family’s keeps the natural route.
- predictor_curvature_directional_derivative(
- y: NDArray,
- eta: NDArray,
- eta_direction: NDArray,
- links: Sequence[Link],
- plan: FamilyLikelihoodPlan,
Differentiate observed predictor curvature along one predictor path.
- predictor_curvature_second_directional_derivative(
- y: NDArray,
- eta: NDArray,
- direction_a: NDArray,
- direction_b: NDArray,
- links: Sequence[Link],
- plan: FamilyLikelihoodPlan,
Differentiate observed predictor curvature twice, along
athenb.Kernel derivatives are in
(mu, rho = log phi, p); the dispersion reachesrhothroughlogof its inverse link, so nophi-scale round trip cancels. A refused row sends the caller to differences.
- cdf(
- y: NDArray,
- theta: NDArray,
P(Y <= y)per row at unit prior weight.
- log_window_probability(lower, upper, theta, weights=None)#
log P(lower < Y <= upper), including the atom iff lower < 0 <= upper.
Optional weights define the reproductive prior law, never replication. Numerical/work refusal is explicit; empty events return -inf.
- 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.