कुछ बिंदु पर, glm.fitबुलाया जा रहा है। इसका मतलब है कि आप जिन फ़ंक्शन को कॉल करते हैं या उन फ़ंक्शन द्वारा कॉल किए गए कार्यों में से एक का उपयोग कर रहा है glm, या glm.fit।
इसके अलावा, जैसा कि मैंने ऊपर अपनी टिप्पणी में उल्लेख किया है, कि एक चेतावनी एक त्रुटि नहीं है , जो एक बड़ा अंतर बनाती है। आप किसी चेतावनी से 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)
फिर अपना कोड चलाएं, आर एक त्रुटि फेंक देगा। किस मोड़ पर, आप दौड़ सकते थे
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।
यदि आप अब इसे डीबग करना चाहते हैं, तो हम आर को डीबगर में प्रवेश करने के लिए आर को बताने के लिए एक अन्य विकल्प की ओर मुड़ सकते हैं जब यह एक त्रुटि का सामना करता है, और जैसा कि हमने चेतावनियों को गलत कर दिया है, जब मूल चेतावनी शुरू होने पर हमें डीबगर मिल जाएगा। उसके लिए आपको दौड़ना चाहिए:
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।