Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can multiple outcomes be regressed on the same linear model? #426

Open
nicklausmillican opened this issue Mar 22, 2024 · 0 comments
Open

Comments

@nicklausmillican
Copy link

nicklausmillican commented Mar 22, 2024

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)
)

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

No branches or pull requests

1 participant