Score: Score Columns of a Matrix Containing NAs by its Values

Description Usage Arguments Value Note Author(s) References Examples

View source: R/gapfill.R

Description

Helper function for Predict used to score the columns of a matrix according to their values. The scoring of a given column is done by pair-wise comparisons with all other columns. The comparison of columns is done by pair-wise comparisons of the non-missing values. This procedure is robust to missing values, if all columns of the matrix have a similar (potentially shifted) distribution of values.

Usage

1
Score(mat)

Arguments

mat

Numeric matrix. May contain NA values.

Value

Numeric vector of length ncol(mat).

Note

Interfaces a C++ function. The R package Rcpp is used.

Author(s)

Florian Gerber, flora.fauna.gerber@gmail.com.

References

F. Gerber, R. de Jong, M. E. Schaepman, G. Schaepman-Strub, and R. Furrer (2018) in IEEE Transactions on Geoscience and Remote Sensing, pp. 1-13, doi: 10.1109/TGRS.2017.2785240.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
mat <- rbind(c( 1,  2, NA),
             c(NA, NA,  1),
             c( 2, NA,  3),
             c( 1,  5, NA),
             c(NA,  2,  5))
s <- Score(mat)

## manual calculation in R
Mean <- function(x) mean(x, na.rm = TRUE)
sByHand <- c(Mean(c(Mean(mat[,1] > mat[,2]),
                    Mean(mat[,1] > mat[,3]))),
             Mean(c(Mean(mat[,2] > mat[,1]),
                    Mean(mat[,2] > mat[,3]))),
             Mean(c(Mean(mat[,3] > mat[,1]),
                    Mean(mat[,3] > mat[,2]))))
stopifnot(identical(s, sByHand))

gapfill documentation built on Feb. 12, 2021, 5:06 p.m.