Skip to content

Outcome: an offset for each response of a multi-response model - #7

Merged
jonathan-taylor merged 1 commit into
mainfrom
multiresponse-offset
Oct 27, 2026
Merged

jonathan-taylor merged 1 commit into
mainfrom
multiresponse-offset

Conversation

@jonathan-taylor

@jonathan-taylor jonathan-taylor commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

For 0.4.0: offsets of multi-response models, with as many columns as the full response.

Outcome(['y1', 'y2', 'y3'], offset='O')
# -> y1, y2, y3, offset                      one offset, the same for every response

Outcome(['y1', 'y2', 'y3'], offset={'y1': 'O1', 'y2': 'O2', 'y3': log_exposure})
# -> y1, y2, y3, offset[y1], offset[y2], offset[y3]

Outcome(Multinomial('kind'), offset={'lo': 'O_lo', 'mid': 'O_mid', 'hi': 'O_hi'})
# -> kind, offset[lo], offset[mid], offset[hi]
  • A dict gives one column for each response. Its keys are the responses: the columns of a list of columns, or the classes of a Multinomial. For a multinomial the keys are its levels whether its output is labels or one-hot, so glmstar can take either form; for a Multinomial of counts, they are its count columns. Each value is a column or a single-column feature, as before.
  • Keys rather than positions, so an offset can't end up in the wrong column silently. The offset[...] columns follow the order of the responses, whatever the dict's order. A missing or unknown key raises, as does a dict for a response with a single linear predictor (a column, Surv, Binomial).
  • A list of columns is now a response of Outcome: the responses of a multi-response model.
  • Unchanged: a single column (offset='O') stays one column, offset, which glmstar broadcasts to every response. transform(X, response=False) gives the (n, k) offsets of new data. wildcard(exclude=outcome) leaves out every source column.

For glmstar: a column offset is broadcast to every response, and columns offset[...] are one per response, in the response's order. If both are present, glmstar should raise an error.

Tests: six new tests in tests/test_outcome.py: dict order vs response order, a feature as a value, offsets of new data, multinomial labels and one-hot, counts, errors, polars. The full suite gives 282 passed and 5 strict xfails, and the docs page executes.

🤖 Generated with Claude Code

- A keyword given as a dict gives one column for each response, keyed
  by the responses: the columns of a list of columns (a new response of
  Outcome) or the classes of a Multinomial, whatever its output.
  offset={'y1': 'O1', 'y2': 'O2'} gives offset[y1] and offset[y2], in
  the order of the responses; a missing or unknown key raises, as does
  a dict for a response with a single linear predictor.
- A single column is unchanged: the same offset for every response.
- Docs: a multinomial example in the Outcome section.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@jonathan-taylor
jonathan-taylor merged commit 3acfcf2 into main Oct 27, 2026
2 checks passed
@jonathan-taylor
jonathan-taylor deleted the multiresponse-offset branch October 27, 2026 00:05
@jonathan-taylor jonathan-taylor changed the title Outcome: an offset for each response of a multi-response model Outcome: an offset (or weights) for each response of a multi-response model Oct 27, 2026
@jonathan-taylor jonathan-taylor changed the title Outcome: an offset (or weights) for each response of a multi-response model Outcome: an offset for each response of a multi-response model Oct 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant