# The logistic regression model

## Logistic Regression Model

We will use the generalized linear model function glm() to estimate a logistic regression-remember that we have a dummy dependent variable. The function is very similar to the lm() function- the only difference is that there is an additional argument called family(). The family() function will tell R that we want to estimate a logistic regression.

Letâ€™s see it in practice, all we have to do is to include the following line in the glm() function:

family = binomial(link = "logit") argument
logit.model<-glm(incumbent~ sociotropic_pros+egocentric_retro+left_right, data=eco_voting,family = binomial(link = "logit"))
summary(logit.model)
##
## Call:
## glm(formula = incumbent ~ sociotropic_pros + egocentric_retro +
##     left_right, family = binomial(link = "logit"), data = eco_voting)
##
## Deviance Residuals:
##     Min       1Q   Median       3Q      Max
## -2.7153  -0.7594  -0.3541   0.7221   2.9429
##
## Coefficients:
##                  Estimate Std. Error z value Pr(>|z|)
## (Intercept)      -5.88946    0.49714 -11.847  < 2e-16 ***
## sociotropic_pros  0.29030    0.10063   2.885  0.00392 **
## egocentric_retro  0.23379    0.10793   2.166  0.03030 *
## left_right        0.79782    0.06612  12.067  < 2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for binomial family taken to be 1)
##
##     Null deviance: 1042.32  on 793  degrees of freedom
## Residual deviance:  742.53  on 790  degrees of freedom
##   (479 observations deleted due to missingness)
## AIC: 750.53
##
## Number of Fisher Scoring iterations: 5

Interpreting the results of a logistic regression model is not the same as the interpretation of the linear model. Remember that for the linear model the coefficient describe the effect of a unit change (increase or decrease) in X on Y.

For the logistic regression the interpretation of the coefficient is: a one unit change (increase or decrease) in X is associated with a $$\hat{\beta}$$ change in the log-odds of the dependent variable (Y), holding all other variables constant.

For example, the coefficient describing perceptions about the economy sociotropic_pros is equal to $$0.047$$, implying that the log-odds of voting for the party in government are $$0.047$$ higher when the respondent believe that the economy is doing well, holding all other variables constant.