使用带有"gam"的geom_smooth()的等效跨度. [英] Equivalent of span using geom_smooth() with "gam"
问题描述
这可能是一个非常基本的问题,但是我还没有找到答案.当 method ="gam"
时, geom_smooth
函数中的 span
参数是否等效?我对GAM总体上并不熟悉,所以我对此表示感谢.我想为n>的数据添加更灵活的(wigglier)平滑器.1'000和 method ="loess"
需要很多时间来计算.
This is probably a very basic question but I haven't found an answer yet. Is there an equivalent to the span
argument in the geom_smooth
function when method = "gam"
? I am not familiar with GAM's in general so I would appreciate any input on that. I want to add a more flexible (wigglier) smoother to data with n > 1'000 and method = "loess"
takes a lot of time to calculate.
推荐答案
mgcv :: gam
默认情况下使用惩罚回归优化平滑度.您可以将其关闭,并使用 k
参数手动指定平滑度:
mgcv::gam
by default optimizes the smoothness using penalized regression. You can switch that off and specify the smoothness manually with the k
parameter:
ggplot(mpg, aes(displ, hwy)) +
geom_point() +
geom_smooth(method = "gam",
formula = y ~ s(x, bs = "cs", fx = TRUE, k = 20))
您可能应该研究软件包mgcv的文档.
You should probably study the documentation of package mgcv.
这篇关于使用带有"gam"的geom_smooth()的等效跨度.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!