I am trying to run a logistic regression analysis in R using the speedglm package. CNVs are a type of genetic variant. We measure whether CNVs occur in cases or controls and whether genes in a pathway are "hit" by the CNV or not (Pathway.hit), and how many genes were hit by the CNV that were not in the pathway (Pathway.out). I run two models with and without the Pathway.hit covariate and compare to see if a pathway is preferentially hit by cases vs controls.
the models and comparison of said are as follows:
fit1 = speedglm(status~size+Pathway.out, data=cnvs, family=binomial('logit')) fit2 = speedglm(status~size+Pathway.out+Pathway.hit, data=cnvs,family=binomial('logit')) P.anova = 1-pchisq(abs(fit1$deviance - fit2$deviance), abs(fit1$df - fit2$df))
It seems to work okay for most data I throw at it, but in a few cases I get the error:
Error in solve.default(XTX, XTz, tol = tol.solve) : system is computationally singular: reciprocal condition number = 1.87978e-16
After some googling around I think I found what's causing the problem:
by(cnvs$Pathway.hit, cnvs$status, summary) cnvs$status: 1 (controls) 0 1 13333 0 ------------------------------------ cnvs$status: 2 (cases) 0 1 10258 2
So here there no observations in controls and only 2 in cases.
If I use with normal glm method however, then it does not throw an error (but that of course doesn't necessarily mean the results will be meaningful). The reason I am using the speedglm package is that I have approximately 16,000 of these analyses to run, and using the base glm function for all 16,000 takes about 20 hours, where as I think speedglm can reduce it down to 8 or so.
So my question is, should I ignore those analyses which throw an error and list the results as NA as there were too few observations, or when speed glm fails should I retry with normal glm? In the above example there are 2 observations of the covariate in cases, but 0 in controls. Might this not be interesting? Would the analysis also fail if there were 0 in controls and 20 in cases - that would certainly be interesting would it not?