Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/visual-studio-2012/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
R中的PLS:提取压力统计值_R_Pls - Fatal编程技术网

R中的PLS:提取压力统计值

R中的PLS:提取压力统计值,r,pls,R,Pls,我对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 <

我对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) 
#加载数据

数据您可以在
mvr
对象中找到压力值

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.

非常感谢cdeterman,这正是我要找的代码!在过去的几天里,我多次看到文档中的这一部分(幸运的是),但我根本不明白如何正确使用语法来提取PRESS值。@BobvanderMeij很乐意提供帮助,如果这完全回答了您的问题,请务必接受,这样问题就结束了。