如何使用动态 LHS 和 RHS 创建 OLS 线性回归的多次迭代循环?
我有一个包含多个列的数据集,其中包含我想要检查相关性的变量。我的标识符是国家代码,剩下的都是要研究的变量。目标是使用 r 平方值作为比较属性,找到所有组合中排名前 5/10 的线性回归。我的数据如下所示:
Country_code | A1 | A2 | A3 |...... | A193
我想运行一个可以循环运行 lm 的模拟,并汇总列表中所有属性的组合,以便我可以比较它们的 r 平方值并发布/绘制前 5/10 相关性。 它应该像这样运行 对于A1: lm(A1~A2) 然后 lm(A1~A3)..... 接下来:lm(A2~A3)....
我知道我需要放置两个循环,但结果要么没有保存,因为摘要有太多属性需要推送到列表中,等等。
I have a dataset with multiple columns with variables that I want to check for correlations. My identifier is country code and the remaining are all variables that are to be studied. The goal is to find the top 5/10 linear regressions among all combinations using r square value as comparison attribute. My data looks like:
Country_code | A1 | A2 | A3 |...... | A193
I want to run a simulation that can run lm in loop and have summaries of all combination of attributes in a list so that I can compare their r square value and publish/plot the top 5/10 correlations.
It should run like
For A1:
lm(A1~A2) then lm(A1~A3).....
Next: lm(A2~A3)....
I know I need to put two loops but either the results are not saved because the summary have too many attributes to be pushed into a list, etc.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论