GeneralizedParetoLSS#

class superglm.GeneralizedParetoLSS(shape_lower: float = 0.0, shape_upper: float = 1.0)#

Bases: ScalePredictor, ShapePredictor

Threshold excesses with generalized Pareto scale and shape predictors.

Choose the threshold before fitting and supply the nonnegative excesses as the response. Declare family.scale(...) and family.shape(...). Scale uses a log link; shape uses a bounded logit link. Results use scale and shape in that order.

Parameters:
shape_lowerfloat, default=0.0

Nonnegative lower bound on the tail-shape parameter xi.

shape_upperfloat, default=1.0

Upper bound on xi. Must exceed shape_lower and be at most one. Fitted shape stays strictly between the two bounds.

Notes

The current shape domain gives every row nonnegative, unbounded support and a finite mean. Negative shapes require response-dependent support and are not supported. predict returns the mean excess, scale / (1 - shape). A fit whose shape reaches a wall says so in result_.warnings. The threshold is not a fitted parameter.

censored_recession(
bounds: ResponseBounds,
) → NDArray[bool]#

Every censored row escapes along the scale; one with no upper truncation also escapes along the shape.

At a fixed shape d^2 log f/(dy dpsi) = (1 + xi)/(psi + xi y)^2 > 0, a monotone likelihood ratio in psi, so within any truncation window P(Y > c) rises and P(Y <= c) falls strictly with psi. log S(c) = -log1p(xi c/psi)/xi rises with xi (t^2 D(z) > 0), and so does S(c)/S(a) above a lower truncation bound a: its xi derivative is (L - (u - v))/xi^2 >= 0 with u, v the xi y/(psi + xi y) of c, a and L = log((1 - v)/(1 - u)). The shape walks to its wall. An upper truncation bound b breaks this for the shape: (S(c) - S(b))/(1 - S(b)) can peak at an interior shape.

predictor_curvature_directional_derivative(
y,
eta,
eta_direction,
links,
plan,
) → NDArray[float64]#

Differentiate observed predictor curvature along one predictor path.

predictor_curvature_second_directional_derivative(
y,
eta,
direction_a,
direction_b,
links,
plan,
) → NDArray[float64]#

Differentiate observed predictor curvature twice, along a then b.

walls() → tuple[int, float, float]#

The shape’s index and its two walls.

wall_disclosure(
pressed: tuple[int, int],
clipped: tuple[int, int],
n_rows: int,
*,
unresolved: bool = False,
settled: bool = True,
) → str | None#

Say what a tail shape at each wall does to the fitted law.

pressed counts the rows, at the (lower, upper) wall, that the data press against it; clipped counts the rows the link clipped to its last float inside it, whatever put them there. unresolved says the fit lost the shape’s curvature at clipped rows, along a direction its rank decision dropped or under a step that still presses them. A fit that is not settled stopped before converging, so its outward step does not establish that the data put the shape at the wall.

variance(
theta,
) → NDArray[float64]#

Population variance; infinite when the shape is at least one half.

log_window_probability(
lower,
upper,
theta,
weights=None,
) → NDArray[float64]#

log P(lower < Y <= upper) under each row’s law, from its log survival function.

expected_shortfall(
p,
theta,
) → NDArray[float64]#

E[Y | Y > q_p] for the generalized Pareto excess law.