Learn R Programming

albatross (version 0.1-1)

feemparafac: Compute PARAFAC on a FEEM cube object

Description

This function forwards its arguments to parafac from the multiway package, optionally rescales the result and attaches a few attributes.

Usage

feemparafac(X, …, rescale = 3, retries = 10)

Arguments

X

A FEEM cube object. The per-sample factors will be multiplied by attr(X, 'scales') stored in it.

Passed as-is to parafac.

rescale

Rescale the resulting factors to leave all the variance in the given mode: emission, excitation, or sample (default). Set to NA to disable.

retries

Retry for given number of tries until parafac returns a successfully fitted model or stops due to the iteration number limit. Raise a fatal error if all tries were unsuccessful.

Value

An object of classes feemparafac and parafac with the cube attribute added containing a reference to the original FEEM cube object.

Details

The function 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.

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))

References

R. Bro, PARAFAC. Tutorial and applications, Chemometrics and Intelligent Laboratory Systems. 38 (1997) 149-171. 10.1016/S0169-7439(97)00032-4

See Also

parafac for the parafac class structure; fitted.feemparafac, residuals.feemparafac, plot.feemparafac for methods specific to values returned from this function.

Examples

Run this code
# NOT RUN {
  data(feems)
  cube <- feemscale(
    feemscatter(
      feemcube(feems, FALSE)[(1:45)*4,(1:13)*4,],
      rep(24, 4)), na.rm = TRUE
  )
  plot(
    factors <- feemparafac(
      cube, nfac = 2, const = rep('nonneg', 3)
    )
  )
# }

Run the code above in your browser using DataLab