Question: Linear Regression for iid sample (Y,X).

$E(\epsilon\_i^2|X)=E(\epsilon\_i^2|x\_i)$, where $x\_i$ is the i-th observation of k regressors, and epsilon is the error term.

The book I'm using states that from an iid sample we can deduce that $E(\epsilon\_i^2)$ is constant across i, and also the functional form of $E(\epsilon\_i^2|x\_i)$ across i.

However, the value of $E(\epsilon\_i^2|x\_i)$ is not the same across i. Why is this?

Any help would be appreciated.

Answer: 
Since this is linear regression, we *assume* the relation

$$y\_i = \mathbf x\_i'\beta + \epsilon\_i,\;\; \forall i$$

and so the i.i.d. sample of size $n$ is, given our assumption, a collection of observations

$$\{y\_i,\mathbf x\_i\}\_{\{i\in [1,n]\}} = \{\mathbf x\_i'\beta + \epsilon\_i,\mathbf x\_i\}\_{\{i\in [1,n]\}}$$

Note that we consider the statement "i.i.d. sample" to pertain to the *joint distribution of the sample*, i.e. of the $y$'s and the $\mathbf x\_i$'s. This is the approach usually adopted in Econometrics (see for example [Hayashi (2000) ch 1 p. 12](http://press.princeton.edu/chapters/s6946.pdf) - **legally downloadable**). Viewed in this light, the "i.i.d. assumption" has some implications for the marginal distribution of the errors, as well as for autocorrelation (it implies no-autocorrelation of the errors), but it does not cover conditional homo/heteroskedasticity.

Specifically, if the sample is (or we assume it to be) i.i.d., then due to the assumed decomposition of $y\_i$, it follows from the above that the $\epsilon\_i$'s are i.i.d. and so 
$$E(\epsilon\_i^2) = E(\epsilon\_j^2),\;\; \forall i,j \in [1,n]$$

Also

$$E(\epsilon\_i^2 \mid \mathbf x\_i) = E((y\_i - \mathbf x\_i'\beta)^2 \mid \mathbf x\_i) = E(y\_i^2 - 2y\_i\mathbf x\_i'\beta+ (\mathbf x\_i'\beta)^2 \mid \mathbf x\_i)$$

$$=E(y\_i^2 \mid\mathbf x\_i) - 2\mathbf x\_i'\beta E(y\_i \mid \mathbf x\_i) + (\mathbf x\_i'\beta)^2 $$

The $\mathbf x\_i$'s may be i.i.d. but this does not mean that each actual realization is identical (this would turn the regressors into constants). So, *without further assumptions*, in general we will have 

$$E(\epsilon\_i^2\mid\mathbf x\_i ) \neq E(\epsilon\_j^2\mid\mathbf x\_j),\;\; i,j \in [1,n]$$

In other words conditional homoskedasticity must be imposed as an *additional* assumption. Note also that the assumption of strict exogeneity (or mean-independence) of the error vector with respect to the regressor matrix, $E(\epsilon \mid \mathbf X) = 0$, which for an i.i.d. sample is equivalent to $E(\epsilon\_i \mid \mathbf x\_i) = 0,\; \forall i$, does not bring about conditional homoskedasticity, the latter remaining a distinct assumption.
> 
> However, the value of $E(\epsilon\_i^2|x\_i)$ is not the same across i.
>  Why is this?
> 
> 
> 

Let's first clarify that your book is most likely talking about the errors, not the residuals. The difference is that the former is not observable, while the latter is. Regression assumes that the *true* model is $y=X\beta+\varepsilon$, where $\varepsilon$ is a random *error*. It's not observable. 

The regression modeling will try to estimate the coefficients, and will come up with $y=Xb+e$, where $b$ is the estimated coefficients, and $e$ - residuals (estimated error). You are hoping that at least $X$ is correct, i.e. that you added all the true predictors, and didn't add wrong predictors. You hope that your model is correctly specified, then go ahead with estimating $b$ and $e$. Note, that at any moment you **do not** observe true errors $\varepsilon$. Therefore, your statement above seems to be stemming from confusion of errors and residuals. You can't really state that expectations of errors are correlated with predictors, because you don't observe them. You don't observe erros, and it's even less observable are their expectations. You can suspect that they are, and run some tests on *residuals* to support your suspicion.

The residuals are observable, of course. You estimated them. How are you going to estimate the expectation of residuals like in your statement above? You observe individual residuals $e\_i$, but how would get $E[e\_i]$? On the other hand $E[e|X]=0$ is guaranteed by the regression. It's just how the regression works: it will estimate residuals in such a way that this will be held true.