# Logistic regression in R returning NA values

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.

-
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. –  Davy Kavanagh Apr 4 '12 at 13:20