Consider the standard linear regression model given by
$Y = XB + \varepsilon$.
$E[Y\mid X] = XB$ if $E[\varepsilon \mid X] = 0$.
We say that the conditional expectation function is a random variable because $X$ is a random variable. But in econometrics textbooks I also read "with non-stochastic regressors, or conditional on $X$..." When we condition on $X$ in $E[Y\mid X] = XB$, is $X$ constant or not? If it is, why is the conditional expectation function a random variable?
$E[Y\mid X = x]$ would be constant not $E[Y\mid X]$, because in the latter we do not consider realisations of $X$ while in the former we do. So what do we mean by that "conditional on $X$ is treating $X$ as constant?
I paste one paragraph from the econometrics book: "If the regressors can be treated as nonstochastic, as they would be in an experimental situation in which the analyst chooses the values in X, then the sampling variance of the least squares estimator can be derived by treating X as a matrix of constants. Alternatively, we can allow X to be stochastic, do the analysis conditionally on the observed X, then consider averaging over X as we did in obtaining (4-6) from (4-5)."
I read this as follows. If X is treated as constant, then there is no need to condition on X. If X is treated as random, then do the derivations conditional on X. So conditioning on X does not mean that X is treated as constant. So does E[Y|X] mean that X is constant? No. X is random, and we just condition on the random X. Conditioning on X does not make X constant. Or am I missing something?