I'm attempting to understand Bayesian logistic regression clearly, and I'm uncertain about (among other things) what is the most clear or most correct notation to use. Here is my current attempt at explaining Bayesian logistic regression:
Suppose that we have a large population of objects (such as emails), each of which is described by a feature vector $x \in \mathbb R^p$ and a class label $y \in \{0,1\}$ (spam or not spam, for example). Consider the experiment of selecting an item at random from this population. Let $X$ and $Y$ be the feature vector and the label of the selected item (so $X$ and $Y$ are random variables). The goal of logistic regression is to find an approximation to the function $$ x \mapsto P(Y = 1 \mid X = x). $$
To achieve this goal, logistic regression makes a modeling assumption that there exists a vector $a \in \mathbb R^p$ and a scalar $b \in \mathbb R$ such that $$ P(Y = 1 \mid X = x) = S(a^T x + b), $$ where $S$ is the sigmoid function defined by $$ S(u) = \frac{e^u}{1 + e^{u}}. $$ Logistic regression computes the parameters $a$ and $b$ using maximum likelihood estimation.
However, we can also take a Bayesian approach to estimating $a$ and $b$ by incorporating prior beliefs about the values of $a$ and $b$. The parameters $a$ and $b$ are now viewed as being random variables. To be concrete, let's make the assumption that $b$ and the components of $a$ are independent and normally distributed with mean $0$ and variance $\sigma^2$. The joint PDF of $a$ and $b$ will be denoted by $f_{a,b}$.
Consider the experiment of selecting $n$ objects at random (with replacement) from the population. Let $X_i$ and $Y_i$ be the feature vector and corresponding class label for the $i$th object selected (so $X_i$ and $Y_i$ are random variables). Let $x_i$ and $y_i$ be the specific values of $X_i$ and $Y_i$ that we observe when we collect our training data.
[Here is where I think the notation gets difficult.]
Let $f$ be the PDF of the random variable $(X_1,Y_1,\ldots,X_n,Y_n)$. Let $f_{X_i,Y_i}$ be the joint PDF of $X_i$ and $Y_i$, and let $f_{X_i}$ be the PDF of $X_i$. According to Bayes' theorem, we have
\begin{align*} &\quad f_{a,b}(\hat a, \hat b \mid (X_i,Y_i) = (x_i,y_i) \text{ for } i = 1,\ldots, n) \\ \propto &\quad f(x_1,y_1,\ldots,x_n,y_n \mid a = \hat a, b = \hat b) f_{a,b}(\hat a, \hat b) \\ =&\quad f_{a,b}(\hat a, \hat b) \Pi_{i=1}^n f_{X_i,Y_i}(x_i,y_i \mid a = \hat a, b = \hat b) \\ =&\quad f_{a,b}(\hat a, \hat b) \Pi_{i=1}^n P(Y_i = y_i \mid X_i = x_i, a = \hat a, b = \hat b) f_{X_i}(x_i \mid a = \hat a, b = \hat b) \\ =&\quad f_{a,b}(\hat a, \hat b) \Pi_{i=1}^n P(Y_i = y_i \mid X_i = x_i, a = \hat a, b = \hat b) f_{X_i}(x_i). \\ \end{align*} In the last step, we assumed that $X_i, a$, and $b$ are independent.
Now taking the natural log of the final expression and omitting terms that do not depend on $\hat a$ or $\hat b$, we see that a maximum a posteriori estimate of $a$ and $b$ can be found by maximizing $$ \frac{-\| \hat a \|^2 - \hat b^2}{2 \sigma^2} + \sum_{i=1}^n \log(S(\hat a^T x_i + \hat b)) $$ with respect to $\hat a$ and $\hat b$. This is a convex optimization problem, which can be solved using a method such as gradient ascent. (Further simplifications to the objective function are possible, but I'm not concerned with how to explain the remaining steps.)
Here are some questions:
- Is this derivation correct? Do you see any errors?
- How can the notation be improved, clarified, or simplified? I want the notation to be perfectly correct (by the standards of a mathematician) but also clear.
- I think the statement
Let $f$ be the PDF of the random variable $(X_1,Y_1,\ldots,X_n,Y_n)$
is incorrect because the random variables $Y_i$ are not continuous, so the term "PDF" can't be
used here. How should this statement be rephrased?
I'd be interested in hearing any comments or opinions about how to clarify the above derivation, including comments about picky details or tangential comments.