dims: Dimension of NMF Objects

nbasisR Documentation

Dimension of NMF Objects

Description

The methods dim, nrow, ncol and nbasis return the different dimensions associated with an NMF model.

dim returns all dimensions in a length-3 integer vector: the number of row and columns of the estimated target matrix, as well as the factorization rank (i.e. the number of basis components).

nrow, ncol and nbasis provide separate access to each of these dimensions respectively.

Usage

  nbasis(x, ...)

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

  ## S4 method for signature 'NMFfitXn'
dim(x)

Arguments

x

an object with suitable basis and coef methods, such as an object that inherit from NMF.

...

extra arguments to allow extension.

Details

The NMF package does not implement specific functions nrow and ncol, but rather the S4 method dim for objects of class NMF. This allows the base methods nrow and ncol to directly work with such objects, to get the number of rows and columns of the target matrix estimated by an NMF model.

The function nbasis is a new S4 generic defined in the package NMF, that returns the number of basis components of an object. Its default method should work for any object, that has a suitable basis method defined for its class.

Value

a single integer value or, for dim, a length-3 integer vector, e.g. c(2000, 30, 3) for an NMF model that fits a 2000 x 30 matrix using 3 basis components.

Methods

dim

signature(x = "NMF"): method for NMF objects for the base generic dim. It returns all dimensions in a length-3 integer vector: the number of row and columns of the estimated target matrix, as well as the factorization rank (i.e. the number of basis components).

dim

signature(x = "NMFfitXn"): Returns the dimension common to all fits.

Since all fits have the same dimensions, it returns the dimension of the first fit. This method returns NULL if the object is empty.

nbasis

signature(x = "ANY"): Default method which returns the number of columns of the basis matrix extracted from x using a suitable method basis, or, if the latter is NULL, the value of attributes 'nbasis'.

For NMF models, this also corresponds to the number of rows in the coefficient matrix.

nbasis

signature(x = "NMFfitXn"): Returns the number of basis components common to all fits.

Since all fits have been computed using the same rank, it returns the factorization rank of the first fit. This method returns NULL if the object is empty.


NMF documentation built on Sept. 11, 2024, 8:34 p.m.