# How can I write a conditional expectation of finite state markov process in matrix notation

NOTE: This question is related to the econometric method explored in the following two questions:

QUESTION: Suppose that $X_t$ is an $n$-state Markov chain with transition probability matrix $\mathbb P$ and realized values given by $n$-dimensional coordinate vectors. Suppose that $\{W_{t+1} \}$ is an iid sequence of multivariate normally distributed random vectors. How would I represent an equation of the form $$E[\exp(D'X_t + X_t' F W_{t+1}) e(X_{t+1}) \mid X_t = x] = \exp(\eta) e(x)$$ as an eigenvector problem for a matrix $\mathbb M$? How can I represent $\mathbb M$ in terms of the primitives of the problem?

Let the $n$ states of the finite-state markov chain be denoted by $\{x_1,...,x_n\}$ and let $\vec e = [e(x_1), ..., e(x_n)]'$. Now, first note that because $X_{t+1} \mid X_t$ is independent of $W_{t+1}$, we can write \begin{align*} \exp(\eta) e(x) &= E[\exp(D'x + x' F W_{t+1})] E[ e(X_{t+1}) \mid X_t = x] \\ &= \exp(D'x + x' F F' x)\, E[ e(X_{t+1}) \mid X_t = x] . \end{align*} Then, because this must hold for all values $x= x_1, ..., x_n$, we can assemble the following vector equation, \begin{align*} \vec e \, \exp(\eta) &= \begin{bmatrix} \exp(D'x_1 + x_1' F F' x_1)\, E[ e(X_{t+1}) \mid X_t = x_1] \\ ... \\ \exp(D'x_n + x_n' F F' x_n)\, E[ e(X_{t+1}) \mid X_t = x_n] \\ \end{bmatrix}\\ &= \text{diag} \begin{bmatrix} \exp(D'x_1 + x_1' F F' x_1) \\ ... \\ \exp(D'x_n + x_n' F F' x_n) \\ \end{bmatrix} \, \mathbb P \, \vec e \\ &= \text{diag}(f)\, \mathbb P \, \vec e \\ \end{align*} where $f = [ \exp(D'x_1 + x_1' F F' x_1), ..., \exp(D'x_n + x_n' F F' x_n) ]'$ and $\text{diag}$ is the operator that takes a vector and places it on the diagonal of a matrix where the off-diagonal elements are zero. So, we can express the equation as a linear operator $\mathbb M$ on $\vec e$ with \begin{align*} \text{diag}(f)\, \mathbb P \, \vec e &= \vec e \, \exp(\eta) \\ \mathbb M \vec e &= \vec e \, \exp(\eta). \end{align*}