# Unbiasedness and OLS Regression

I understand that we say that an estimator is unbiased if its expected value is equal to the population parameter it targets (i.e. if $$\bar X _N$$ is an estimator of the mean over a sample of size $$N$$, then $$E[\bar X_N ] = \mu$$).

However, I recently learned that, in the OLS regression under the model $$y_i = b x_i + a + u_i$$, we say that the estimators $$\hat a$$ and $$\hat b$$ are unbiased if $$E[\hat a | X] = a$$ and $$E[\hat b | X] = b$$.

I am having trouble reconciliation these two ideas. How is it that the idea in the first paragraph (i.e. $$E[\hat b] = b$$) is equivalent to the idea in the second paragraph (i.e. $$E[\hat b | X] = b$$)?

The idea is that $$E[\hat{b}|X]$$ could possibly be a function of $$X$$. For example, we might have an estimator for which $$E[\hat{b}|X] = b +f(X)$$. This would mean our estimator is only unbiased for the draws of data, $$X$$, for which $$f(X)=0$$.

If we have that $$E[\hat{b}|X]$$ is the same constant, $$b$$, for all $$X$$ (mathematically, if $$E[\hat{b}|X]=b$$ for all $$X$$), then regardless of the draw of data, $$X$$, our estimator is unbiased.

$$E[\hat{b}]= E[E[\hat{b}|X]] = E[b] = b$$

They are not equivalent. In the linear regression model (matrix notation), $$y = X\beta + u,$$

the OLS estimator for $$\beta$$ is $$\hat \beta_{OLS} = \beta + (X'X)^{-1}X'u.$$

Then $$\mathbb E\left(\hat \beta_{OLS} \mid X\right) = \beta + (X'X)^{-1}X'\mathbb E\left(u \mid X\right).$$

Under the assumption that is usually called "mean-independence of the error term from the regressors", or "strict exogeneity of the regressors", $$E\left(u \mid X\right)=0,$$

we get

$$\mathbb E\left(\hat \beta_{OLS} \mid X\right) = \beta$$

And as another answer pointed out, we then also get by the law of iterated expectations,

$$\mathbb E\left(\hat \beta_{OLS} \right)= \mathbb E \Big[\mathbb E\left(\hat \beta_{OLS} \mid X\right)\Big] = \mathbb E(\beta) = \beta.$$

The reason that econometrics uses conditional arguments is that with observational data, the regressors are stochastic. But the original framework in which linear regression and least-squares were developed, was controlled experiments, where the regressors were "deterministic", namely, their values were decided upon by the researcher (hence the name "design matrix" that is still used sometimes). There, there was no need to use conditional arguments, because, being deterministic, the regressors were not/could not be characterized by a disgtribution, to have moments, etc.

When we condition on a random variable, we treat it "as though" it is "fixed/deterministic".