Various error measures evaluating the quality of imputations
evaluation(x, y, m, vartypes = "guess")
nrmse(x, y, m)
pfc(x, y, m)
msecov(x, y)
msecor(x, y)
matrix or data frame
matrix or data frame of the same size as x
the indicator matrix for missing cells
a vector of length ncol(x) specifying the variables types, like factor or numeric
the error measures value
This function has been mainly written for procudures that evaluate imputation or replacement of rounded zeros. The ni parameter can thus, e.g. be used for expressing the number of rounded zeros.
M. Templ, A. Kowarik, P. Filzmoser (2011) Iterative stepwise regression imputation using standard and robust methods. Journal of Computational Statistics and Data Analysis, Vol. 55, pp. 2793-2806.
data(iris)
iris_orig <- iris_imp <- iris
iris_imp$Sepal.Length[sample(1:nrow(iris), 10)] <- NA
iris_imp$Sepal.Width[sample(1:nrow(iris), 10)] <- NA
iris_imp$Species[sample(1:nrow(iris), 10)] <- NA
m <- is.na(iris_imp)
iris_imp <- kNN(iris_imp, imp_var = FALSE)
#> Sepal.Width Petal.Length Petal.Width Sepal.Width Petal.Length Petal.Width
#> 2.0 1.0 0.1 4.4 6.9 2.5
#> Sepal.Length Petal.Length Petal.Width Sepal.Length Petal.Length Petal.Width
#> 4.3 1.0 0.1 7.9 6.9 2.5
#> Sepal.Length Sepal.Width Petal.Length Petal.Width Sepal.Length Sepal.Width
#> 4.3 2.0 1.0 0.1 7.9 4.4
#> Petal.Length Petal.Width
#> 6.9 2.5
evaluation(iris_orig, iris_imp, m = m, vartypes = c(rep("numeric", 4), "factor"))
#> $err_num
#> [1] 0.149
#>
#> $err_cat
#> [1] 0
#>
#> $error
#> [1] 0.149
#>
msecov(iris_orig[, 1:4], iris_imp[, 1:4])
#> [1] 0.0001986385