0

I am relatively new in R. Working on an assignment on logistic regression. as part of the assignment I am asked to "Keep Female Gender as the base class"

In my data set I have Gender variable with the following characteristics: Gender: Factor w/ 2 levels "Female","Male": 2 2 1 1 2 2 1 1 2 1 ...

When I ran logistic regression. I get Male as base class (see below). My question is how can I make Female as a base class?

glm(formula = Purchased ~ Gender + Age + EstimatedSalary, data = advertising)

Deviance Residuals: 
     Min        1Q    Median        3Q       Max  
-0.96850  -0.28334  -0.02213   0.25846   0.83315  

Coefficients:
                  Estimate Std. Error t value Pr(>|t|)    
(Intercept)     -9.203e-01  7.502e-02 -12.268  < 2e-16 ***
GenderMale       1.619e-02  3.555e-02   0.456    0.649    
Age              2.661e-02  1.715e-03  15.518  < 2e-16 ***
EstimatedSalary  3.840e-06  5.268e-07   7.290  1.7e-12 ***
vethraut
  • 35
  • 5
  • I think `Female` is the "base class" (= reference level) in your example? The coefficient `GenderMale` is the estimated effect of `Male` as compared to the reference `Female`. – neilfws Jun 23 '20 at 01:17
  • neilfws is correct. The estimate shows the incremental difference for males with reference to a base class of females. If you want to reverse this to get the effect of being female with male as a refernce then use relevel(): advertising$Gender <- relevel(advertising$Gender, ref = "Male") – Bradford Dec 31 '20 at 21:01

0 Answers0