R 主成分回归中“成分”的含义是什么?

R 主成分回归中“成分”的含义是什么?,r,pca,R,Pca,我正在学习主成分回归,我不理解PCR方法得到的结果。我使用PCR的目的是减少预测因子的数量 例如: library(caret) # Load the data data("Boston", package = "MASS") # Split the data into training and test set set.seed(123) training.samples <- Boston$medv %>% createDataPartition(p = 0.8, list

我正在学习主成分回归,我不理解PCR方法得到的结果。我使用PCR的目的是减少预测因子的数量

例如:

library(caret)
# Load the data
data("Boston", package = "MASS")
# Split the data into training and test set
set.seed(123)
training.samples <- Boston$medv %>%
  createDataPartition(p = 0.8, list = FALSE)
train.data  <- Boston[training.samples, ]
test.data <- Boston[-training.samples, ]
# Build the model on training set
set.seed(123)
model <- train(
  medv~., data = train.data, method = "pcr",
  scale = TRUE,
  trControl = trainControl("cv", number = 10),
  tuneLength = 10
  )

# Print the best tuning parameter ncomp that
# minimize the cross-validation error, RMSE
summary(model)

model$bestTune

我可以问一下1比5是什么意思吗? $bestTune车型的ncomp 5结果是什么意思? 我在哪里可以从这些结果中找到简化模型?我的最终目标是选择重要的预测因子。 谢谢


-C.T

从我读到的关于PCR的内容来看,它对于降维非常有用,特别是考虑到变量之间的共线性。一些有用的链接:

您执行的模型拟合过程并不是告诉您要使用哪一个原始变量进行预测,而是建议使用不同的系数集组合所有变量的各种方法,以得出较短的元预测值或组件列表

summarymodel告诉您,使用单个组件可以解释38%的结果,但使用5个组件可以解释71%。bestTune认为这是预测能力和模型简单性之间的最佳平衡

要查看这些组件的外观,可以查看下面复制的模型[[finalModel]][[Courters]],输出。我相信这显示了应用于每个变量的标准化版本的系数,以创建前几个组件中的每一个

, , 1 comps   # coefficients applied to variables to create component #1

            .outcome
crim    -0.592587562
zn       0.599992485
indus   -0.802349361
chas     0.006248825
nox     -0.791459829
rm       0.447008384
age     -0.713823494
dis      0.739724065
rad     -0.741112634
tax     -0.785801427
ptratio -0.487355792
black    0.457723689
lstat   -0.716345800

, , 2 comps    # coefficients applied to variables to create component #2...

          .outcome
crim    -1.3071490
zn      -0.1696660
indus   -0.5509926
chas     1.3404699
nox     -0.1278061
rm       1.2483213
age      0.2066896
dis     -0.2710928
rad     -1.3575348
tax     -1.3611397
ptratio -1.5186875
black    0.8599876
lstat   -1.0065236

, , 3 comps

            .outcome
crim    -0.379353935
zn       0.914275307
indus   -0.663750247
chas     1.800225620
nox      0.173805923
rm       2.911531130
age      0.006938608
dis     -0.221098241
rad     -0.348203175
tax     -0.583374313
ptratio -2.388449513
black   -0.232188538
lstat   -1.784086797

, , 4 comps

          .outcome
crim    -0.4650669
zn       0.8355077
indus   -0.6614445
chas     1.0473459
nox      0.3090320
rm       3.0563403
age      0.1453604
dis     -0.3965918
rad     -0.4828702
tax     -0.6739500
ptratio -2.6654286
black   -0.3997876
lstat   -1.8464750

, , 5 comps

           .outcome
crim    -0.56682510
zn       0.07089925
indus   -0.72683562
chas     0.61226427
nox      0.03060117
rm       4.18612272
age      0.17409947
dis     -0.70519697
rad      0.11136186
tax     -0.31640619
ptratio -1.42839422
black    0.70692195
lstat   -2.80938875

, , 6 comps

          .outcome
crim    -0.4526589
zn       0.2148831
indus   -0.7151197
chas     0.5618245
nox      0.0850809
rm       4.1544127
age      0.2220764
dis     -0.7142467
rad      0.1485075
tax     -0.2614366
ptratio -1.5666266
black    1.0166062
lstat   -2.7407352

请问如何使用pcr进行变量选择?根据您对每个组件的结果,似乎每个组件都使用数据集中的所有变量,而不进行选择。我想知道pcr是否能像glmnet一样告诉我数据集中哪些变量最重要。谢谢。我不认为它对变量选择最有用。PCR不是一种特征选择方法,因为每个计算的主成分都是原始变量的线性组合。使用主成分而不是实际特征会使解释什么影响什么变得更加困难。
  ncomp
5     5
, , 1 comps   # coefficients applied to variables to create component #1

            .outcome
crim    -0.592587562
zn       0.599992485
indus   -0.802349361
chas     0.006248825
nox     -0.791459829
rm       0.447008384
age     -0.713823494
dis      0.739724065
rad     -0.741112634
tax     -0.785801427
ptratio -0.487355792
black    0.457723689
lstat   -0.716345800

, , 2 comps    # coefficients applied to variables to create component #2...

          .outcome
crim    -1.3071490
zn      -0.1696660
indus   -0.5509926
chas     1.3404699
nox     -0.1278061
rm       1.2483213
age      0.2066896
dis     -0.2710928
rad     -1.3575348
tax     -1.3611397
ptratio -1.5186875
black    0.8599876
lstat   -1.0065236

, , 3 comps

            .outcome
crim    -0.379353935
zn       0.914275307
indus   -0.663750247
chas     1.800225620
nox      0.173805923
rm       2.911531130
age      0.006938608
dis     -0.221098241
rad     -0.348203175
tax     -0.583374313
ptratio -2.388449513
black   -0.232188538
lstat   -1.784086797

, , 4 comps

          .outcome
crim    -0.4650669
zn       0.8355077
indus   -0.6614445
chas     1.0473459
nox      0.3090320
rm       3.0563403
age      0.1453604
dis     -0.3965918
rad     -0.4828702
tax     -0.6739500
ptratio -2.6654286
black   -0.3997876
lstat   -1.8464750

, , 5 comps

           .outcome
crim    -0.56682510
zn       0.07089925
indus   -0.72683562
chas     0.61226427
nox      0.03060117
rm       4.18612272
age      0.17409947
dis     -0.70519697
rad      0.11136186
tax     -0.31640619
ptratio -1.42839422
black    0.70692195
lstat   -2.80938875

, , 6 comps

          .outcome
crim    -0.4526589
zn       0.2148831
indus   -0.7151197
chas     0.5618245
nox      0.0850809
rm       4.1544127
age      0.2220764
dis     -0.7142467
rad      0.1485075
tax     -0.2614366
ptratio -1.5666266
black    1.0166062
lstat   -2.7407352