“剩余与杠杆"中的红色实线是什么?由plot.lm()产生的剧情? [英] What is the red solid line in the "residuals vs leverage" plot produced by `plot.lm()`?

查看:94
本文介绍了“剩余与杠杆"中的红色实线是什么?由plot.lm()产生的剧情?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

fit <- lm(dist ~ speed, cars)
plot(fit, which = 5)

情节中间的红色实线是什么意思?

What does the solid red line in the middle of plot mean?

我认为这与厨师的距离无关.

I think it is not about cook's distance.

推荐答案

这是LOESS回归线(具有span = 2/3degree = 2),可以通过平滑标准化残差和杠杆来实现.

It is the LOESS regression line (with span = 2/3 and degree = 2), by smoothing standardised residuals against leverage.

plot.lm()内部,变量xx是杠杆,而rsp是Pearson残差(即标准化残差).然后,通过以下方式绘制散点图和红色实线:

Internally in plot.lm(), variable xx is leverage, while rsp is Pearson residuals (i.e., standardised residuals). Then, the scattered plot as well as the red solid line is drawn via:

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>


R的?plot.lm文档未解释所有内容.您最多可以从参数"部分获得以下提示:


R documentation for ?plot.lm does not explain everything. You can at most get the following hint from the "Arguments" section:

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来禁止它:

Normally add.smooth = TRUE is the default, hence you see that solid red line. But you can use add = FALSE to suppress it:

plot(fit, which = 5, add.smooth = FALSE)

这篇关于“剩余与杠杆"中的红色实线是什么?由plot.lm()产生的剧情?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆