Learn R Programming

parafac4microbiome (version 1.1.2)

parafac_fun: PARAFAC loss function calculation

Description

PARAFAC loss function calculation

Usage

parafac_fun(x, Tensor, lambdas = NULL)

Value

Scalar value of the loss function

Arguments

x

Vector of fitted loadings generated by the PARAFAC algorithm, can also be a Fac object

Tensor

input data

lambdas

If lambdas (from the kruskal tensor case) are generated to make the Fac norm 1, they can be supplied.

Examples

Run this code
A = array(rnorm(108*2), c(108,2))
B = array(rnorm(100*2), c(100,2))
C = array(rnorm(10*2), c(10,2))
X = reinflateTensor(A, B, C)
model = parafac(X, 2)
f = parafac_fun(model$Fac, X)

Run the code above in your browser using DataLab