scores: Extract Scores and Loadings from PLSR and PCR Models

View source: R/extract.R

scoresR Documentation

Extract Scores and Loadings from PLSR and PCR Models

Description

These functions extract score and loading matrices from fitted mvr models.

Usage

loadings(object, ...)

## Default S3 method:
loadings(object, ...)

scores(object, ...)

## Default S3 method:
scores(object, estimate, newdata, ...)

Yscores(object)

loading.weights(object)

Yloadings(object)

Arguments

object

a fitted model to extract from.

...

extra arguments, currently not used.

estimate

optional character vector ("train", "CV", "test") used by scores to select the desired estimate.

newdata

optional data frame passed to scores when estimate = "test".

Details

All functions extract the indicated matrix from the fitted model, and will work with any object having a suitably named component.

The default scores and loadings methods also handle prcomp objects (their scores and loadings components are called x and rotation, resp.), and add an attribute "explvar" with the variance explained by each component, if this is available. (See explvar for details.)

Value

A matrix with scores or loadings.

Note

There is a loadings function in package stats. It simply returns any element named "loadings". See loadings for details. The function can be accessed as stats::loadings(...).

Author(s)

Ron Wehrens and Bjørn-Helge Mevik

See Also

mvr, coef.mvr

Examples


data(yarn)
plsmod <- plsr(density ~ NIR, 6, data = yarn)
scores(plsmod)
loadings(plsmod)[,1:4]


pls documentation built on Feb. 21, 2026, 9:07 a.m.