1

我只是想知道如何在使用 PCR 回归后访问解释的变异百分比和交叉验证的测试错误。我查看了 summary.mvr 的文档,但我想我一定遗漏了一些东西。有没有简单的方法来做到这一点?例如:

library(MASS)
boston = Boston

pcr.fit = pcr(crim ~ ., data = boston, scale = TRUE, validation = "CV")
summary(pcr.fit)

Data:   X dimension: 506 13 
    Y dimension: 506 1
Fit method: svdpc
Number of components considered: 13

VALIDATION: RMSEP
Cross-validated using 10 random segments.
       (Intercept)  1 comps  2 comps  3 comps  4 comps  5 comps  6 comps  7 comps  8 comps  9 comps
CV            8.61    7.174    7.178    6.722    6.703    6.717    6.727    6.729    6.603    6.611
adjCV         8.61    7.173    7.177    6.719    6.699    6.715    6.723    6.724    6.598    6.607
       10 comps  11 comps  12 comps  13 comps
CV        6.624     6.643     6.569     6.498
adjCV     6.619     6.635     6.561     6.490

TRAINING: % variance explained
      1 comps  2 comps  3 comps  4 comps  5 comps  6 comps  7 comps  8 comps  9 comps  10 comps
X       47.70    60.36    69.67    76.45    82.99    88.00    91.14    93.45    95.40     97.04
crim    30.69    30.87    39.27    39.61    39.61    39.86    40.14    42.47    42.55     42.78
      11 comps  12 comps  13 comps
X        98.46     99.52     100.0
crim     43.04     44.13      45.4

我只想访问为预测变量和犯罪解释解释的变化百分比。是否有捷径可寻?

谢谢你的帮助!

文森特

4

2 回答 2

1

To get the percentage of variation explained for each predictors, you can use:

cumsun(explvar(pcr.fit))

For the cross-validated test errors, you can maybe look at the MSEP function.

Also if in this case you can use getS3method("summary","mvr") to see the code of the summary function and figure out how to get the values you need from there.

于 2015-02-18T00:11:21.103 回答
0

对于偶然发现这个问题的任何其他人,这里的命令(在最初的问题中发布 pcr 命令)对我有用,可以根据总解释变化绘制组件数量。

validationplot(pcr.fit, val.type = "R2")
于 2019-02-18T03:44:14.423 回答