Geom_ooth()有哪些可用的方法?

我用的是 ggplot2geom_smooth()

在 Hadley Wickham 的书(“ ggplot2-Elegant Graphics for Data Analysis”)中有一个例子(第51页) ,其中使用了 method="lm"。在 在线手册中没有关于 method参数的讨论。我看到其他使用 method='loess'的谷歌搜索结果(以及这里的问题)。

有没有一个详尽的清单来解释这些选项?

在我看来,'lm'画了一条直线,而 'loess'画了一条非常平滑的曲线。我想还有其他人在参考点之间画了更多的锯齿线吧?

示例中的 se参数也不在帮助或在线文档中。

FWIW 这是我的代码。

p <- ggplot(output8, aes(age, myoutcome, group=id, colour=year_diag_cat2)) +
geom_line() + scale_y_continuous(limits = c(lwr,upr))
p + geom_smooth(aes(group=year_diag_cat2), method="loess", size=2, se=F)
157553 次浏览

Sometimes it's asking the question that makes the answer jump out. The methods and extra arguments are listed on the ggplot2 wiki stat_smooth page.

Which is alluded to on the geom_smooth() page with:

"See stat_smooth for examples of using built in model fitting if you need some more flexible, this example shows you how to plot the fits from any model of your choosing".

It's not the first time I've seen arguments in examples for ggplot graphs that aren't specifically in the function. It does make it tough to work out the scope of each function, or maybe I am yet to stumble upon a magic explicit list that says what will and will not work within each function.

The method argument specifies the parameter of the smooth statistic. You can see stat_smooth for the list of all possible arguments to the method argument.

The se argument from the example also isn't in the help or online documentation.

When 'se' in geom_smooth is set 'FALSE', the error shading region is not visible