[R] How to make try to catch warnings in logistic glm

Dieter Menne dieter.menne at menne-biomed.de
Mon Jun 22 15:25:54 CEST 2009




Fredrik Nilsson-5 wrote:
> 
>>From an earlier post I got the impression that one could promote
> warnings from a glm to errors (presumably by putting
> options(warn=1)?), then try() would flag them as errors. I’ve spent
> half the day trying to do this, but no luck. Do you have an explicit
> solution?
> 
> 

You were rather close... 

1) use warn=2
2) make sure to get the | and || right (this is nasty, I never learn it)

Dieter


 options(warn=2) #
 my.glm<-try(glm(outcome~ald + fat+ hstop + btun + time, data=DF,
family=binomial),FALSE)
 failed <- inherits(my.glm,"try-error")
 if(failed || !my.glm$converged)
 {
   res[i, 1:6]<-NA
 } else
 {


-- 
View this message in context: http://www.nabble.com/How-to-make-try-to-catch-warnings-in-logistic-glm-tp24146726p24147228.html
Sent from the R help mailing list archive at Nabble.com.




More information about the R-help mailing list