coef.nmf: Extract coefficients from NMF models

View source: R/s3methods.R

coef.nmfR Documentation

Extract coefficients from NMF models

Description

Returns the coefficients data frame from a fitted NMF model that has been passed through an inference function (nmfkc.inference, nmfae.inference, nmfre.inference).

If inference has not been run, returns the parameter matrix C (\Theta) directly.

For nmf.sem objects, returns C_2 (exogenous block) as fallback.

Usage

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

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

Arguments

object

A fitted model object of class "nmf", "nmfkc", "nmfae", "nmfre", or "nmf.sem".

...

Not used.

Value

A data frame of coefficients (if inference was performed), or the parameter matrix C.

See Also

nmfkc.inference, nmfae.inference, nmfre.inference, nmf.sem.inference

Examples

Y <- matrix(cars$dist, nrow = 1)
A <- rbind(1, cars$speed)
result <- nmfkc(Y, A, rank = 1)
coef(result)  # returns C matrix

result2 <- nmfkc.inference(result, Y, A)
coef(result2)  # returns coefficients data frame


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