eem_parafac: Runs a PARAFAC analysis on EEM data

View source: R/parafac_functions.R

eem_parafacR Documentation

Runs a PARAFAC analysis on EEM data

Description

One or more PARAFAC models can be calculated depending on the number of components. The idea is to compare the different models to get the most suitable. B-mode is emmission wavelengths, C-mode is excitation wavelengths and, A-mode is the loadings of the samples. The calculation is done with parafac, please see details there.

Usage

eem_parafac(
  eem_list,
  comps,
  maxit = 2500,
  normalise = TRUE,
  const = c("nonneg", "nonneg", "nonneg"),
  nstart = 30,
  ctol = 10^-8,
  strictly_converging = FALSE,
  cores = parallel::detectCores(logical = FALSE),
  verbose = FALSE,
  output = "best",
  ...
)

Arguments

eem_list

object of class eem

comps

vector containing the desired numbers of components. For each of these numbers one model is calculated

maxit

maximum iterations for PARAFAC algorithm

normalise

state whether EEM data should be normalised in advance

const

constraints of PARAFAC analysis. Default is non-negative ("nonneg"), alternatively smooth and non-negative ("smonon") might be interesting for an EEM analysis.

nstart

number of random starts

ctol

Convergence tolerance (R^2 change)

strictly_converging

calculate nstart converging models and take the best. Please see details!

cores

number of parallel calculations (e.g. number of physical cores in CPU)

verbose

print infos

output

Output the "best" solution (default) only or additionally add "all" nstart solutions to the model as an element named "models".

...

additional parameters that are passed on to parafac

Details

PARAFAC models are created based on multiple random starts. In some cases, a model does not converge and the resulting model is then based on less than nstart converging models. In case you want to have nstart converging models, set strictly_converging TRUE. This calculates models stepwise until the desired number is reached but it takes more calculation time. Increasing the number of models from the beginning is much more time efficient.

Value

object of class parafac

See Also

parafac

Examples


data(eem_list)

dim_min <- 3 # minimum number of components
dim_max <- 7 # maximum number of components
nstart <- 25 # random starts for PARAFAC analysis, models built simulanuously, best selected
# cores <- parallel::detectCores(logical=FALSE) # use all cores but do not use all threads
cores <- 2 # package checks only run with 2 cores
maxit = 2500
ctol <- 10^-7 # tolerance for parafac

pfres_comps <- eem_parafac(eem_list, comps = seq(dim_min, dim_max),
    normalise = TRUE, maxit = maxit, nstart = nstart, ctol = ctol, cores = cores)

## with a defined number of converging models
#pfres_comps <- eem_parafac(eem_list, comps = seq(dim_min, dim_max),
#     normalise = TRUE, maxit = maxit, nstart = nstart, ctol = ctol,
#     output = "all", strictly_converging = TRUE, cores = cores, verbose = TRUE)

pfres_comps2 <- eem_parafac(eem_list, comps = seq(dim_min, dim_max),
    normalise = TRUE, maxit = maxit, nstart = nstart, ctol = ctol, cores = cores, output = "all")


staRdom documentation built on July 9, 2023, 5:57 p.m.