I want to perform a Parallel Factor Analysis (PARAFAC) with data from Fluorescence spectroscopy. I have a three dimensional array (39x151x43) that I pass to the parafac function in the "multiway" package. So far, it works well but I get negative values for some of the components.
I read in the manual that one can specify constraints for non-negativity. However, I don't understand how the vector for the constraints option should look like. When I try to do the following I get an error that says "Input 'const' must be 3 element vector specifying constraint for each mode"
#### creating dummy values for Stackoverflow ####
A <- c(1:39)
B <- rnorm(151, mean =1, sd=0.5)
C <- rnorm(43, mean=1, sd = 0.5)
myArray <- array(c(A,B,C), dim = c(39,151,43))
dim(myArray)
library(multiway) # load the library
myModel <- parafac(myArray, nfac = 3) # how to set const?
#Input 'const' must be 3 element vector specifying constraint for each mode
Some research was to no avail. How should the vector look like so that the parafac function accepts it?
The parameters of constraints vector are unconstrained:0,orthogonal:1,non-negative:2.
If all three inputs A,B,C are to be non-negative the constraint vector should be
const=c(2,2,2)