I am quite new in logistic regression. I tried to apply a logistic regression on a dataset with 3 independent variables: Gender (Categorical- either male or female), Freq_A and Freq_B (continious variables between 0 and 1). My dependent variable is binary. Either 0 or 1. Here is a couple of lines form my dataset:

     Gender       Freq_A       Freq_B Labels
1    Female 5.842289e-03 9.090465e-03      0
2      Male 3.180251e-03 4.009848e-03      1
3      Male 2.060638e-05 2.365917e-04      0
4      Male 1.930360e-02 3.868656e-03      0
5    Female 2.551375e-03 1.110913e-02      0
6    Female 3.564216e-02 3.755856e-02      1

Let me first show you what I did so far:

fname = 'logreg_input.csv'
mydata <- read.csv(fname)
is.factor(mydata$Freq_A) # FALSE
is.factor(mydata$Freq_B) # FALSE
is.factor(mydata$Gender) # TRUE
train <- mydata[1:1800,]
test <- mydata[1801:2000,]
model <- glm(Labels ~.,family=binomial(link='logit'),data=train)

This is what I got:

glm(formula = Labels ~ ., family = binomial(link = "logit"), 
    data = train)

Deviance Residuals: 
   Min      1Q  Median      3Q     Max  
-1.180  -1.134  -1.006   1.188   1.520  

            Estimate Std. Error z value Pr(>|z|)    
(Intercept) -0.38513    0.07412  -5.196 2.04e-07 ***
GenderMale   0.39087    0.09691   4.033 5.50e-05 ***
Freq_A      -0.97515    0.70525  -1.383    0.167    
Freq_B      -0.13894    0.55444  -0.251    0.802    
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

(Dispersion parameter for binomial family taken to be 1)

    Null deviance: 2478.1  on 1799  degrees of freedom
Residual deviance: 2460.8  on 1796  degrees of freedom
AIC: 2468.8

Number of Fisher Scoring iterations: 4

When I look at this, I see the GenderMale is an important variable to explain the variance in the model. (because its significant)

But then, I wanted to see how much the model explains the variance. I found that McFadden R2 is somehow similar to R2 value for Linear Regression. Therefore I measured the McFadden R2 value of the model above:


And result is :

   llh       llhNull            G2      McFadden          r2ML          r2CU 
-1.230380e+03 -1.239047e+03  1.733430e+01  6.995017e-03  9.583948e-03  1.281971e-02 

So, As McFadden R2 value I got 6.995017e-03 which is almost zero. Is that make sense to have such a small R2 value ? What does this value says about my model?

  • $\begingroup$ You have a sample size of about 1800 if I understand this correctly and are trying to predict some binary response. In many fields it's common that significance at conventional levels (given the sample size) goes hand in hand with poor explanatory power as measured crudely by substitutes for $R^2$. I am not sure what answer you seek here, but there is no obvious reason to doubt the software or that you used it correctly. $\endgroup$ – Nick Cox May 21 at 9:40
  • 1
    $\begingroup$ An analogous problem might to predict the probability that people watched a particular movie given their gender and two other measured variables. How much predictive power do you think such a model would have? How that does that compare with your problem? Do your predictors give more information, or less? In social science or epidemiology for example it's common that predictive power is poor because so much depends on individual caprice. $\endgroup$ – Nick Cox May 21 at 9:41
  • $\begingroup$ @NickCox thanks for reply. Your understanding about my sample size and aim is correct. I want to see that if any of the independent variables have a huge effect on output or not basically. By looking those values in summary or R2 value, is it possible to say that ? $\endgroup$ – zwlayer May 21 at 9:45
  • $\begingroup$ Male is an indicator, so its effect on your response can be the focus of a 2 x 2 table. Otherwise I would plot your response against each frequency variable and smooth the results. What you show us doesn't seem supportive of any kind of relationship. $\endgroup$ – Nick Cox May 21 at 9:51
  • $\begingroup$ @NickCox, if it is not too much time consuming, could you please provide an example on a toy dataset about your suggestion ? I couldn't understand what you mean. $\endgroup$ – zwlayer May 21 at 9:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.