nrmse: Normalized root mean squared error

View source: R/nrmse.R

nrmseR Documentation

Normalized root mean squared error

Description

nrmse computes the normalized root mean squared error (NRMSE) for a given complete data matrix xtrue, an imputed matrix ximp, and the corresponding matrix with missing values xmis.

Usage

nrmse(ximp, xmis, xtrue)

Arguments

ximp

Imputed data matrix (or data frame) with variables in columns and observations in rows. Must be numeric and contain no missing values.

xmis

Data matrix (or data frame) with the original missing values. Its dimensions and column order must match ximp and xtrue.

xtrue

Complete data matrix (or data frame). Must be numeric and contain no missing values. Dimensions and column order must match xmis/ximp.

Details

The NRMSE is computed over the entries that were missing in xmis and are numeric in xtrue / ximp, using

\mathrm{NRMSE} = \sqrt{\frac{\mathrm{mean}\{(X_{\mathrm{true}} - X_{\mathrm{imp}})^2\}} {\mathrm{var}(X_{\mathrm{true}})}}\,,

where \mathrm{mean} and \mathrm{var} are the empirical mean and variance computed over the continuous missing entries only. This measure is intended for continuous data; for categorical or mixed-type data, see mixError.

Value

A numeric scalar: the normalized root mean squared error.

Note

This function is used internally by mixError.

Author(s)

Daniel J. Stekhoven [aut, cre]

References

\insertRef

Oba2003missForest

See Also

mixError, missForest

Examples

## Simple numeric example
set.seed(1)
xtrue <- matrix(rnorm(100), ncol = 5)
xmis  <- xtrue
xmis[sample(length(xmis), 10)] <- NA
ximp  <- xmis
ximp[is.na(ximp)] <- rowMeans(ximp, na.rm = TRUE)[row(ximp)[is.na(ximp)]]

nrmse(ximp, xmis, xtrue)

missForest documentation built on Nov. 5, 2025, 6 p.m.