R 中的 PLS:提取 PRESS 统计值

PLS in R: Extracting PRESS statistic values

我对 R 比较陌生,目前正在使用 pls 包构建 PLS 模型。我有两个大小相等的独立数据集,第一个在这里用于校准模型。该数据集包含多个响应变量 (y) 和 101 个解释变量 (x),用于 28 个观测值。然而,响应变量将分别包含在 PLS 模型中。当前的代码如下所示:

# load data
data <- read.table("....txt", header=TRUE)
data <- as.data.frame(data)

# define response variables (y)
HEIGHT <- as.numeric(unlist(data[2]))
FBM <- as.numeric(unlist(data[3]))
N <- as.numeric(unlist(data[4]))
C <- as.numeric(unlist(data[5]))
CHL <- as.numeric(unlist(data[6]))

# generate matrix containing the explanatory (x) variables only
spectra <-(data[8:ncol(data)])

# calibrate PLS model using LOO and 20 components
library(pls)
refl.pls <- plsr(N ~ as.matrix(spectra), ncomp=20, validation = "LOO", jackknife = TRUE)

# visualize RMSEP -vs- number of components
plot(RMSEP(refl.pls), legendpos = "topright")

# calculate explained variance for x & y variables
summary(refl.pls) 

我目前已经到了需要为每个响应变量决定要包含在我的 PLS 模型中的最佳组件数量的时间点。 RMSEP 值已经提供了一个不错的指示。但是,我也想根据与我正在进行的研究类似的各种研究,根据 PRESS(预测残差平方和)统计数据做出我的决定。所以简而言之,我想为每个具有 n 个组件的 PLS 模型提取 PRESS 统计数据。

我浏览了 pls 包文档和整个网络,但不幸的是一直无法找到答案。如果这里有人可以帮助我找到正确的方向,我们将不胜感激!

您可以在 mvr 对象中找到 PRESS 值。

refl.pls$validation$PRESS

您可以通过直接使用 str 探索对象或更彻底地阅读文档来了解这一点。如果您查看 ?mvr,您会注意到以下内容:

validation  if validation was requested, the results of the 
            cross-validation. See mvrCv for details.

确实请求了验证,所以我们按照这个到 ?mvrCv 在那里你会发现:

PRESS       a matrix of PRESS values for models with 1, ..., 
            ncomp components. Each row corresponds to one response variable.