【发布时间】:2017-02-04 16:40:40
【问题描述】:
以下脚本中的 gam.check 将诊断结果输出到控制台(以及绘图):
library(mgcv)
set.seed(0)
dat <- gamSim(1,n=200)
b<-gam(y~s(x0)+s(x1)+s(x2)+s(x3),data=dat)
gam.check(b,pch=19,cex=.3)
上述代码中 gam.check 语句向控制台的输出是:
Method: GCV Optimizer: magic
Smoothing parameter selection converged after 8 iterations.
The RMS GCV score gradient at convergence was 0.00001072609 .
The Hessian was positive definite.
Model rank = 37 / 37
Basis dimension (k) checking results. Low p-value (k-index<1) may
indicate that k is too low, especially if edf is close to k'.
k' edf k-index p-value
s(x0) 9.000 2.318 0.996 0.44
s(x1) 9.000 2.306 0.969 0.32
s(x2) 9.000 7.655 0.961 0.24
s(x3) 9.000 1.233 1.037 0.66
我想将诊断的输出保存到一个列表(或只是将表保存到一个数据框)并且不输出任何图形。
我考虑过的事情:
-
下面的代码返回一个空对象。
x
-
查看了 gam.check 的代码,似乎我想从
中“获取”结果kchck
不幸的是,直接运行上面的代码行会产生一个'找不到函数“k.check”。
我可以使用 sink 将输出保存到控制台,但这不会关闭绘图。
Gavin Simpson 为提取绘图提供了一个很好的答案here,但我没有看到任何可以帮助解决我的问题的东西。
【问题讨论】:
-
定位于 user20650。三重“:”对我来说是新事物