% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/s3methods.R
\name{residuals.nmf}
\alias{residuals.nmf}
\alias{residuals.nmfae}
\alias{residuals.nmfre}
\alias{residuals.nmf.sem}
\title{Extract residuals from NMF models}
\usage{
\method{residuals}{nmf}(object, Y, ...)

\method{residuals}{nmfae}(object, Y, ...)

\method{residuals}{nmfre}(object, Y, type = c("blup", "fixed"), ...)

\method{residuals}{nmf.sem}(object, Y, ...)
}
\arguments{
\item{object}{A fitted model object.}

\item{Y}{The original observation matrix used for fitting.}

\item{...}{Not used.}

\item{type}{For \code{nmfre} objects: \code{"blup"} (default) or
\code{"fixed"}.}
}
\value{
The residual matrix.
}
\description{
Returns the residual matrix \eqn{Y - \hat{Y}} from a fitted NMF model.
Requires the original observation matrix \code{Y} to be supplied.

For \code{nmfre} objects, residuals are computed from the BLUP
reconstruction (\eqn{Y - X(B_{blup})}) by default. Set
\code{type = "fixed"} to use fixed-effects only.
}
\examples{
Y <- matrix(runif(50), 5, 10)
result <- nmfkc(Y, rank = 2)
residuals(result, Y)

}
\seealso{
\code{\link{nmfkc}}, \code{\link{nmfae}}, \code{\link{nmfre}},
\code{\link{nmf.sem}}, \code{\link{fitted.nmf}}
}
