Can multiple outcomes be regressed on the same linear model?

Open
#426 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
1-2 days
Newbie friendliness
12/100
Issue type
Documentation
Clarity
Needs clarification
Activity status
Stale
Tech stack
r
Domain
data

Research direction

This is a modeling question, not a code change. The snippet calls ulam with a Poisson likelihood and indexed intercepts and slopes, and it refers to the book's multinomial-as-Poisson decomposition. Start by checking whether the book or package docs already cover indexed multi-category Poisson models, and whether the snippet's indexing is valid. Done means a maintainer-confirmed answer, or a documentation note that addresses the K-category case.

Written by the indexing model from the issue text.

Description

From your book, you mention that a multinomial can be decomposed into several Poisson regression, where each output category gets its own linear model. Say that, instead of 2-3 category outcomes, there are many more (e.g., K=100). Is there a way to regress K-1 outcome categories on the same linear model, i.e., without having to write K-1 linear models?

I'm imagining something like:

Y <- rep(c("A","B","C"), times=c(10,8,6))
Y_ind <- 1:3
x <- c(rnorm(n=10, mean=0, sd=1),
rnorm(n=8, mean=2, sd=1),
rnorm(n=6, mean=5, sd=1))
one_hot <- model.matrix(~ Y - 1)
Y_counts <- colSums(one_hot)

m <- ulam(
alist(
Y_counts[Y_ind] <- dpois(lambda[Y_ind]),
log(lambda[Y_ind]) <- a[Y_ind] + b[Y_ind]*x,
a[Y_ind] ~ dnorm(0,1),
b[Y_ind] ~ dnorm(0,1)
), data=list(Y_counts=Y_counts, Y_ind=Y_ind)
)

Dominant language
R
Stars
2.4k
Forks
632
PR merge metrics
No merged PRs in 30d

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from rmcelreath/rethinking

All issues in rmcelreath/rethinking

Similar issues

More R issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.