Description Usage Arguments Details Value Methods (by generic) Examples
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
,
1 2 3 4 5 6 7 8 9 10 11 12 |
object |
an R object with a suitable |
... |
extra arguments to allow extension, e.g. passed to |
target |
target matrix |
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.
a single numeric value
evar:
evar(object = ANY)
: Default method for evar
.
It requires a suitable rss
method to be defined
for object
, as it internally calls rss(object, target, ...)
.
rss:
rss(object = matrix)
: Computes the RSS between a target matrix and its estimate object
,
which must be a matrix of the same dimensions as target
.
The RSS between a target matrix V and its estimate v is computed as:
RSS = ∑_{i,j} (v_{ij} - V_{ij})^2
Internally, the computation is performed using an optimised C++ implementation, that is light in memory usage.
rss(object = ANY)
: Residual sum of square between a given target matrix and a model that has a
suitable fitted
method.
It is equivalent to rss(fitted(object), ...)
In the context of NMF, Hutchins2008 used the variation of the RSS
in combination with the algorithm from Lee1999 to estimate the
correct number of basis vectors.
The optimal rank is chosen where the graph of the RSS first shows an inflexion
point, i.e. using a screeplot-type criterium.
See section Rank estimation in nmf
.
Note that this way of estimation may not be suitable for all models. Indeed, if the NMF optimisation problem is not based on the Frobenius norm, the RSS is not directly linked to the quality of approximation of the NMF model. However, it is often the case that it still decreases with the rank.
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)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.