basis-coef-methods: Accessing NMF Factors

Description Usage Arguments Details Methods (by generic) See Also Examples

Description

basis and basis<- are S4 generic functions which respectively extract and set the matrix of basis components of an NMF model (i.e. the first matrix factor).

The methods .basis, .coef and their replacement versions are implemented as pure virtual methods for the interface class NMF, meaning that concrete NMF models must provide a definition for their corresponding class (i.e. sub-classes of class NMF). See NMF for more details.

The method loadings is identical to basis, but do not accept any extra argument.

coef and coef<- respectively extract and set the coefficient matrix of an NMF model (i.e. the second matrix factor). For example, in the case of the standard NMF model V ~ W H, the method coef will return the matrix H.

Methods coefficients and coefficients<- are simple aliases for methods coef and coef<- respectively.

scoef is similar to coef, but returns the mixture coefficient matrix of an NMF model, with the columns scaled so that they sum up to a given value (1 by default).

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
basis(object, ...)

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

## S4 method for signature 'NMF'
basis(object, ..., all = TRUE)

.basis(object, ...)

basis(object, ...) <- value

## S4 replacement method for signature 'NMF'
basis(object, ..., use.dimnames = TRUE) <- value

.basis(object, ...) <- value

## S4 method for signature 'NMF'
loadings(x)

coef(object, ...)

## S4 method for signature 'NMF'
coef(object, ..., all = TRUE)

.coef(object, ...)

coef(object, ...) <- value

## S4 replacement method for signature 'NMF'
coef(object, ..., use.dimnames = TRUE) <- value

.coef(object, ...) <- value

coefficients(object, ...)

## S4 method for signature 'NMF'
coefficients(object, ..., all = TRUE)

scoef(object, ...)

## S4 method for signature 'matrix'
scoef(object, scale = 1)

## S4 method for signature 'NMFfitXn'
coef(object, ...)

## S4 method for signature 'NMFfitXn'
basis(object, ...)

Arguments

object

an object from which to extract the factor matrices, typically an object of class NMF.

...

extra arguments to allow extension and passed to the low-level access functions .coef and .basis.

Note that these throw an error if used in replacement functions .

all

a logical that indicates whether the complete matrix factor should be returned (TRUE) or only the non-fixed part. This is relevant only for formula-based NMF models that include fixed basis or coefficient terms.

value

replacement value

use.dimnames

logical that indicates if the object's dim names should be set using those from the new value, or left unchanged – after truncating them to fit new dimensions if necessary. This is useful to only set the entries of a factor.

x

an object of class NMF

scale

scaling factor, which indicates to the value the columns of the coefficient matrix should sum up to.

Details

For example, in the case of the standard NMF model V ~ W H, the method basis will return the matrix W.

basis and basis<- are defined for the top virtual class NMF only, and rely internally on the low-level S4 generics .basis and .basis<- respectively that effectively extract/set the coefficient data. These data are post/pre-processed, e.g., to extract/set only their non-fixed terms or check dimension compatibility.

The method loadings is provided to standardise the NMF interface against the one defined in the stats package, and emphasises the similarities between NMF and PCA or factorial analysis (see loadings).

coef and coef<- are S4 methods defined for the corresponding generic functions from package stats (See stats::coef). Similarly to basis and basis<-, they are defined for the top virtual class NMF only, and rely internally on the S4 generics .coef and .coef<- respectively that effectively extract/set the coefficient data. These data are post/pre-processed, e.g., to extract/set only their non-fixed terms or check dimension compatibility.

Methods (by generic)

.basis:

.basis<-:

.coef:

.coef<-:

basis:

basis<-:

coef:

coef<-:

coefficients:

See Also

Other NMF-interface: NMF-class, nmfModel(), rnmf()

Examples

1
2
3
4
# Scaled coefficient matrix
x <- rnmf(3, 10, 5)
scoef(x)
scoef(x, 100)

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