rss: Residual Sum of Squares and Explained Variance

Description Usage Arguments Details Value Methods (by generic) Examples

Description

rss and evar are S4 generic functions that respectively computes the Residual Sum of Squares (RSS) and explained variance achieved by a model.

The explained variance for a target V is computed as:

evar = 1 - RSS/sum v_{ij}^2

,

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
rss(object, ...)

## S4 method for signature 'matrix'
rss(object, target)

## S4 method for signature 'ANY'
rss(object, ...)

evar(object, ...)

## S4 method for signature 'ANY'
evar(object, target, ...)

Arguments

object

an R object with a suitable fitted, rss or evar method.

...

extra arguments to allow extension, e.g. passed to rss in evar calls.

target

target matrix

Details

where RSS is the residual sum of squares.

The explained variance is usefull to compare the performance of different models and their ability to accurately reproduce the original target matrix. Note, however, that a possible caveat is that some models explicitly aim at minimizing the RSS (i.e. maximizing the explained variance), while others do not.

Value

a single numeric value

Methods (by generic)

evar:

rss:

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
# RSS bewteeen random matrices
x <- rmatrix(20,10, max=50)
y <- rmatrix(20,10, max=50)
rss(x, y)
rss(x, x + rmatrix(x, max=0.1))

# RSS between an NMF model and a target matrix
x <- rmatrix(20, 10)
y <- rnmf(3, x) # random compatible model
rss(y, x)

# fit a model with nmf(): one should do better
y2 <- nmf(x, 3) # default minimizes the KL-divergence
rss(y2, x)
y2 <- nmf(x, 3, 'lee') # 'lee' minimizes the RSS
rss(y2, x)

renozao/NMF documentation built on June 14, 2020, 9:35 p.m.