residuals.nmf: Extract residuals from NMF models

View source: R/s3methods.R

residuals.nmfR Documentation

Extract residuals from NMF models

Description

Returns the residual matrix Y - \hat{Y} from a fitted NMF model. Requires the original observation matrix Y to be supplied.

For nmfre objects, residuals are computed from the BLUP reconstruction (Y - X(B_{blup})) by default. Set type = "fixed" to use fixed-effects only.

Usage

## S3 method for class 'nmf'
residuals(object, Y, ...)

## S3 method for class 'nmfae'
residuals(object, Y, ...)

## S3 method for class 'nmfre'
residuals(object, Y, type = c("blup", "fixed"), ...)

## S3 method for class 'nmf.sem'
residuals(object, Y, ...)

Arguments

object

A fitted model object.

Y

The original observation matrix used for fitting.

...

Not used.

type

For nmfre objects: "blup" (default) or "fixed".

Value

The residual matrix.

See Also

nmfkc, nmfae, nmfre, nmf.sem, fitted.nmf

Examples

Y <- matrix(runif(50), 5, 10)
result <- nmfkc(Y, rank = 2)
residuals(result, Y)


nmfkc documentation built on July 14, 2026, 1:07 a.m.