bcoef: b-coefficients for PCR and PLSR models

View source: R/bcoef.R

bcoefR Documentation

b-coefficients for PCR and PLSR models

Description

Function bcoef returns the "b-coefficients" (= regression coefficients for the X-matrix), including the intercept) from PCR and PLSR models.

The function is implemented only for algorithms providing orthogonal scores.

Usage


bcoef(fm, ncomp = NULL)

Arguments

fm

Output of functions pls or plsr, or of the PLS algorithm functions.

ncomp

The b-coefficients are calculated for the model with ncomp scores. If NULL (default), the maximal model is considered.

Value

A matrix with the b-coefficients.

Examples


n <- 8
p <- 6
set.seed(1)
X <- matrix(rnorm(n * p, mean = 10), ncol = p, byrow = TRUE)
y1 <- 100 * rnorm(n)
y2 <- 100 * rnorm(n)
Y <- cbind(y1, y2)
set.seed(NULL)

fm <- plsr(X, Y, X, ncomp = 3)
#fm <- pls(X, Y, ncomp = 3)
#fm <- pls.kernel(X, Y, ncomp = 3)
bcoef(fm, ncomp = 2)

fm <- pcr(X, Y, X, ncomp = 3)
bcoef(fm, ncomp = 2)


mlesnoff/rnirs documentation built on April 24, 2023, 4:17 a.m.