问题描述
我有一个包含 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
感谢您的帮助! :)
但还是不确定。这就是我在这里问的原因。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)