Description Usage Arguments Value Methods (by generic) See Also Examples
nneg
is a generic function to transform a data objects that
contains negative values into a similar object that only contains
values that are nonnegative or greater than a given threshold.
rposneg
performs the "reverse" transformation of the posneg
function.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | nneg(object, ...)
## S4 method for signature 'matrix'
nneg(
object,
method = c("pmax", "posneg", "absolute", "min"),
threshold = 0,
shift = TRUE
)
## S4 method for signature 'NMF'
nneg(object, ...)
posneg(...)
rposneg(object, ...)
## S4 method for signature 'matrix'
rposneg(object, unstack = TRUE)
## S4 method for signature 'NMF'
rposneg(object, ...)
|
object |
The data object to transform |
... |
extra arguments to allow extension or passed down to |
method |
Name of the transformation method to use, that is partially matched against the following possible methods:
|
threshold |
Nonnegative lower threshold value (single numeric).
See argument |
shift |
a logical indicating whether the entries below the threshold
value |
unstack |
Logical indicating whether the positive and negative parts
should be unstacked and combined into a matrix as |
an object of the same class as argument object
.
an object of the same type of object
nneg:
nneg(object = matrix)
: Transforms a mixed-sign matrix into a nonnegative matrix, optionally apply a
lower threshold.
This is the workhorse method, that is eventually called by all other
methods defined in the NMF
package.
nneg(object = NMF)
: Apply nneg
to the basis matrix of an NMF
object (i.e. basis(object)
).
All extra arguments in ...
are passed to the method nneg,matrix
.
rposneg:
rposneg(object = NMF)
: Apply rposneg
to the basis matrix of an NMF
object.
Other transforms:
NMF-class
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 50 51 52 53 54 55 56 57 58 59 60 61 | # random mixed sign data (normal distribution)
set.seed(1)
x <- rmatrix(5,5, rnorm, mean=0, sd=5)
x
# pmax (default)
nneg(x)
# using a threshold
nneg(x, threshold=2)
# without shifting the entries lower than threshold
nneg(x, threshold=2, shift=FALSE)
# posneg: split positive and negative part
nneg(x, method='posneg')
nneg(x, method='pos', threshold=2)
# absolute
nneg(x, method='absolute')
nneg(x, method='abs', threshold=2)
# min
nneg(x, method='min')
nneg(x, method='min', threshold=2)
# random
M <- nmfModel(x, rmatrix(ncol(x), 3))
nnM <- nneg(M)
basis(nnM)
# mixture coefficients are not affected
identical( coef(M), coef(nnM) )
# shortcut for the "posneg" transformation
posneg(x)
posneg(x, 2)
# random mixed sign data (normal distribution)
set.seed(1)
x <- rmatrix(5,5, rnorm, mean=0, sd=5)
x
# posneg-transform: split positive and negative part
y <- posneg(x)
dim(y)
# posneg-reverse
z <- rposneg(y)
identical(x, z)
rposneg(y, unstack=FALSE)
# But posneg-transformation with a non zero threshold is not reversible
y1 <- posneg(x, 1)
identical(rposneg(y1), x)
# random mixed signed NMF model
M <- nmfModel(rmatrix(10, 3, rnorm), rmatrix(3, 4))
# split positive and negative part
nnM <- posneg(M)
M2 <- rposneg(nnM)
identical(M, M2)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.