这可能是评论而不是答案,我不确定我是否正确。让我们尝试比较一个线性模型在 PCA 之前和之后在两个几乎共线的变量上的输出:
set.seed(1234)
x1 <- 1:10
x2 <- x1 + rnorm(n= length(x1), sd= 0.0001) # x2 is nearly colinear to x1
y <- rowMeans(cbind(x1, x2)) + rnorm(n= length(x1)) # A response variable
原始数据的线性回归:
summary(lm(y ~ x1 + x2))
...
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) -0.9351 0.7503 -1.246 0.253
x1 1428.6673 3681.8475 0.388 0.710
x2 -1427.5288 3681.8604 -0.388 0.710
Residual standard error: 1.094 on 7 degrees of freedom
Multiple R-squared: 0.9281, Adjusted R-squared: 0.9076
F-statistic: 45.18 on 2 and 7 DF, p-value: 9.963e-05
现在关于主要组件:
pca <- prcomp(cbind(x1, x2))
pca_lm <- lm(y ~ pca$x[,1] + pca$x[,2])
summary(pca_lm)
...
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 5.382e+00 3.458e-01 15.562 1.09e-06 ***
pca$x[, 1] 8.086e-01 8.514e-02 9.498 3.00e-05 ***
pca$x[, 2] 2.020e+03 5.207e+03 0.388 0.71
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 1.094 on 7 degrees of freedom
Multiple R-squared: 0.9281, Adjusted R-squared: 0.9076
F-statistic: 45.18 on 2 and 7 DF, p-value: 9.963e-05
查看调整后的 R 平方,这两个模型的质量是相同的 - 正如预期的那样。
将具有主成分的模型中的系数投影到原始比例(我这样做对吗?)
(pca_lm$coefficients[1] + pca_lm$coefficients[2:3]) %*% pca$rotation
PC1 PC2
[1,] 1436.278 -1427.529
这些类似于原始变量模型中的系数。因此,总而言之,通过主成分没有优势。