9
$\begingroup$

First off, I'll say I am a biologist and new to the statistics side of things so excuse my ignorance

I have a data set that consists of a binary outcome and then a bunch of trinary explanatory variables that looks something like this:

head()
 Category block21_hap1 block21_hap2 block21_hap3 block21_check
1        1            1            1            0             2
2        1            2            0            0             2
3        1            1            0            1             2
4        1            1            0            1             2
5        1            1            1            0             2
6        1            1            1            0             2

A quick summary of the data

summary()
Category block21_hap1 block21_hap2 block21_hap3 block21_check
 1:718    0:293        0:777        0:1026       2:1467       
 0:749    1:709        1:577        1: 390                    
          2:465        2:113        2:  51  

and another summary grouped by outcome levels

by(hap.ped.final, hap.ped.final$Category, summary)
hap.ped.final$Category: 1
 block21_hap1 block21_hap2 block21_hap3 block21_check
 0:146        0:374        0:518        2:718        
 1:336        1:286        1:174                     
 2:236        2: 58        2: 26                     
---------------------------------------------------------------------------- 
hap.ped.final$Category: 0
 block21_hap1 block21_hap2 block21_hap3 block21_check
 0:147        0:403        0:508        2:749        
 1:373        1:291        1:216                     
 2:229        2: 55        2: 25          

So I am trying to run logistic regression on this data. When I do this:

fit = glm(Category~ block21_hap1 + block21_hap2 + block21_hap3, data = hap.ped.final ,family = "binomial")
summary(fit)

Deviance Residuals: 
   Min      1Q  Median      3Q     Max  
-1.301  -1.177   1.059   1.177   1.200  

Coefficients: (1 not defined because of singularities)
                             Estimate Std. Error z value Pr(>|z|)
(Intercept)                 -0.039221   0.280110  -0.140    0.889
hap.ped.final$block21_hap11  0.123555   0.183087   0.675    0.500
hap.ped.final$block21_hap12  0.009111   0.295069   0.031    0.975
hap.ped.final$block21_hap21 -0.084334   0.183087  -0.461    0.645
hap.ped.final$block21_hap22 -0.013889   0.337468  -0.041    0.967
hap.ped.final$block21_hap31  0.201113   0.183087   1.098    0.272
hap.ped.final$block21_hap32        NA         NA      NA       NA

(Dispersion parameter for binomial family taken to be 1)

    Null deviance: 2033  on 1466  degrees of freedom
Residual deviance: 2028  on 1461  degrees of freedom
AIC: 2040

Number of Fisher Scoring iterations: 3

So I don't really know what a singularity is or what's going wrong here that is throwing up NA's as a result of my analysis. Is it my data, or what I'm doing to it. I tried googling the warning (or whatever you might call it) and I got some pages talking about collinearity and multilinearity, which I do not understand at all. Again, sorry for lack of knowledge here. I wish I had done more maths in undergrad.

$\endgroup$
1
  • $\begingroup$ Sorry I forgot to say. the check variable is the sum of the preceding columns and is there only to check if there is missing data across the other columns, as each one should add up to two. $\endgroup$ Commented Apr 4, 2012 at 13:20

1 Answer 1

10
$\begingroup$

Singularity means that your predictor variables are linearly dependent, i.e. one of the variables can be expressed as linear combination of other variables. Seeing that your predictor variables are dummies, you probably encountered dummy variable trap problem.

$\endgroup$
2
  • $\begingroup$ Thanks for the answer. How should I go about recoding the data so that I can run the analysis? $\endgroup$ Commented Apr 4, 2012 at 14:01
  • 1
    $\begingroup$ Singularity means that one of your predictor variable is redundant. How exactly you need to recode data, depends on what are you trying to achieve. I suggest asking a new question with more details about what your analysis is about. $\endgroup$
    – mpiktas
    Commented Apr 4, 2012 at 14:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.