- rnmf
signature(x = "NMFOffset", target =
"numeric")
: Generates a random NMF model with offset,
from class NMFOffset
.
The offset values are drawn from a uniform distribution
between 0 and the maximum entry of the basis and
coefficient matrices, which are drawn by the next
suitable rnmf
method, which is the
workhorse method rnmf,NMF,numeric
.
- rnmf
signature(x = "NMF", target =
"numeric")
: Generates a random NMF model of the same
class and rank as another NMF model.
This is the workhorse method that is eventually called by
all other methods. It generates an NMF model of the same
class and rank as x
, compatible with the
dimensions specified in target
, that can be a
single or 2-length numeric vector, to specify a square or
rectangular target matrix respectively.
The second dimension can also be passed via argument
ncol
, so that calling rnmf(x, 20, 10, ...)
is equivalent to rnmf(x, c(20, 10), ...)
, but
easier to write.
The entries are uniformly drawn between 0
and
max
(optionally specified in ...
) that
defaults to 1.
By default the dimnames of x
are set on the
returned NMF model. This behaviour is disabled with
argument keep.names=FALSE
. See
nmfModel
.
- rnmf
signature(x = "ANY", target =
"matrix")
: Generates a random NMF model compatible and
consistent with a target matrix.
The entries are uniformly drawn between 0
and
max(target)
. It is more or less a shortcut for:
rnmf(x, dim(target), max=max(target), ...)
It returns an NMF model of the same class as x
.
- rnmf
signature(x = "ANY", target =
"data.frame")
: Shortcut for rnmf(x,
as.matrix(target))
.
- rnmf
signature(x = "NMF", target =
"missing")
: Generates a random NMF model of the same
dimension as another NMF model.
It is a shortcut for rnmf(x, nrow(x), ncol(x),
...)
, which returns a random NMF model of the same class
and dimensions as x
.
- rnmf
signature(x = "numeric", target =
"missing")
: Generates a random NMF model of a given
rank, with known basis and/or coefficient matrices.
This methods allow to easily generate partially random
NMF model, where one or both factors are known. Although
the later case might seems strange, it makes sense for
NMF models that have fit extra data, other than the basis
and coefficient matrices, that are drawn by an
rnmf
method defined for their own class, which
should internally call rnmf,NMF,numeric
and let it
draw the basis and coefficient matrices. (e.g. see
NMFOffset
and
rnmf,NMFOffset,numeric-method
).
Depending on whether arguments W
and/or H
are missing, this method interprets x
differently:
W
provided, H
missing: x
is
taken as the number of columns that must be drawn to
build a random coefficient matrix (i.e. the number of
columns in the target matrix).
W
is missing, H
is provided: x
is taken as the number of rows that must be drawn to
build a random basis matrix (i.e. the number of rows in
the target matrix).
both W
and H
are provided: x
is taken as the target rank of the model to generate.
Having both W
and H
missing produces
an error, as the dimension of the model cannot be
determined in this case.
The matrices W
and H
are reduced if
necessary and possible to be consistent with this value
of the rank, by the internal call to
nmfModel
.
All arguments in ...
are passed to the function
nmfModel
which is used to build an initial
NMF model, that is in turn passed to
rnmf,NMF,numeric
with dist=list(coef=dist)
or dist=list(basis=dist)
when suitable. The type
of NMF model to generate can therefore be specified in
argument model
(see nmfModel
for
other possible arguments).
The returned NMF model, has a basis matrix equal to
W
(if not missing) and a coefficient matrix equal
to H
(if not missing), or drawn according to the
specification provided in argument dist
(see
method rnmf,NMF,numeric
for details on the
supported values for dist
).
- rnmf
signature(x = "missing", target =
"missing")
: Generates a random NMF model with known
basis and coefficient matrices.
This method is a shortcut for calling
rnmf,numeric,missing
with a suitable value for
x
(the rank), when both factors are known:
rnmf(min(ncol(W), nrow(H)), ..., W=W, H=H)
.
Arguments W
and H
are required. Note that
calling this method only makes sense for NMF models that
contains data to fit other than the basis and coefficient
matrices, e.g. NMFOffset
.
- rnmf
signature(x = "numeric", target =
"numeric")
: Generates a random standard NMF model of
given dimensions.
This is a shortcut for rnmf(nmfModel(x, target,
ncol, ...)), dist=dist)
. It generates a standard NMF
model compatible with the dimensions passed in
target
, that can be a single or 2-length numeric
vector, to specify a square or rectangular target matrix
respectively. See nmfModel
.
- rnmf
signature(x = "formula", target =
"ANY")
: Generate a random formula-based NMF model, using
the method nmfModel,formula,ANY-method
.