% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/npca.R
\name{npca}
\alias{npca}
\title{Non-Negative PCA with Deflation (nPCA)}
\usage{
npca(x, k, tol = 1e-10, max.iter = 1000, return.score = TRUE)
}
\arguments{
\item{x}{A numeric matrix of size (p x n). The row dimension will be embedded}

\item{k}{Integer; number of nPCA components to extract.}

\item{tol}{Numeric; convergence tolerance for nPCA iterations. Default: \code{1e-10}.}

\item{max.iter}{Integer; maximum iterations for calculating each nPCA component.
Default: \code{1000}.}

\item{return.score}{Logical; If \code{TRUE} return the nPCA projection of \code{x}.}
}
\value{
A list with:
  \itemize{
    \item \code{scores}: Matrix (n x k) of non-negative nPCA scores
          (columns are components).
    \item \code{loadings}: Matrix (p x k) of non-negative nPCA loadings
    \item \code{sd}: Numeric vector (\code{k}) of nPCA “standard deviations”.
  }
}
\description{
Computes a non-negative PCA (nPCA) basis via iterative regression and
deflation on an input matrix \code{x}.
}
\details{
This function implements non-negative PCA using restricted single-value decomposition, 
which is solved using the iterative regression approach introduced by Sigg and Buhmann (2008) and deflation
approach introduced by Mackey (2008).
}
\examples{
x <- matrix(rnorm(1000), nrow - 100)
res <- nn.pca(x, k = 10, tol = 1e-10, n.iter = 1000)
str(res$loadings); str(res$sd)

}
\references{
Sigg, C. D., & Buhmann, J. M. (2008, July). Expectation-maximization for sparse and non-negative PCA.
\emph{In Proceedings of the 25th international conference on Machine learning} (pp. 960-967).

Mackey, L. (2008). Deflation methods for sparse PCA. Advances in neural information processing systems, 21.
}
