feemparafac {albatross} | R Documentation |
Compute PARAFAC on a FEEM cube object and access the results
Description
feemparafac
forwards its arguments to
parafac
from the multiway package,
optionally rescales the result and attaches a few attributes.
Resulting objects of class feemparafac
can be accessed using
methods presented below.
Usage
feemparafac(
X, ..., const = rep('nonneg', 3), ctol = 1e-6,
rescale = 3, retries = 10, subset = TRUE, envir = NULL
)
## S3 method for class 'feemparafac'
plot(x, type = c("image", "lines"), ...)
## S3 method for class 'feemparafac'
coef(
object, type = c(
"all", "scores", "loadings", "surfaces",
"emission", "excitation", "samples"
), ...
)
## S3 method for class 'feemparafac'
fitted(object, ...)
## S3 method for class 'feemparafac'
residuals(object, ...)
## S3 method for class 'feemparafac'
reorder(x, neworder, like, ...)
## S3 method for class 'feemparafac'
rescale(x, mode, newscale, absorb, like, ...)
Arguments
X |
A FEEM cube object. The per-sample factors will be multiplied by
If |
... |
|
const |
A character vector of length 3 specifying the constraints for all
modes of |
ctol |
The stopping criterion used by |
rescale |
Rescale the resulting factors to leave all the variance in the given
mode: emission, excitation, or sample (default). Set to |
retries |
Retry for given number of tries until
|
subset |
An integer or logical vector choosing the samples from |
envir |
An environment to look up |
x , object |
An object returned by |
type |
Given a fitted PARAFAC model:
With
Fitted PARAFAC coefficients can be returned in the following forms:
|
neworder |
A permutation of integers between |
like |
A In In |
mode |
The modes to rescale, with |
newscale |
The desired root-mean-square for each column of the modes being
rescaled.
Forwarded to |
absorb |
The mode that should absorb the inverse rescaling coefficients.
When |
Details
feemparafac
tries hard to guarantee the convergence flag to be
0
(normal convergence) or 1
(iteration number limit
reached), but never 2
(a problem with the constraints). A fatal
error is raised if repeated runs of parafac
do
not return a (semi-)successfully fitted model.
After the PARAFAC decomposition is calculated, the scores are
multiplied by the scales
attribute of the X
object,
making them represent the cube with scaling undone. Use
feemscale(remember = FALSE)
if you don't want to undo
the scaling.
The output
option is fixed to "best"
value. Obtaining
a list of alternative solutions can therefore be achieved by running:
replicate(n, feemparafac(..., nstart = 1), simplify = FALSE)
The subset
and envir
options are useful to repeatedly
perform PARAFAC on different subsets of the same FEEM cube, e.g. in
jack-knifing or split-half analysis. Since feemparafac
keeps
a reference to the its X
and envir
arguments, the use
of subset
should ensure that the same FEEM cube is referenced
from multiple feemparafac
objects instead of creating copies
of its subsets. Additionally, environment objects are not duplicated
on save
or load
, so storing
X
in an environment and passing it to multiple invocations of
feemparafac
will save a lot of memory when the results are
serialised together.
plot.feemparafac
provides sane defaults for lattice
options such as xlab
, ylab
, as.table
,
auto.key
, type
, cuts
, col.regions
, but
they can be overridden.
Value
feemparafac |
An object of classes
Use |
plot.feemparafac |
A lattice plot object. Its |
coef.feemparafac |
A |
fitted.feemparafac |
A |
resid.feemparafac |
A |
References
Bro R (1997). “PARAFAC. Tutorial and applications.” Chemometrics and Intelligent Laboratory Systems, 38(2), 149-171. doi:10.1016/S0169-7439(97)00032-4.
See Also
The parafac
class structure;
write.openfluor
, feemcube
for methods
specific to values returned from this function.
The rescale
generic is re-exported from the
multiway package.
Examples
data(feems)
cube <- feemscale(feemscatter(cube, c(24, 14)), na.rm = TRUE)
(factors <- feemparafac(cube, nfac = 3, ctol = 1e-4))
plot(factors, 'image')
plot(factors, 'line')
head(coef(factors, 'loadings'))
str(coef(factors, 'all'))
str(feemcube(factors)) # original cube is retained
plot(fitted(factors))
plot(resid(factors))