Testing NMF Objects

Description

The functions documented here tests different characteristics of NMF objects.

is.nmf tests if an object is an NMF model or a class that extends the class NMF.

hasBasis tests whether an objects contains a basis matrix -- returned by a suitable method basis -- with at least one row.

hasBasis tests whether an objects contains a coefficient matrix -- returned by a suitable method coef -- with at least one column.

is.partial.nmf tests whether an NMF model object contains either an empty basis or coefficient matrix. It is a shorcut for !hasCoef(x) || !hasBasis(x).

Usage

is.nmf(x)

is.empty.nmf(x, ...)

hasBasis(x)

hasCoef(x)

is.partial.nmf(x)

isNMFfit(object, recursive = TRUE)

Arguments

x
an R object. See section Details, for how each function uses this argument.
...
extra parameters to allow extension or passed to subsequent calls
object
any R object.
recursive
if TRUE and object is a plain list then isNMFfit tests each element of the list. Note that the recursive test only applies in the case of lists that are not themselves NMFfit objects, like NMFfitXn objects for which the result of isNMFfit will always be TRUE, although they are list objects (a single logical value).

Value

isNMFfit returns a logical vector (or a list if object is a list of list) of the same length as object.

Details

is.nmf tests if object is the name of a class (if a character string), or inherits from a class, that extends NMF-class.

is.empty.nmf returns TRUE if the basis and coefficient matrices of x have respectively zero rows and zero columns. It returns FALSE otherwise.

In particular, this means that an empty model can still have a non-zero number of basis components, i.e. a factorization rank that is not null. This happens, for example, in the case of NMF models created calling the factory method nmfModel with a value only for the factorization rank.

isNMFfit checks if object inherits from class NMFfit-class or NMFfitX-class, which are the two types of objects returned by the function nmf. If object is a plain list and recursive=TRUE, then the test is performed on each element of the list, and the return value is a logical vector (or a list if object is a list of list) of the same length as object.

Note

The function is.nmf does some extra work with the namespace as this function needs to return correct results even when called in .onLoad. See discussion on r-devel: https://stat.ethz.ch/pipermail/r-devel/2011-June/061357.html