r - 为什么即使我正在转换预测变量,我的散点图看起来也完全一样?

标签 r regression

这是我正在使用的数据集:http://archive.ics.uci.edu/ml/datasets/Wine+Quality

我正在使用 R 制作两个散点图:

> plot(chlorides~(1/alcohol),data=redwinedata)
> plot(chlorides~alcohol,data=redwinedata)

但两个图看起来完全一样(轴,点,一切)。有谁知道为什么会这样?

最佳答案

$x$ 对 $y$ 的图不应与 $1/x$ 对 $y$ 的图看起来相同。我认为你犯了一个代码错误。您提供的代码不会转换预测器。

您需要单独计算变量并将其传递给绘图或使用 I功能。请参阅下面的示例。

x = runif(100)
y = runif(100)
plot(y ~ x)
plot(y ~ (1/x)) # looks exactly the same. It's a plot of y vs. x.....
plot(y ~ I(1/x)) # does not look exactly the same
z = 1/x
plot(y ~ z) # looks just like the last call but not like the plot of y vs. x

关于r - 为什么即使我正在转换预测变量,我的散点图看起来也完全一样?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42655871/

相关文章:

具有独特组合的 R tcrossprod

R beepr 播放太早

r - ggplot2 中的绘图树

r - 循环数字序列

r - LM 和 LME 结果的标准误

r - lme4/矩阵 : Entry Point Not Found - how to fix?

deep-learning - 使用深度学习在回归中获得多个输出

r - 更改 "R"中 nls.lm() 中的目标函数

r - 如何按行运行线性回归并仅在 R 中具有 NA 的元素中填充数据?

python - 如何从 LogisticRegressionCV 和 GridSearchCV 获得可比较和可重现的结果