# How to regress two categorical variables

I'm not looking for a detailed answer, just some pointers towards possible things I could read to better understand this problem.

Let's say that we have a survey that asks two questions, $X$ and $Y$. How do you regress $Y$ against $X$? I know that if $Y$ is binary you can use logistic regression, but generally, how do you regress an unordered $Y$ against an unordered $X$? Ordered $Y$ against unordered $X$? Unordered $Y$ against ordered $X$? Ordered $Y$ against Ordered $X$?

I'm working on some survey analysis software, and in it I attempt to predict $Y$ with $X$ using the following method:

Suppose $X$ has $X_1,\cdots, X_n$ responses, and $Y$ has $Y_1,\cdots,Y_m$ responses. Then I calculate a matrix, where the $[i,j]$ element is $\mathbb{P}(Y_i|X_j)$. I then have the user enter in a hypothetical response distribution for $X$ (so new $X_1,\cdots, X_n$, call it $X_{new_1},\cdots,X_{new_n}$). Then if you multiply the matrix by this column vector, you get a new distribution for the $Y$ response variable.

I'm really not sure how good this method is, and I was very careful to propagate error with each operation (each $\mathbb{P}(Y_i|X_j)$ has a confidence interval) to try not to mislead people, but I came up with this method on my own and it seems too simple.