Skip to content

Optimization routines¤

These lower-level routines support GLM fitting. Most CLI and mapping users should construct a model rather than call them directly.

Iteratively reweighted least squares (IRLS)¤

jaxqtl.infer.irls(X: jax.Array, y: jax.Array, offset: jax.Array, eta: jax.Array, family: ExponentialFamily, solver: AbstractLinearSolve, max_iter: int = 1000, tol: float = 0.001, step_size: float = 1.0, disp_init: ScalarLike = 0.0, gtol: float = 0.001) -> SolveResult ¤

Solve a GLM with iteratively reweighted least squares (IRLS).

Arguments:

  • X: Covariate matrix with shape (n, p).
  • y: Outcome vector with shape (n,).
  • offset: Offset vector with shape (n,), or a scalar offset.
  • eta: Initial linear predictor \(\eta\) with shape (n,), excluding the separately supplied offset. IRLS adds the offset when constructing the complete initial predictor.
  • family: GLM family implementing jaxqtl.distribution.ExponentialFamily.
  • solver: Linear solver implementing jaxqtl.infer.AbstractLinearSolve.
  • max_iter: Maximum IRLS iterations.
  • tol: Absolute tolerance on the change in total negative log likelihood. A small change triggers the gradient check; it does not establish convergence on its own.
  • step_size: Initial step size for each IRLS update. Rejected updates are retried with successively halved step sizes.
  • disp_init: Initial dispersion estimate.
  • gtol: Tolerance on the per-observation gradient infinity norm. Coefficient gradients are divided by each design column's root-mean-square magnitude. NB2 also requires a small projected alpha-space gradient, respecting its dispersion bounds. Defaults to 1e-3.

Returns:

A jaxqtl.infer.SolveResult containing fitted coefficients, dispersion, and convergence metadata.

Failure Modes:

converged is false on exhausted backtracking, an iteration limit, or an unchanged nonstationary state.


jaxqtl.infer.lstsq(X: jax.Array, y: jax.Array, solver: AbstractLinearSolve) -> SolveResult ¤

Solve an unweighted least-squares problem.

This is used as a fast path for Gaussian models.

Arguments:

Returns:

A jaxqtl.infer.SolveResult with disp set to 1 and num_iters set to 1.


jaxqtl.infer.SolveResult(builtins.tuple) [source] ¤

Container for IRLS solver outputs.

Attributes:

  • beta: Fitted coefficient vector with shape (p,).
  • num_iters: Number of solver iterations.
  • converged: Boolean convergence indicator.
  • disp: Fitted family dispersion. jaxqtl.infer.lstsq returns 1.

See Gene-level aggregation for Beta-calibration helpers.