GeneralizedParetoLSS#
- class superglm.GeneralizedParetoLSS(shape_lower: float = 0.0, shape_upper: float = 1.0)#
Bases:
ScalePredictor,ShapePredictorThreshold excesses with generalized Pareto scale and shape predictors.
Choose the threshold before fitting and supply the nonnegative excesses as the response. Declare
family.scale(...)andfamily.shape(...). Scale uses a log link; shape uses a bounded logit link. Results usescaleandshapein 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_lowerand 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.
predictreturns the mean excess,scale / (1 - shape). A fit whose shape reaches a wall says so inresult_.warnings. The threshold is not a fitted parameter.- censored_recession(
- bounds: ResponseBounds,
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 inpsi, so within any truncation windowP(Y > c)rises andP(Y <= c)falls strictly withpsi.log S(c) = -log1p(xi c/psi)/xirises withxi(t^2 D(z) > 0), and so doesS(c)/S(a)above a lower truncation bounda: itsxiderivative is(L - (u - v))/xi^2 >= 0withu, vthexi y/(psi + xi y)ofc, aandL = log((1 - v)/(1 - u)). The shape walks to its wall. An upper truncation boundbbreaks 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,
Differentiate observed predictor curvature along one predictor path.
- predictor_curvature_second_directional_derivative(
- y,
- eta,
- direction_a,
- direction_b,
- links,
- plan,
Differentiate observed predictor curvature twice, along
athenb.
- wall_disclosure(
- pressed: tuple[int, int],
- clipped: tuple[int, int],
- n_rows: int,
- *,
- unresolved: bool = False,
- settled: bool = True,
Say what a tail shape at each wall does to the fitted law.
pressedcounts the rows, at the (lower, upper) wall, that the data press against it;clippedcounts the rows the link clipped to its last float inside it, whatever put them there.unresolvedsays 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 notsettledstopped before converging, so its outward step does not establish that the data put the shape at the wall.
- variance(
- theta,
Population variance; infinite when the shape is at least one half.
- log_window_probability(
- lower,
- upper,
- theta,
- weights=None,
log P(lower < Y <= upper)under each row’s law, from its log survival function.
- expected_shortfall(
- p,
- theta,
E[Y | Y > q_p]for the generalized Pareto excess law.