如何使用动态 LHS 和 RHS 创建 OLS 线性回归的多次迭代循环?

发布于 2025-01-15 14:50:05 字数 348 浏览 2 评论 0原文

我有一个包含多个列的数据集,其中包含我想要检查相关性的变量。我的标识符是国家代码,剩下的都是要研究的变量。目标是使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文