# NOT RUN {
# Import data.
fname <- system.file("extdata", "finndiane.txt", package = "Numero")
dataset <- read.delim(file = fname)
# Convert identities to strings (produces a warning later).
ds <- dataset
ds$INDEX <- paste("K", ds$INDEX, sep=".")
# Introduce missing values to cholesterol.
missing <- seq(from = 1, to = nrow(ds), length.out = 40)
missing <- unique(round(missing))
ds$CHOL[missing] <- NA
# Impute missing values with and without standardization.
ds.std <- nroImpute(data = ds, standard = TRUE)
ds.orig <- nroImpute(data = ds, standard = FALSE)
# Compare against "true" cholesterol values.
rho.std <- cor(ds.std$CHOL[missing], dataset$CHOL[missing])
rho.orig <- cor(ds.orig$CHOL[missing], dataset$CHOL[missing])
cat("Correlation, standard = TRUE: ", rho.std, "\n", sep="")
cat("Correlation, standard = FALSE: ", rho.orig, "\n", sep="")
# }
Run the code above in your browser using DataLab