Learn R Programming

FuzzyImputationTest (version 0.5.0)

ErrorMatrix: Calculation of the errors for the imputed values.

Description

`ErrorMatrix` calculates the various types of the errors between two datasets -- the true and the imputed one.

Usage

ErrorMatrix(trueData, imputedData, imputedMask, trapezoidal = TRUE, ...)

Value

The output is given as a matrix (the rows are related to various types of the errors, the columns - to the variables).

Arguments

trueData

Name of the input matrix (or data frame, or list) with the true values of the variables.

imputedData

Name of the input matrix (or data frame) with the imputed values.

imputedMask

Matrix (or data frame) with logical values where TRUE indicates the cells with the imputed values.

trapezoidal

Logical value depending on the type of fuzzy values (triangular or trapezoidal ones) in the dataset.

...

Additional parameters passed to other functions.

Details

The procedure calculates different types of the errors (MAE - the mean absolute error, WMA - the weighted mean absolute error, MSE - the mean squared error, WMSE - the weighted mean squared error, NRMSE - the normalized root mean squared error) between two datasets - the first one with true values (set by trueData), and the second one (specified by imputedData) with the imputed variables. To properly distinguish the real values with their imputed counterparts, the additional matrix imputedMask should be provided. In this matrix, the logical value TRUE points out the cells with the imputed values. Otherwise, FALSE should be used.

All of the input datasets can be given as matrices or data frames.

Examples

Run this code

# seed PRNG

set.seed(1234)

# load the necessary library

library(FuzzySimRes)

# generate sample of trapezoidal fuzzy numbers with FuzzySimRes library

list1<-SimulateSample(20,originalPD="rnorm",parOriginalPD=list(mean=0,sd=1),
incrCorePD="rexp", parIncrCorePD=list(rate=2),
suppLeftPD="runif",parSuppLeftPD=list(min=0,max=0.6),
suppRightPD="runif", parSuppRightPD=list(min=0,max=0.6),
type="trapezoidal")

# convert fuzzy data into a matrix

matrix1 <- FuzzyNumbersToMatrix(list1$value)

# check starting values

head(matrix1)

# add some NAs to the matrix

matrix1NA <- IntroducingNA(matrix1,percentage = 0.1)

head(matrix1NA)

# impute missing values

matrix1DImp <- ImputationDimp(matrix1NA)

# find cells with NAs

matrix1Mask <- is.na(matrix1NA)

# calculate errors for the imputed values

ErrorMatrix(matrix1,matrix1DImp,matrix1Mask)



Run the code above in your browser using DataLab