Skip to main content

Module transformation_normal

Module transformation_normal 

Source
Expand description

Conditional transformation model: estimate h(y|x) such that h(Y|x) ~ N(0,1).

Given a response variable y and covariates x with a pre-built covariate design operator, this family estimates a smooth monotone transformation h(y | x) mapping the conditional distribution of Y|x onto a standard normal.

The response-direction basis is [1, I_1(y), ..., I_K(y)], tensored with an arbitrary covariate design operator. Column 0 is an unconstrained location component b(x). The I-spline columns are shape components with squared covariate-side coefficients, giving the SCOP representation h(y, x) = b(x) + ε·(y−median_y) + Σ_k I_k(y) γ_k(x)^2 and h'(y, x) = ε + Σ_k M_k(y) γ_k(x)^2. Monotonicity is structural: the fixed derivative floor ε keeps the change-of-variables log-density away from the log(0) singularity, while the non-negative M-spline basis and squared covariate-side coefficients supply the learned shape.

The log-likelihood per observation is the finite-support normalized change-of-variables density for a standard normal target:

ℓ_i = -½ h_i² + log(h’_i) - log(Φ(h_U(x_i)) - Φ(h_L(x_i)))

where h_i = b(x_i) + ε·(y_i−median_y) + Σ_k I_k(y_i) γ_k(x_i)^2 and h'_i = ε + Σ_k M_k(y_i) γ_k(x_i)^2. The endpoint normalizer is required because the I-spline response basis saturates at finite support values rather than mapping onto the full real line.

Structs§

TransformationNormalConfig
TransformationNormalFamily
Conditional transformation model mapping Y|x to N(0,1).
TransformationNormalFitResult
Result of fit_transformation_normal.
TransformationWarmStart
Optional warm-start for the transformation model: per-observation location and scale values from a prior mean/SD normalizer.

Enums§

TransformationNormalError
Typed errors emitted by the transformation-normal family pipeline.

Constants§

TRANSFORMATION_MONOTONICITY_EPS
Strict-feasibility margin for h' > 0 on the monotonicity grid. Used both by the fit-time fraction-to-boundary line search (so accepted β keeps h'(grid) ≥ EPS) and by the predict-time monotonicity check in inference::predict_input (which rejects predictions whose minimum h' on the response grid drops below this threshold). Keeping these in sync prevents the predict path from rejecting fits that the optimizer accepted as feasible — and vice versa.
TRANSFORMATION_NORMAL_H_ABS_MAX
Absolute bound for feasible transformation scores on the standard-normal scale. The CTN likelihood targets h(Y|x) ~ N(0,1); accepting exact-Newton iterates with finite positive h' but astronomical |h| lets curvature diagnostics overflow into meaningless values. This is a numerical runaway guard, not a statistical plausibility filter: startup seeds can temporarily land outside practically observable normal quantiles before the line search moves them back into the likelihood’s high-density region.

Functions§

build_tensor_psi_derivatives
Build CustomFamilyBlockPsiDerivative objects for the tensor product.
effective_response_num_internal_knots
fit_transformation_normal
Fit a conditional transformation model with N-block spatial length-scale optimization over the covariate side.
transformation_normal_pit_score