我使用pls包创建了PLS回归模型,请参见下面的示例:
#Package
library(pls)
#First simulate some data
set.seed(123)
bands=20
data <- data.frame(matrix(runif(60*bands),ncol=bands))
colnames(data) <- paste0(1:bands)
data$nitrogen <- rpois(60,10)
data$carbon <- rpois(60,10)
data$time <- c(rep(1,30),rep(2,30))
#
#define explanatory variables (x)
spectra1 <- as.matrix(data[1:30,1:20])
spectra2 <- as.matrix(data[31:60,1:20])
#Build PLS model 1
d1<-data[data$time==1,]
mod_pls1 <- plsr(carbon + nitrogen ~ spectra1,
ncomp = 20, data =d1, validation = "LOO", jackknife = TRUE)
#
确定我的模型mod_pls1有效,但是有没有办法查看该模型中的所有系数?我理想的目标是将我的模型表示为y_carbon + y_nitrogen =斜率值+ 0.34 * spectra1 ... 1.78 * spectra20。
谢谢你!