作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
fit <- lm(dist ~ speed, cars)
plot(fit, which = 5)
图中红色实线是什么意思?
我认为这与厨师的距离无关。
最佳答案
它是 LOESS 回归线(span = 2/3
和 degree = 2
),通过对杠杆率的标准化残差进行平滑处理。
在 plot.lm()
内部,变量 xx
是杠杆,而 rsp
是 Pearson 残差(即标准化残差)。然后,散点图和红色实线绘制如下:
graphics::panel.smooth(xx, rsp)
这是这个函数的作用:
> panel.smooth
function (x, y, col = par("col"), bg = NA, pch = par("pch"),
cex = 1, col.smooth = "red", span = 2/3, iter = 3, ...)
{
points(x, y, pch = pch, col = col, bg = bg, cex = cex)
ok <- is.finite(x) & is.finite(y)
if (any(ok))
lines(stats::lowess(x[ok], y[ok], f = span, iter = iter),
col = col.smooth, ...)
}
<bytecode: 0xabc0004>
<environment: namespace:graphics>
?plot.lm
的 R 文档并未解释所有内容。从“Arguments”部分最多能得到如下提示:
panel
panel function. The useful alternative to `points`, `panel.smooth` can be
chosen by `add.smooth = TRUE`.
add.smooth
logical indicating if a smoother should be added to most plots; see also
panel above.
通常 add.smooth = TRUE
是默认值,因此您会看到红色实线。但是你可以使用 add = FALSE
来抑制它:
plot(fit, which = 5, add.smooth = FALSE)
关于r - "residuals vs leverage"生成的 `plot.lm()` 图中的红色实线是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38899463/
我是一名优秀的程序员,十分优秀!