geom_smooth 中的 span 参数控制什么?
What does the span argument control in geom_smooth?
我正在使用 ggplot2
包中的 geom_smooth
在时间序列散点图上创建平滑线(一年中的每一天一个点,所以我有 365 个点)。其中一个参数称为 span
,进入帮助文件 (?geom_smooth
) 给出以下描述:
span
controls the amount of smoothing for the default loess smoother. Smaller numbers produce wigglier lines, larger numbers produce smoother lines.
但是,这实际上并没有告诉我 span 参数在控制什么。设置为1没有用,设置为0.1提供了一些看起来不错的东西。
span = 0.5
span = 0.1
但是,在描述情节时,由于我不完全确定 span
实际发生了什么变化,所以我不确定如何描述平滑线。有什么指点吗?
LOESS 平滑是一种非参数形式的回归,它使用加权、滑动-window 平均值来计算最佳拟合线。在每个"window"内,计算一个加权平均值,滑动window沿x轴传递
可以使用 span 参数控制此 window 的大小。 span 元素控制 alpha,它是平滑的程度。跨度越小,'window' 越小,因此线条越嘈杂/越锯齿。
在 LOESS 而不是 span 下寻找文档。
跨度(也定义为 alpha)将决定平滑数据时移动的宽度 window。
"In a loess fit, the alpha parameter determines the width of the sliding window. More specifically, alpha gives the proportion of observations that is to be used in each local regression. Accordingly, this parameter is specified as a value between 0 and 1. The alpha value used for the loess curve in Fig. 2 is 0.65; so, each of the local regressions used to produce that curve incorporates 65% of the total data points. "
取自:
有关详细信息,请查看参考论文。
我正在使用 ggplot2
包中的 geom_smooth
在时间序列散点图上创建平滑线(一年中的每一天一个点,所以我有 365 个点)。其中一个参数称为 span
,进入帮助文件 (?geom_smooth
) 给出以下描述:
span
controls the amount of smoothing for the default loess smoother. Smaller numbers produce wigglier lines, larger numbers produce smoother lines.
但是,这实际上并没有告诉我 span 参数在控制什么。设置为1没有用,设置为0.1提供了一些看起来不错的东西。
span = 0.5
span = 0.1
但是,在描述情节时,由于我不完全确定 span
实际发生了什么变化,所以我不确定如何描述平滑线。有什么指点吗?
LOESS 平滑是一种非参数形式的回归,它使用加权、滑动-window 平均值来计算最佳拟合线。在每个"window"内,计算一个加权平均值,滑动window沿x轴传递
可以使用 span 参数控制此 window 的大小。 span 元素控制 alpha,它是平滑的程度。跨度越小,'window' 越小,因此线条越嘈杂/越锯齿。
在 LOESS 而不是 span 下寻找文档。
跨度(也定义为 alpha)将决定平滑数据时移动的宽度 window。
"In a loess fit, the alpha parameter determines the width of the sliding window. More specifically, alpha gives the proportion of observations that is to be used in each local regression. Accordingly, this parameter is specified as a value between 0 and 1. The alpha value used for the loess curve in Fig. 2 is 0.65; so, each of the local regressions used to produce that curve incorporates 65% of the total data points. "
取自:
有关详细信息,请查看参考论文。