% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/rTensor_Decomp.R
\name{rescal}
\alias{rescal}
\title{RESCAL Decomposition}
\usage{
rescal(tnsr, num_components = NULL, max_iter = 25, tol = 1e-05)
}
\arguments{
\item{tnsr}{3-Tensor with square frontal slices}

\item{num_components}{the number of components for the decomposition}

\item{max_iter}{maximum number of iterations if error stays above \code{tol}}

\item{tol}{relative Frobenius norm error tolerance}
}
\value{
a list containing the following:\describe{
\item{\code{A}}{the shared entity factor matrix with \code{num_components} columns}
\item{\code{R}}{a list of core matrices (one per frontal slice), each of size \code{num_components} by \code{num_components}}
\item{\code{conv}}{whether or not \code{resid} < \code{tol} by the last iteration}
\item{\code{est}}{estimate of \code{tnsr} after decomposition}
\item{\code{norm_percent}}{the percent of Frobenius norm explained by the approximation}
\item{\code{fnorm_resid}}{the Frobenius norm of the error \code{fnorm(est-tnsr)}}
\item{\code{all_resids}}{vector containing the Frobenius norm of error for all the iterations}
}
}
\description{
RESCAL decomposition of a 3-Tensor for relational data. Decomposes a 3-Tensor into a shared entity factor matrix \code{A} and slice-specific core matrices \code{R_k} such that each frontal slice \code{X_k = A \%*\% R_k \%*\% t(A)}. Uses the Alternating Least Squares (ALS) estimation procedure. For more details on RESCAL, consult Nickel et al. (2011).
}
\details{
A progress bar is included to help monitor operations on large tensors. The input tensor must be 3-dimensional with square frontal slices (i.e. the first two modes must be equal). Unlike \code{\link{indscal}}, the core matrices \code{R_k} are dense (not restricted to be diagonal), which allows modeling of asymmetric relations.
}
\note{
The first two modes of \code{tnsr} must be equal (square frontal slices).
}
\examples{
tnsr <- rand_tensor(c(5,5,3))
rescalD <- rescal(tnsr, num_components=2)
rescalD$conv
rescalD$norm_percent
plot(rescalD$all_resids)
}
\references{
M. Nickel, V. Tresp, H. Kriegel, "A Three-Way Model for Collective Learning on Multi-Relational Data". Proceedings of the 28th International Conference on Machine Learning 2011.
}
\seealso{
\code{\link{indscal}}, \code{\link{dedicom}}
}
