在某个时候,glm.fit
正在被调用。这意味着您调用的功能之一或这些功能调用的功能之一正在使用glm
,glm.fit
。
而且,正如我在上面的评论中提到的那样,这是警告而不是错误,这有很大的不同。您不能从警告中触发任何R的调试工具(在有人告诉我我错了之前,请使用默认选项;-)。
如果我们更改选项以将警告变成错误,那么我们可以开始使用R的调试工具。来自?options
我们有:
‘warn’: sets the handling of warning messages. If ‘warn’ is
negative all warnings are ignored. If ‘warn’ is zero (the
default) warnings are stored until the top-level function
returns. If fewer than 10 warnings were signalled they will
be printed otherwise a message saying how many (max 50) were
signalled. An object called ‘last.warning’ is created and
can be printed through the function ‘warnings’. If ‘warn’ is
one, warnings are printed as they occur. If ‘warn’ is two or
larger all warnings are turned into errors.
所以如果你跑
options(warn = 2)
然后运行您的代码,R将引发错误。此时,您可以运行
traceback()
查看调用堆栈。这是一个例子。
> options(warn = 2)
> foo <- function(x) bar(x + 2)
> bar <- function(y) warning("don't want to use 'y'!")
> foo(1)
Error in bar(x + 2) : (converted from warning) don't want to use 'y'!
> traceback()
7: doWithOneRestart(return(expr), restart)
6: withOneRestart(expr, restarts[[1L]])
5: withRestarts({
.Internal(.signalCondition(simpleWarning(msg, call), msg,
call))
.Internal(.dfltWarn(msg, call))
}, muffleWarning = function() NULL)
4: .signalSimpleWarning("don't want to use 'y'!", quote(bar(x +
2)))
3: warning("don't want to use 'y'!")
2: bar(x + 2)
1: foo(1)
在这里,您可以忽略标记为4:
更高的框架。我们看到该foo
调用bar
并bar
生成了警告。那应该告诉您正在调用哪些函数glm.fit
。
如果现在要调试它,我们可以转到另一个选项,告诉R在遇到错误时进入调试器,并且当我们发出警告错误时,当原始警告被触发时,我们将得到一个调试器。为此,您应该运行:
options(error = recover)
这是一个例子:
> options(error = recover)
> foo(1)
Error in bar(x + 2) : (converted from warning) don't want to use 'y'!
Enter a frame number, or 0 to exit
1: foo(1)
2: bar(x + 2)
3: warning("don't want to use 'y'!")
4: .signalSimpleWarning("don't want to use 'y'!", quote(bar(x + 2)))
5: withRestarts({
6: withOneRestart(expr, restarts[[1]])
7: doWithOneRestart(return(expr), restart)
Selection:
然后,您可以进入这些框架中的任何一个,以查看引发警告时发生的情况。
要将以上选项重置为默认值,请输入
options(error = NULL, warn = 0)
至于您引用的特定警告,很可能需要在代码中允许更多迭代。一旦你发现了什么呼吁glm.fit
,制定出如何通过它的control
使用参数glm.control
-见?glm.control
。