impute_conditional_mean: Impute missing values by their conditional mean

Description Usage Arguments Value Author(s) Examples

View source: R/imputation.r

Description

This function imputes missing values by their conditional mean

Usage

1

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'

Value

A vector where missing values for 'x' have been replaced by their conditional mean

Author(s)

Thomas Debray <thomas.debray@gmail.com>

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
# Define the population means
mu <- c(0, 1, 2)

# Define the covariance of the population
Sigma <- diag(1,3)
Sigma[1,2] <- Sigma[2,1] <- 0.3 
Sigma[2,3] <- Sigma[3,2] <- 0.1
Sigma[1,3] <- Sigma[3,1] <- -0.2

# Generate a 'random' sample from the population that is partially observed
x <- c(NA, 2, 4)

# Impute the missing values
impute_conditional_mean (x=x, mu=mu, Sigma=Sigma)

metamisc documentation built on Oct. 13, 2021, 3 p.m.