Learn R Programming

ThreeWay (version 1.1.3)

renormsolCP: Scaling of the Candecomp/Parafac solution

Description

Scales the Candecomp/Parafac solution producing two component matrices normalized to unit sum of squares (and compensating this scaling in the remaining component matrix).

Usage

renormsolCP(A, B, C, mode)

Arguments

A
Component matrix for the A-mode
B
Component matrix for the B-mode
C
Component matrix for the C-mode
mode
Scaling option (1 if scaling for B- and C-modes, 2 if scaling for A- and C-modes, 3 if scaling for A- and B-modes)

Value

A list including the following components:
A
Component matrix for the A-mode after normalization
B
Component matrix for the B-mode after normalization
C
Component matrix for the C-mode after normalization

Examples

Run this code
data(TV)
TVdata=TV[[1]]
# permutation of the modes so that the A-mode refers to students
TVdata <- permnew(TVdata, 16, 15, 30)
TVdata <- permnew(TVdata, 15, 30, 16)
# CP solution
TVcp <- CPfuncrep(TVdata, 30, 16, 15, 2, 1, 1, 1, 0, 1e-6, 10000)
# sums of squares of A, B and C
sum(TVcp$A^2)
sum(TVcp$B^2)
sum(TVcp$C^2)
# Renormalization by scaling B- and C-modes
TVcpScalBC <- renormsolCP(TVcp$A, TVcp$B, TVcp$C, 1)
# sums of squares of A, B and C after renormalization
sum(TVcpScalBC$A^2)
sum(TVcpScalBC$B^2)
sum(TVcpScalBC$C^2)

Run the code above in your browser using DataLab