本文介绍了找不到函数plot.gam的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在研究"R中的应用程序进行统计学习简介"(ISLR),我只停留在第295页的一部分上,这是广义可加模型的实验室.当我运行以下代码时,出现错误Error in plot.gam(gam1, se = TRUE, col = "red") : could not find function "plot.gam".

I'm going through the "Introduction to Statistical Learning with Applications in R" (ISLR), and I'm stuck on a part on page 295, the lab on Generalized Additive Models. When I run the following code I get an error Error in plot.gam(gam1, se = TRUE, col = "red") : could not find function "plot.gam".

library(ISLR)
gam1 = lm(wage ~ ns(year, 4) + ns(age, 5) + education, data=Wage)
par(mfrow=c(1,3))
plot.gam(gam1, se=TRUE, col="red")

这本书说plot.gam应该是通用plot函数的一部分,所以R为什么找不到它?我应该做些不同的事情吗?我尝试用install.packages('plot', repos='http://cran.us.r-project.org')重新下载绘图库失败.

The book says that plot.gam should be part of the general plot function, so why can't R find it? Am I supposed to be doing something differently? I tried unsuccessfully to re-download the plot library with install.packages('plot', repos='http://cran.us.r-project.org').

这使我感到困惑,因为书上写着这样:

This confuses me because the book says this:

推荐答案

使用plot.Gam而不是plot.gam.

软件更新,但本书没有跟上.查看 gam软件包的更改日志,我们可以看到情况在2018年初有所改变:

Software updates, but the book has not kept up. Checking the change log for the gam package, we can see that the case was changed in early 2018:

这篇关于找不到函数plot.gam的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-27 22:27