Use data frame ‘uk’ from’seminar2 (2).RData’

The variables are:

Fulfill the following tasks:

  1. Predict interest in politics by age, gender, education and income group.
  2. Interpret the coefficients.
  3. Tell if the model fits data well.
  4. Visualize the link between interest in politics and age when respondent completed education.
knitr::opts_chunk$set(message=FALSE, warning=FALSE)
load('seminar2 (2).RData')

Predict interest in politics by age, gender, education and income group

library(MASS)
m1 = polr(polintr ~ age + sex + edu + income1, data = uk, Hess=T)
summary(m1)  # logit
## Call:
## polr(formula = polintr ~ age + sex + edu + income1, data = uk, 
##     Hess = T)
## 
## Coefficients:
##              Value Std. Error t value
## age        0.01928   0.002556   7.545
## sexFemale -0.48411   0.087338  -5.543
## edu        0.13976   0.013431  10.405
## income1    0.10993   0.016068   6.842
## 
## Intercepts:
##                                         Value   Std. Error t value
## Not at all interested|Hardly interested  1.4941  0.2525     5.9174
## Hardly interested|Quite interested       2.8338  0.2571    11.0227
## Quite interested|Very interested         5.2831  0.2795    18.9040
## 
## Residual Deviance: 4574.285 
## AIC: 4588.285 
## (530 observations deleted due to missingness)

Interpret the coefficient

Better to interpret only AME coefficients:

library(knitr)
#Marginal effects
library(erer)
#ocME(m1)  # logit
kable(ocME(m1)$out$ME.all*100)  # in percent
effect.Not at all interested effect.Hardly interested effect.Quite interested effect.Very interested
age -0.3 -0.2 0.3 0.2
sexFemale 6.7 5.1 -7.3 -4.5
edu -1.9 -1.5 2.2 1.3
income1 -1.5 -1.2 1.7 1.0

Tell if the model fits data well

library(pscl)
t(pR2(m1))
## fitting null model for pseudo-r2
##            llh   llhNull       G2   McFadden      r2ML      r2CU
## [1,] -2287.143 -2419.829 265.3719 0.05483279 0.1308678 0.1418563

Model seems to be obsolete to predict anything - McFadden’s pseudo R^2 equals to 0.05 which is too low - what a shame.

hitmiss(m1)
## Table of Actual (y) Against Predicted (p)
## Classification rule: outcome with highest probability.
##                         p=Not at all interested p=Hardly interested
## y=Not at all interested                      73                  11
## y=Hardly interested                          49                  17
## y=Quite interested                           52                  13
## y=Very interested                            14                   1
##                         p=Quite interested p=Very interested Row PCP
## y=Not at all interested                271                 0  20.563
## y=Hardly interested                    411                 0   3.564
## y=Quite interested                     758                 7  91.325
## y=Very interested                      205                10   4.348
## 
## Percent Correctly Predicted, Fitted Model: 45.35%
## Percent Correctly Predicted, Null Model  : 43.87%

So model with predictors is just slightly better than null model and guess even worse than random guessing - that’s a pity.