Regression on Inferred Variables

Given a set of labels $y$ and design matrix $X$ we often compute a linear regression to find a set of parameters $\hat{\beta}$ such that $E[y|X] = X\hat{\beta}$. However, how does one perform regression when $X$ itself must be inferred conditioned on an observed set of data $O$?

Specifically, suppose we are given posterior probabilities for discrete values for each $x_i$ conditioned on $O$. Do there exist regression methods to take this uncertainty into account? A naive approach might just take the posterior mean for each $x_i$, but a more holistic approach may integrate over the posterior while performing the regression, that is find $\hat{\beta}$ for $E[E[y|X]|O]$.

If you know of references that would be great.