【发布时间】:2021-07-26 05:32:56
【问题描述】:
我有一个包含 3 个共线预测变量的数据集。 我最终提取了这些预测变量并使用主成分分析来减少多重共线性。 我想要的是使用这些预测器进行进一步的建模。
- 使用
predict函数并获取3个共线预测变量的值并使用预测值进行进一步分析是否不正确? - 或者由于前两个轴捕获了大部分方差(演示数据集中的 70% 和实际数据集中的 96%),我是否应该只使用前两个轴的值而不是 3 个预测值进行进一步分析?
#Creating sample dataset
df<- data.frame(ani_id = as.factor(1:10), var1 = rnorm(500), var2=rnorm(500),var3=rnorm(500))
### Principal Component Analysis
myPCA1 = prcomp(df[,-1],data = df , scale. = TRUE, center = TRUE)
summary(myPCA1)
这是我运行时从演示数据集中得到的结果
> summary(myPCA1)
Importance of components:
PC1 PC2 PC3
Standard deviation 1.0355 1.0030 0.9601
Proportion of Variance 0.3574 0.3353 0.3073
Cumulative Proportion 0.3574 0.6927 1.0000
这表明前两个轴捕获了几乎 70% 的方差。
现在执行以下操作是否正确?
## Using predict function to predict the values of the 3 collinear predictors
axes1 <- predict(myPCA1, newdata = df)
head(axes1)
subset1 <- cbind(df, axes1)
names(subset1)
### Removing the actual 3 collinear predictors and getting a dataset with the ID and 3 predictors who are no long collinear
subset1<- subset1[,-c(2:4)]
summary(subset1)
## Merge this to the actual dataset to use for further analysis in linear mixed effect models
感谢您的帮助! :)
但仍然不确定。这就是我在这里问的原因。
【问题讨论】:
标签: r pca multicollinearity