[R] logistic regression

Daniel Malter daniel at umd.edu
Thu Aug 13 07:42:34 CEST 2009


This reads as if you need to pick up a methods book on regression more
generally. My guess is that "teaching method" is perfectly collinear with
"TotalHours." Therefore, your model matrix is rank deficient. That is, if it
is the case that teaching method=(1), (2), and (3) imply total hours=(0),
(1), and (2), respectively, then, obviously, the effects of teaching and
total hours are not discernable. R will automatically drop such collinear
variables, which is most likely the reason for you getting NA results.
Include either and you will get a (the same) result.

How to investigate if this is the reason: do

table(teaching.method,TotalHours)

If this outputs a diagonal matrix (a matrix with all zeros off the main
diagonal), then the reason for the NAs is the perfect collinearity between
teaching.method and TotalHours

Further, you might want to include one of these variables as factors/dummies
(or even factors coded as polynomial orthogonal contrasts), which is another
reason to pick up a book on the topic.

HTH,
Daniel


-------------------------
cuncta stricte discussurus
-------------------------

-----Ursprüngliche Nachricht-----
Von: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] Im
Auftrag von SNN
Gesendet: Wednesday, August 12, 2009 5:33 PM
An: r-help at r-project.org
Betreff: [R] logistic regression


Hi All,

I have data with 400 individuals and the following information
Grade: pass or fail
Sex: male or female
Age
Teaching.metho : can be  1,2,3
TotalHours: can be 0,1,2

I want to fit a logistic regression and for the TotalHours I am getting
nothing! What could be the reason. What does the following message mean ?
 [Coefficients: (1 not defined because of singularities)] 

Below is my output

Thanks for your help



Call:
glm(formula = Grade~ sex + age + teaching.method+ TotalHours, 
    family = binomial, data = data)

Deviance Residuals: 
    Min       1Q   Median       3Q      Max  
-1.3844  -0.9686  -0.7688   1.2304   1.8871  

Coefficients: (1 not defined because of singularities)
                Estimate Std. Error z value Pr(>|z|)   
(Intercept)     -3.62178    1.20480  -3.006  0.00265 **
sex             -0.32709    0.28539  -1.146  0.25175   
age              0.04405    0.01371   3.213  0.00132 **
teaching.method   0.23878    0.20553   1.162  0.24533   
TotalHours             NA         NA      NA       NA   
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 

(Dispersion parameter for binomial family taken to be 1)

    Null deviance: 297.38  on 223  degrees of freedom Residual deviance:
282.93  on 220  degrees of freedom
AIC: 290.93


--
View this message in context:
http://www.nabble.com/logistic-regression-tp24943431p24943431.html
Sent from the R help mailing list archive at Nabble.com.

______________________________________________
R-help at r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.




More information about the R-help mailing list