CLINEAR: a slope with hard bounds
When a single coefficient β must satisfy a hard constraint (positive, negative, or inside [a, b]), use 'clinear' instead of a plain linear term. pyINLA enforces the bounds smoothly by reparameterizing β through an unconstrained internal parameter θ.
One slope, plus a guarantee on its sign or range
A normal linear term contributes β zi to the linear predictor, with β free on the entire real line. A clinear term keeps the same contribution but constrains β to a user-specified interval:
Typical uses: a slope you know must be non-negative (a rate, a price, a dose effect), a probability-like coefficient bounded in (0, 1), or any case where domain knowledge gives a hard range you do not want the optimizer to leave.
An unconstrained θ maps to a bounded β
Inference is done on an unconstrained parameter θ; the visible slope β is recovered from θ through one of two transformations, picked automatically from the range tuple you pass:
AOne-sided
Use when β must exceed a known floor (commonly 0). range = (low, float('inf')).
BTwo-sided
Use when β lives in a known interval. σ is the logistic, σ(θ) = eθ/(1+eθ). range = (low, high).
model='linear' instead of 'clinear'. The clinear reparameterization is meant for genuinely bounded slopes.
Force a positive slope in a Poisson rate model
Parameters of the clinear dict
| Key | Required | Description |
|---|---|---|
model | Yes | Must be 'clinear'. |
covariate | Yes | Column name in the dataframe, or an explicit 1D array of values. |
range | Yes | Tuple (low, high). Picks the transformation: see Section 2. Requires low < high. Supported shapes: (low, high) both finite, or (low, float('inf')) with finite low. |
hyper | No | List with exactly one dict, [{prior, param, initial, fixed}], placing a prior on the internal θ. Default: [{"prior": "normal", "param": [1, 10], "initial": 1, "fixed": False}]. |
id | No | Label used in summary_random / summary_hyperpar. Defaults to the value of covariate when it is a column name. |
weights | No | Per-observation weight vector multiplied into the covariate contribution. Length must equal the number of rows. |
diagonal | No | Small constant added to the precision-matrix diagonal for numerical stability. Default 0.0; rarely needed. |
Watch what the default prior implies for your slope
The hyper block places a prior on the unconstrained internal parameter θ. The prior on the actual slope β is induced by the transformation. Three things to keep straight:
Keys inside the hyper dict
| Key | Description |
|---|---|
prior | Prior family for θ: "normal", "loggamma", "flat", "pc", and others. |
param | Parameters of the prior, in that family's order. For "normal": [mean, precision]. |
initial | Starting value for θ in the optimizer. Default 1. |
fixed | If True, pin θ at initial instead of inferring it. Default False. |
Where to find the slope after fitting
- The back-transformed slope β appears in
result.summary_hyperparin the row labeled"Beta for <id>". - The per-observation contribution β zi appears in
result.summary_random[id], one row per observation. - The intercept and any unconstrained linear terms remain in
result.summary_fixedas usual.
If you only need an informative prior (no hard bounds)
control['fixed']: simpler, no reparameterization, and you specify the prior on β directly. See Linear slope priors. Reach for clinear only when the bound is a hard requirement (sign, physical limits, identifiability).