In plot.gam()
我们注意到plot()
被召唤x$smooth[[i]]
,它是类的对象:
class(x$smooth[[i]])
[1] "tprs.smooth" "mgcv.smooth"
There is a plot()
类的方法"mgcv.smooth"
在一般情况下,这就是用于情节的。?plot.gam
提到这是大多数平滑使用的默认方法,但是对于某些类型的平滑支持有特定的方法gam()
(来自详细信息部分?plot.gam
:
For smooth terms ‘plot.gam’ actually calls plot method functions
depending on the class of the smooth. Currently random effect and
Markov random field smooths have special methods, the rest use the
defaults described below.
因为某些原因,methods()
没有找到这些方法,但它们确实存在:
> mgcv:::plot.mgcv.smooth
function (x, P = NULL, data = NULL, label = "", se1.mult = 1,
se2.mult = 2, partial.resids = FALSE, rug = TRUE, se = TRUE,
scale = -1, n = 100, n2 = 40, pers = FALSE, theta = 30, phi = 30,
jit = FALSE, xlab = NULL, ylab = NULL, main = NULL, ylim = NULL,
xlim = NULL, too.far = 0.1, shade = FALSE, shade.col = "gray80",
shift = 0, trans = I, by.resids = FALSE, scheme = NULL, ...)
{
....
这可能与以下错误有关methods()
这意味着plot.function
未显示在列表中,我当前的 R 可能不会包含该修复。该方法应该正常显示,在这种情况下的一般建议是识别对象的类(如我上面所示),然后使用methods()
和类似的功能(例如showMethods()
)来确定特定方法是否可用于返回对象的类。