  Consider a communication system in which a single antenna user equipment
exchanges information with a multi-antenna base station via a reconfigurable
intelligent surface (RIS) in the presence of spatially correlated channels and
electromagnetic interference (EMI). To exploit the attractive advantages of RIS
technology, accurate configuration of its reflecting elements is crucial. In
this paper, we use statistical knowledge of channels and EMI to optimize the
RIS elements for i) accurate channel estimation and ii) reliable data
transmission. In both cases, our goal is to determine the RIS coefficients that
minimize the mean square error, resulting in the formulation of two non-convex
problems that share the same structure. To solve these two problems, we present
an alternating optimization approach that reliably converges to a locally
optimal solution. The incorporation of the diagonally scaled steepest descent
algorithm, derived from Newton's method, ensures fast convergence with
manageable complexity. Numerical results demonstrate the effectiveness of the
proposed method under various propagation conditions. Notably, it shows
significant advantages over existing alternatives that depend on a sub-optimal
configuration of the RIS and are derived on the basis of different criteria.
