(Note: Question has been significantly edited to try to make question more clear).
Suppose I want to solve $$\max_x E[f(x,u)]$$, where $f$ is a function such that I can interchange derivatives and expectation.
Can I pull $x$ terms out of the expectation. I.e. can I rewrite terms such as $E[xu]$ or $E[xu^2]$ as $E[x]E[u]$ and $E[x]E[u^2]$ respectively? If so, why? (seeking intuitive or mathematical explanation, preferably mathematical)
- If there are conditions under which I can do this, what are the conditions?
Original question below double horizontal rule
(If it helps assume that $u$ is normally distributed. But if this is a necessary assumption please give me a hint or explanation about why)
Suppose I was to find the $x$ that solves $$\max_x E[-(x-u)^3]$$
The function inside the expectation is "smooth" so I should be able to exchange derivatives and expectations, so I figure I can just solve this by taking a FOC.
The FOC is
$$E[-3(x-u)^2] = -3 E[x^2 - 2xu +u^2]=0$$
How can I deal with the $x^2$ and $xu$ terms in this expectation?
My confusion comes from the fact that If $x$ can be a function of $u$ then I don't think I can just pull it out of the expectation? (because it will be a random variable itself then?)
If I can just pull $x$ out of the expectation -- perhaps it is not a function of $u$ because of the expectation? -- why can I do this?
Edit:
Since It is a cubic function I guess there might not be a max? If this is the case then consider if it was a quartic instead.
What I am trying to understand is 1) How can I deal with $x$ and $x*u$ terms in this expectation when I am maximizing over $x$, since I am concerned that $x$ might be a function of $u$
Edit 2:
I guess upon further thinking $x$ being a function of $u$ doesn't make sense since $u$ does not take a particular value. However, how could I see this mathematically?
There is no need of interchanging derivatives and expectations here. Due to linearity of the expectation we have:
$$\begin{align*}f(x) := E[-(x-u)^3] &= -\left(x^3 - 3x^2E[u] + 3E[u^2]x - E[u^3]\right) \\ &= -\left(x^3 + 3\sigma^2x - E[u^3]\right)\end{align*}$$
Consider that $E[u^3]$ and $\sigma$ are now constants w.r.t $x$ hence now you can calculate $\max\limits_{x} f(x)$ with the standard way of finding a maximum of a function (or you can see easily that having no restrictions on $x$ no such maximum exists...)