Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

krprod

Khatri-Rao Product


Description

Calculates the Khatri-Rao product (i.e., columnwise Kronecker product) between two matrices with the same number of columns.

Usage

krprod(X, Y)

Arguments

X

Matrix of order n-by-p.

Y

Matrix of order m-by-p.

Details

Given X (n-by-p) and Y (m-by-p), the Khatri-Rao product Z = krprod(X,Y) is defined as

Z[,j] = kronecker(X[,j],Y[,j])

which is the mn-by-p matrix containing Kronecker products of corresponding columns of X and Y.

Value

The mn-by-p matrix of columnwise Kronecker products.

Note

X and Y must have the same number of columns.

Author(s)

Nathaniel E. Helwig <helwig@umn.edu>

Examples

##########   EXAMPLE 1   ##########
X <- matrix(1,4,2)
Y <- matrix(1:4,2,2)
krprod(X,Y)


##########   EXAMPLE 2   ##########
X <- matrix(1:2,4,2)
Y <- matrix(1:4,2,2)
krprod(X,Y)


##########   EXAMPLE 3   ##########
X <- matrix(1:2,4,2,byrow=TRUE)
Y <- matrix(1:4,2,2)
krprod(X,Y)

multiway

Component Models for Multi-Way Data

v1.0-6
GPL (>= 2)
Authors
Nathaniel E. Helwig <helwig@umn.edu>
Initial release
2019-03-12

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.