This function imputes missing values by their conditional mean
impute_conditional_mean(x, mu, Sigma)
Arguments
x: A vector with observations, some of which may be missing (indicated by NA)
mu: A vector with the population means for 'x'. No missing values are allowed here.
Sigma: A matrix describing the population covariance of 'x'
Returns
A vector where missing values for 'x' have been replaced by their conditional mean
Examples
# Define the population meansmu <- c(0,1,2)# Define the covariance of the populationSigma <- diag(1,3)Sigma[1,2]<- Sigma[2,1]<-0.3Sigma[2,3]<- Sigma[3,2]<-0.1Sigma[1,3]<- Sigma[3,1]<--0.2# Generate a 'random' sample from the population that is partially observedx <- c(NA,2,4)# Impute the missing valuesimpute_conditional_mean (x=x, mu=mu, Sigma=Sigma)