如何从整理数据中获得相关性的残差
我有一个整洁的数据。
|ID | variable | value.x | value.y |
| --- | -------- | ------- | ------- |
|1 | Temp | -0.71 | -0.74 |
|2 | Temp | -0.53 | -0.50 |
|3 | Temp | -0.48 | -0.51 |
|4 | Temp | -0.65 | -0.66 |
|5 | Temp | -0.49 | -0.56 |
|6 | Prep | -0.72 | -0.75 |
|7 | Prep | -0.64 | -0.65 |
|8 | Prep | -0.56 | -0.54 |
|9 | Prep | -0.46 | -0.47 |
|10 | Prep | -0.44 | -0.44 |
我想获得每个变量的相关性残差。
提前致谢,
I have a tidy data.
|ID | variable | value.x | value.y |
| --- | -------- | ------- | ------- |
|1 | Temp | -0.71 | -0.74 |
|2 | Temp | -0.53 | -0.50 |
|3 | Temp | -0.48 | -0.51 |
|4 | Temp | -0.65 | -0.66 |
|5 | Temp | -0.49 | -0.56 |
|6 | Prep | -0.72 | -0.75 |
|7 | Prep | -0.64 | -0.65 |
|8 | Prep | -0.56 | -0.54 |
|9 | Prep | -0.46 | -0.47 |
|10 | Prep | -0.44 | -0.44 |
I would like to get the residuals of correlation for each variable.
Thanks in advance,
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您只想将残差从模型添加到数据表中,则
modelr :: add_residuals()
是为此目的而言是一个不错的便利功能。您可以使用dplyr :: group_split()
和purrr :: map()
同时在原始数据的多个子集上运行此操作。我假设一个简单的线性模型,但您可以替换其他标准模型对象。由
If you just want to add the residuals from a model to your data table,
modelr::add_residuals()
is a nice convenience function for this exact purpose. You can usedplyr::group_split()
andpurrr::map()
to simultaneously run this on multiple subsets of your original data. I assumed a simple linear model but you can substitute other standard model objects.Created on 2022-04-07 by the reprex package (v2.0.1)