name: regression-model-options
description: Model options beyond the textbook fit — a penalty over a predictor subset (unpenalized), non-negative coefficients (NNLS), per-coefficient prior precision for an experiment-centred prior, the media-mix recipe, and a regression an embedder registered (params, outputs, what it declines). Topical design; per-model params in atomic op-reg-* skills.
type: guide
kind: design
applies_to: process, compose, predict
covers: [unpenalized, bounds, nonnegative, NNLS, prior_precision, prior_mu, custom regression, extension regression, regression params, outputs, media mix]
Regression model options
Reach for these when a plain fit shrinks or signs the wrong things. Model choice: regression-modeling; intervals: regression-inference.
Which option
| Need | Option | Model |
|---|---|---|
| A penalty, but controls or dummies must stay unshrunk | unpenalized: [names] | OLS, GLM, multinomial |
| Slopes that cannot be negative (media spend) | bounds: {nonnegative: [names]} | OLS |
| A prior centred on an experiment for ONE coefficient, flat or weak elsewhere | prior_precision: [..] per coefficient | Bayesian linear |
| A curve or fit no built-in covers | a registered regression | manifest extensions.regressions |
| A known model with no fit (a truth to optimise against) | a models entry with inline coefficients (compose-optimize) | least-squares or media-mix |
unpenalized (penalty subset)
The penalty skips the listed predictors (glmnet penalty.factor 0: never shrunk or dropped); each a listed predictor, once. OLS, GLM and multinomial take it with any penalty; no penalty, a Bayesian fit or a registered model refuse it PROCESSING_CONFIG (predict too).
bounds.nonnegative (NNLS)
Constrains the listed slopes ≥ 0 (Lawson–Hanson; intercept and other slopes stay free; weighted fits work).
- No bound binds: the fit is plain OLS, bit for bit.
- A bound binds: coefficients (held ones exactly 0),
R2,AdjR2andResidualStdErrstand, butStdErrors,PValues, intervals andVcoventries arenulland the result carriesPULSE_ADVISORY_CONSTRAINT_ACTIVE(details.suggested=resample: bootstrap). A bootstrap refits the bounded model per replicate and gives intervals. - Refused: any
penalty,selection, another regression type, a robustcovariance(PROCESSING_REGRESSION_VCOV_UNSUPPORTED). - Predict cannot know if a bound binds: its
p_valuescount is an upper bound.
Per-coefficient prior precision
prior_precision takes a number (ε·I) or an array of predictors + 1 entries, intercept FIRST like prior_mu: Λ₀ = diag. 0 is flat on that coefficient, a large entry pins it to its prior_mu. A wrong length or negative entry is PROCESSING_CONFIG; an improper flat prior PROCESSING_REGRESSION_RANK_DEFICIENT.
Media-mix recipe (one request)
A regression may name a same-request window label. Adstock each channel (a window, partition_by market, order_by week), saturate with hill(x, half, shape) in a post-window attribute, then fit OLS with bounds.nonnegative on the saturated channels and a holdout on the last weeks — one request, no materialize. Sweep the decay with a $var and rank on regressions.<name>.holdout.rmse (compose-sweeps).
- Joint fit:
REG_MMM_HILL(op-reg-mmm-hill) fits each channel’s β and Hillk,stogether, nohill()attribute.REG_MMM_BAYES(op-reg-mmm-bayes) adds decay and ROI intervals. Decay sweep, fit,optimize:mmm-workflow. - Windows-over-records shape only (no
groups/aggregations/crosstab): a grouped shape isPULSE_REGRESSION_WINDOW_UNAVAILABLE(reason: grouped_shape); a slotweightnaming a window label isSERVICE_VALIDATION. A bootstrap does not re-run windows per replicate. - A lag’s first rows are
null: guard a formula withlag ?? 0orx == nil ? nil : …, elsePROCESSING_RUNTIME. Null / NaN / ±Inf rows drop listwise.
holdout (out-of-sample)
"holdout": "week >= 91" (a bool expression) fits on the other rows and reports holdout {n, n_null, rmse, mae, r2} beside the fit, kept by every return preset.
ncounts scored rows;n_nullthe null-predicate rows (neither train nor held out; never fatal). No held-out row: that slot fails alone,PROCESSING_REGRESSION_INSUFFICIENT_DATAreason: holdout_empty.- Penalty,
bounds,selectionandresamplefit on train rows; held-out rows score with the point estimate.nequals the RMSE aggregator’sn_scored(zero / invalid-weight rows out); a NaN / ±Inf target drops. - A registered model needs a scorer (
PULSE_MODEL_SCORE_INVALIDno_scorer). A bad predicate isPULSE_FORMULA_COMPILE_ERROR. Predict: buffered only.
A registered regression
An embedder may register REG_<NS>_<NAME>. The manifest lists it under extensions.regressions; use it like a built-in, plus params.
params: only the declared keys (PULSE_REQUEST_UNKNOWN_FIELDotherwise); a wrong JSON type or a missing required one isPULSE_REQUEST_PARAM_INVALID(details.path,reason). Built-in OLS, GLM, Bayesian, multinomial fits take noparams.outputs: the model’s own figures, keyed by the manifest’soutput_schema(regressions[i].outputs.<key>); a sweep canrankon one.- A shared slot the model did not declare (
penalty,selection,vcov,covariance,save,family,prior, ..) isPROCESSING_CONFIG{regression, slot}. conf_levelandorderalways work,resampleunless the row lists noresampleslot (thenPROCESSING_CONFIG): intervals are estimate ∓ q·SE (t on the model’sdf, else normal; normal on the replicate SE underresample),nullwhere the SE is.selectionneeds the model to declare it.coef("<fit>", "<name>"[, stat])reads any coefficient the fit reports, the model’s own names included, withlower/upperatconf_levelandse. An unknown name isPULSE_MODEL_TERM_UNKNOWN: on a loaded model at predict and run, on afitsentry at run only.- p-values only where the manifest row’s
emits_type_notesays so: otherwisep_valuesisnullthroughout and amultiplicitymethod other thannoneisPULSE_MULTIPLICITY_INVALID. - Scoring (
ATTR_REG_PREDICT) andsaveneed the model to carry a scorer; without one,PULSE_MODEL_SCORE_INVALIDreasonno_scorer. A saved model reloaded where its type is not registered isPULSE_MODEL_REGRESSION_UNREGISTERED.