首页 > 解决方案 > R中GAM模型的简单可视化

问题描述

我正在使用这个:

library(datasets)
library(ggplot2)

model <- gam(
    Petal.Width ~

    s(Sepal.Length)

    , data = iris
    , method = "REML"
)

ggplot(iris, aes(x = Petal.Width, y = Sepal.Length)) +
geom_point() +
geom_smooth(method = "gam", formula = Petal.Width ~ s(Sepal.Length))

但得到这个错误:

Warning message:
Computation failed in `stat_smooth()`:
object 'Petal.Width' not found 

有任何想法吗?谢谢!

标签: r

解决方案


推荐阅读