[R] glm output format

Allan Engelhardt allane at cybaea.com
Sat Jun 5 08:27:34 CEST 2010


Look at help("tryCatch") and help("try").

Hope this helps a little

Allan

On 05/06/10 04:21, Bojuan Zhao wrote:
> Hello,
>   
> I am running a loop to compare some residual deviances obtained from glm, with codes:
> ........
>   
> OUT<-NULL
> for (i in 1:10){ 
> myglm<-glm(mat ~X1+X2+X3,family = binomial, data =myDATA)
> OUT<-c(OUT,myglm$deviance) }
>   
> .......
>   
> In the loop, X1, X2, and X3 chage with i. If X1, X2 and X3 are not highly correlated, OUT is a vector of 10 values.
>   
> The problem is:  if there there is one set of X1,X2,X3 that are highly correlated, the program stopped, with error message: "qr.solve(qr.R(object$qr)[p1, p1]) : singular matrix 'a' in solve."  
>   
> I wonder if there is a way I can skip the highly correlated case and get a NA as the response, instead of letting the whole loop stop with no OUT output at all.  That is, I want to get the OUT vector with 9 values and one NA. 
>   
> Is there a way I can do so?
>   
> Many Thanks,
> Barbara



More information about the R-help mailing list