Importing data from the British Election Study in SPSS format

In order to run this notebook successfully, you have to download the 1983 British Election Study from the BES website and upload it to the virtual machine on which this notebook runs. To do this,

  1. pull down the “File” menu item and select “Open”
  2. An overview of the folder that contains the notebook opens.
  3. The folder view has a button labelled “Upload”. Use this to upload the file that you downloaded from the BES website. Its name should be 83BES.sav.

Note that the uploaded data will disappear, when the notebook container is reset.

The following also makes use of the memisc package. You may need to install it from CRAN using the code install.packages("memisc") if you want to run this on your computer. (The package is already installed on the notebook container, however.)


library(memisc) # The functions used here are in this package.
Loading required package: lattice

Loading required package: MASS


Attaching package: ‘memisc’


The following objects are masked from ‘package:stats’:

    contr.sum, contr.treatment, contrasts


The following object is masked from ‘package:base’:

    as.array



# The first step: Optainin the location and description of the survey data file
BES.1983.por <- spss.portable.file("83BES.sav")

description(BES.1983.por[1:30])

 ID1      'SERIAL NUMBER'
 RECORD1  'CARD NUMBER'
 AREANO   'AREA NUMBER'
 PANO     'PA CONSTITUENCY NUMBER'
 MOVER    'MOVER-REISSUE CODE'
 INT      'INTERVIEWER NUMBER'
 FGLCLASS 'FATHER'S GOLDTHORPE-LLEWELLYN CLASS'
 RGLCLASS 'RESPONDENT'S GOLDTHORPE-LLEWELLYN CLASS'
 SGLCLASS 'SPOUSE'S GOLDTHORPE-LLEWELLYN CLASS'
 FGHCLASS 'FATHER'S GOLDTHORPE-HEATH CLASS'
 RGHCLASS 'RESPONDENT'S GOLDTHORPE-HEATH CLASS'
 SGHCLASS 'SPOUSE'S GOLDTHORPE-HEATH CLASS'
 Q1       'CARE WHICH PARTY WON'
 Q2A      'FOLLOWED ELECTION BROADCASTS'
 Q2B      'READ ABOUT CAMPAIGN IN NEWSPAPER'
 Q2C      '[IF READ NEWSPP] WHICH DAILY ON CAMPAIGN'
 Q2D      'HEARD CANDIDATE AT POLITICAL MEETING'
 Q2E      'CANVASSED FOR CANDIDATE'
 Q2F      'PUT UP POLITICAL PARTY POSTER'
 Q2G      'CANVASSER CALLED DURING CAMPAIGN'
 Q2H1     'CON CANVASSER CALLED'
 Q2H2     'LAB CANVASSER CALLED'
 Q2H3     'ALLIANCE CANVASSER CALLED'
 Q2H4     'LIB CANVASSER CALLED'
 Q2H5     'SOCIAL DEMOCRACTIC CANVASSER CALLED'
 Q2H6     'SNP CANVASSER CALLED'
 Q2H7     'PLAID CYMRU CANVASSER CALLED'
 Q2H8     'OTHER PARTY CANVASSER CALLED'
 Q2H9     'ECOLOGY PARTY CANVASSER CALLED'
 Q2H10    'NATIONAL FRONT CANVASSER CALLED'


# The second step: Loading a subset of the data - only the variables that are
# really needed for the analysis.
BES.1983.classvot <- subset(
    BES.1983.por,
    select=c(
        voted          = Q7A,
        vote           = Q9A,
        lrself         = Q46G,
        fglclass       = FGLCLASS,
        rglclass       = RGLCLASS,
        sglclass       = SGLCLASS,
        ethnicity      = Q64A,
        gender         = Q64B,
        age            = Q56,
        educ           = Q59A,
        religion       = Q63A,
        religatt       = Q63B
    ))
description(BES.1983.classvot)

 voted     'DID RESPONDENT VOTE 1983'
 vote      '[IF VOTED] PARTY VOTED FOR'
 lrself    'LEFT,RIGHT SCALE: R'S POSITION 1983'
 fglclass  'FATHER'S GOLDTHORPE-LLEWELLYN CLASS'
 rglclass  'RESPONDENT'S GOLDTHORPE-LLEWELLYN CLASS'
 sglclass  'SPOUSE'S GOLDTHORPE-LLEWELLYN CLASS'
 ethnicity 'RESPONDENT'S ETHNIC ORIGIN'
 gender    'RESPONDENT'S SEX'
 age       'RESPONDENT'S AGE LAST BIRTHDAY'
 educ      'AGE RESPONDENT LEFT SCHOOL'
 religion  'RESPONDENT'S RELIGION'
 religatt  '[IF RELIGION] FREQUENCY OF ATTENDANCE'


# Declaring the measurement level of a single variable
measurement(BES.1983.classvot$lrself) <- "interval"

# Declaring the measurement level of several variables
BES.1983.classvot <- within(BES.1983.classvot,{
   measurement(lrself) <- "interval"
   measurement(age) <- "interval"
   measurement(educ) <- "interval"
})

# Declaring the measurement level of several variables using a loop
BES.1983.classvot <- within(BES.1983.classvot,{
   foreach(var=c(lrself,age,educ),{
           measurement(var) <- "interval"
   })
})

# Obtaining the codebook a single variable
codebook(BES.1983.classvot["age"])
================================================================================

   age 'RESPONDENT'S AGE LAST BIRTHDAY'

--------------------------------------------------------------------------------

   Storage mode: double
   Measurement: interval

   Values and labels       N Percent

   99 'NA'                20     0.5

        Min: 18.000
        Max: 99.000
       Mean: 45.704
   Std.Dev.: 18.174


# Declaring the missing values for this variable
missing.values(BES.1983.classvot$age) <- 99

# Declaring several missing values
BES.1983.classvot <- within(BES.1983.classvot,{
    missing.values(voted)     <- 9
    missing.values(vote)      <- 95:99
    missing.values(lrself)    <- 95:99
    missing.values(fglclass)  <- 0
    missing.values(rglclass)  <- 0
    missing.values(sglclass)  <- 0
    missing.values(ethnicity) <- 9
    missing.values(gender)    <- 9
    missing.values(age)       <- 9
    missing.values(age)       <- 98:99
    missing.values(religion)  <- 99
    missing.values(religatt)  <- 7:9
})

# The codebook of the resulting data set object
codebook(BES.1983.classvot)
================================================================================

   voted 'DID RESPONDENT VOTE 1983'

--------------------------------------------------------------------------------

   Storage mode: double
   Measurement: nominal
   Missing values: 9

   Values and labels       N Percent

   1   'YES'            3295    83.3
   2   'NO'              660    16.7

================================================================================

   vote '[IF VOTED] PARTY VOTED FOR'

--------------------------------------------------------------------------------

   Storage mode: double
   Measurement: nominal
   Missing values: 95, 96, 97, 98, 99

   Values and labels         N Valid Total

    0   'SKIPPED'          660  17.1  16.7
    1   'CON'             1432  37.1  36.2
    2   'LAB'              937  24.3  23.7
    3   'ALLIANCE'         416  10.8  10.5
    4   'LIB'              278   7.2   7.0
    5   'SOCIAL  DEMOCR'    94   2.4   2.4
    6   'SNP'               33   0.9   0.8
    7   'PLAID   CYMRU'      7   0.2   0.2
    8   'ECOLOGY PARTY'      2   0.1   0.1
    9   'NATNL   FRONT'      2   0.1   0.1
   10   'COMNIST PARTY'      0   0.0   0.0
   95 M 'REFUSED'           92         2.3
   97 M 'OTHER   PARTY'      2         0.1

================================================================================

   lrself 'LEFT,RIGHT SCALE: R'S POSITION 1983'

--------------------------------------------------------------------------------

   Storage mode: double
   Measurement: interval
   Missing values: 95, 96, 97, 98, 99

   Values and labels            N Valid Total

   -10   'LEFT'                69   2.0   1.7
     0   'MID POINT'         2130  61.3  53.9
    10   'RIGHT'               74   2.1   1.9
    95 M 'NT ASKD RSN GIVN'    35         0.9
    96 M 'REFUSED'             19         0.5
    97 M 'TO RIGHT OF 10'       1         0.0
    98 M 'DK'                 393         9.9
    99 M 'NA'                  35         0.9

        Min: -10.000
        Max:  10.000
       Mean:   0.154
   Std.Dev.:   3.174

================================================================================

   fglclass 'FATHER'S GOLDTHORPE-LLEWELLYN CLASS'

--------------------------------------------------------------------------------

   Storage mode: double
   Measurement: nominal
   Missing values: 0

   Values and labels              N Valid Total

   0 M 'NOT CLASSIFIED'         494        12.5
   1   'HGH GRD PROF & MAN'     337   9.7   8.5
   2   'LOW GRADE PROF & MAN'   275   7.9   7.0
   3   'ROUTINE NONMANUAL'      237   6.8   6.0
   4   'PETTY BOURGEOISIE'      483  14.0  12.2
   5   'MANUAL FOREMEN ETC'     333   9.6   8.4
   6   'SKILLED MANUAL'         961  27.8  24.3
   7   'SEMI & UNSKIL MANUAL'   835  24.1  21.1

================================================================================

   rglclass 'RESPONDENT'S GOLDTHORPE-LLEWELLYN CLASS'

--------------------------------------------------------------------------------

   Storage mode: double
   Measurement: nominal
   Missing values: 0

   Values and labels              N Valid Total

   0 M 'NOT CLASSIFIED'         203         5.1
   1   'HGH GRD PROF & MAN'     310   8.3   7.8
   2   'LOW GRADE PROF & MAN'   614  16.4  15.5
   3   'ROUTINE NONMANUAL'     1137  30.3  28.7
   4   'PETTY BOURGEOISIE'      244   6.5   6.2
   5   'MANUAL FOREMEN ETC'     227   6.1   5.7
   6   'SKILLED MANUAL'         413  11.0  10.4
   7   'SEMI & UNSKIL MANUAL'   807  21.5  20.4

================================================================================

   sglclass 'SPOUSE'S GOLDTHORPE-LLEWELLYN CLASS'

--------------------------------------------------------------------------------

   Storage mode: double
   Measurement: nominal
   Missing values: 0

   Values and labels              N Valid Total

   0 M 'NOT CLASSIFIED'        1350        34.1
   1   'HGH GRD PROF & MAN'     233   8.9   5.9
   2   'LOW GRADE PROF & MAN'   426  16.4  10.8
   3   'ROUTINE NONMANUAL'      732  28.1  18.5
   4   'PETTY BOURGEOISIE'      199   7.6   5.0
   5   'MANUAL FOREMEN ETC'     145   5.6   3.7
   6   'SKILLED MANUAL'         348  13.4   8.8
   7   'SEMI & UNSKIL MANUAL'   522  20.0  13.2

================================================================================

   ethnicity 'RESPONDENT'S ETHNIC ORIGIN'

--------------------------------------------------------------------------------

   Storage mode: double
   Measurement: nominal
   Missing values: 9

   Values and labels          N Valid Total

   1   'WHITE   EUROPEAN'  3855  97.6  97.5
   2   'INDIAN  ETC'         51   1.3   1.3
   3   'BLACK   ETC'         33   0.8   0.8
   4   'OTHER   INC CHIN'    10   0.3   0.3
   9 M 'NA'                   6         0.2

================================================================================

   gender 'RESPONDENT'S SEX'

--------------------------------------------------------------------------------

   Storage mode: double
   Measurement: nominal
   Missing values: 9

   Values and labels       N Percent

   1   'MALE'           1871    47.3
   2   'FEMALE'         2084    52.7

================================================================================

   age 'RESPONDENT'S AGE LAST BIRTHDAY'

--------------------------------------------------------------------------------

   Storage mode: double
   Measurement: interval
   Missing values: 98, 99

   Values and labels       N Percent

   99 M 'NA'              20     0.5

        Min: 18.000
        Max: 93.000
       Mean: 45.433
   Std.Dev.: 17.817

================================================================================

   educ 'AGE RESPONDENT LEFT SCHOOL'

--------------------------------------------------------------------------------

   Storage mode: double
   Measurement: interval

   Values and labels          N Percent

    0 'NO SCHOOLING'          3     0.1
   98 'STILL AT SCHOOL'       2     0.1
   99 'NA'                    7     0.2

        Min:  0.000
        Max: 99.000
       Mean: 15.636
   Std.Dev.:  4.238

================================================================================

   religion 'RESPONDENT'S RELIGION'

--------------------------------------------------------------------------------

   Storage mode: double
   Measurement: nominal
   Missing values: 99

   Values and labels           N Valid Total

    0   'NO RELIG'          1009  25.6  25.5
    1   'XIAN NO DENOM'       66   1.7   1.7
    2   'ROMAN   CATHOLIC'   453  11.5  11.5
    3   'C OF E,W ETC'      1767  44.8  44.7
    4   'CHURCH  SCOTLAND'   223   5.7   5.6
    5   'METHODST'           185   4.7   4.7
    6   'BAPTIST'             61   1.5   1.5
    7   'URC ETC'             41   1.0   1.0
    8   'OTHER   XIAN'        71   1.8   1.8
    9   'J WITNESS'           11   0.3   0.3
   12   'JEW'                 11   0.3   0.3
   13   'HINDU'               20   0.5   0.5
   14   'ISLAM   MOSLEM'      16   0.4   0.4
   15   'SIKH'                 8   0.2   0.2
   16   'BUDDHIST'             0   0.0   0.0
   97   'OTHER   NON XIAN'     2   0.1   0.1
   99 M 'NA'                  11         0.3

================================================================================

   religatt '[IF RELIGION] FREQUENCY OF ATTENDANCE'

--------------------------------------------------------------------------------

   Storage mode: double
   Measurement: nominal
   Missing values: 7, 8, 9

   Values and labels         N Valid Total

   0   'NEVER'            1089  38.2  27.5
   1   'ONCE+ A WEEK'      475  16.7  12.0
   2   'SEV TIME A MTH'    114   4.0   2.9
   3   'ONCE+ A MTH'       176   6.2   4.5
   4   'SEV TIME YR'       424  14.9  10.7
   5   'ONCE+ A YR'        283   9.9   7.2
   6   'LESS TH ONCE YR'   290  10.2   7.3
   7 M 'VARIES  DK'         74         1.9
   8 M 'SKIPPED'          1020        25.8
   9 M 'NA'                 10         0.3


options(jupyter.rich_display=TRUE)
show_html(codebook(BES.1983.classvot)) # Same information in HTML format

voted'DID RESPONDENT VOTE 1983'

Storage mode: double
Measurement: nominal
Missing values: 9

Values and labels N Percent
1 'YES' 3295 83 . 3
2 'NO' 660 16 . 7

vote'[IF VOTED] PARTY VOTED FOR'

Storage mode: double
Measurement: nominal
Missing values: 95, 96, 97, 98, 99

Values and labels N Valid Total
0 'SKIPPED' 660 17 . 1 16 . 7
1 'CON' 1432 37 . 1 36 . 2
2 'LAB' 937 24 . 3 23 . 7
3 'ALLIANCE' 416 10 . 8 10 . 5
4 'LIB' 278 7 . 2 7 . 0
5 'SOCIAL DEMOCR' 94 2 . 4 2 . 4
6 'SNP' 33 0 . 9 0 . 8
7 'PLAID CYMRU' 7 0 . 2 0 . 2
8 'ECOLOGY PARTY' 2 0 . 1 0 . 1
9 'NATNL FRONT' 2 0 . 1 0 . 1
10 'COMNIST PARTY' 0 0 . 0 0 . 0
95 M 'REFUSED' 92 2 . 3
97 M 'OTHER PARTY' 2 0 . 1

lrself'LEFT,RIGHT SCALE: R'S POSITION 1983'

Storage mode: double
Measurement: interval
Missing values: 95, 96, 97, 98, 99

Values and labels N Valid Total
-10 'LEFT' 69 2 . 0 1 . 7
0 'MID POINT' 2130 61 . 3 53 . 9
10 'RIGHT' 74 2 . 1 1 . 9
95 M 'NT ASKD RSN GIVN' 35 0 . 9
96 M 'REFUSED' 19 0 . 5
97 M 'TO RIGHT OF 10' 1 0 . 0
98 M 'DK' 393 9 . 9
99 M 'NA' 35 0 . 9

Min: -10 . 000
Max: 10 . 000
Mean: 0 . 154
Std.Dev.: 3 . 174

fglclass'FATHER'S GOLDTHORPE-LLEWELLYN CLASS'

Storage mode: double
Measurement: nominal
Missing values: 0

Values and labels N Valid Total
0 M 'NOT CLASSIFIED' 494 12 . 5
1 'HGH GRD PROF & MAN' 337 9 . 7 8 . 5
2 'LOW GRADE PROF & MAN' 275 7 . 9 7 . 0
3 'ROUTINE NONMANUAL' 237 6 . 8 6 . 0
4 'PETTY BOURGEOISIE' 483 14 . 0 12 . 2
5 'MANUAL FOREMEN ETC' 333 9 . 6 8 . 4
6 'SKILLED MANUAL' 961 27 . 8 24 . 3
7 'SEMI & UNSKIL MANUAL' 835 24 . 1 21 . 1

rglclass'RESPONDENT'S GOLDTHORPE-LLEWELLYN CLASS'

Storage mode: double
Measurement: nominal
Missing values: 0

Values and labels N Valid Total
0 M 'NOT CLASSIFIED' 203 5 . 1
1 'HGH GRD PROF & MAN' 310 8 . 3 7 . 8
2 'LOW GRADE PROF & MAN' 614 16 . 4 15 . 5
3 'ROUTINE NONMANUAL' 1137 30 . 3 28 . 7
4 'PETTY BOURGEOISIE' 244 6 . 5 6 . 2
5 'MANUAL FOREMEN ETC' 227 6 . 1 5 . 7
6 'SKILLED MANUAL' 413 11 . 0 10 . 4
7 'SEMI & UNSKIL MANUAL' 807 21 . 5 20 . 4

sglclass'SPOUSE'S GOLDTHORPE-LLEWELLYN CLASS'

Storage mode: double
Measurement: nominal
Missing values: 0

Values and labels N Valid Total
0 M 'NOT CLASSIFIED' 1350 34 . 1
1 'HGH GRD PROF & MAN' 233 8 . 9 5 . 9
2 'LOW GRADE PROF & MAN' 426 16 . 4 10 . 8
3 'ROUTINE NONMANUAL' 732 28 . 1 18 . 5
4 'PETTY BOURGEOISIE' 199 7 . 6 5 . 0
5 'MANUAL FOREMEN ETC' 145 5 . 6 3 . 7
6 'SKILLED MANUAL' 348 13 . 4 8 . 8
7 'SEMI & UNSKIL MANUAL' 522 20 . 0 13 . 2

ethnicity'RESPONDENT'S ETHNIC ORIGIN'

Storage mode: double
Measurement: nominal
Missing values: 9

Values and labels N Valid Total
1 'WHITE EUROPEAN' 3855 97 . 6 97 . 5
2 'INDIAN ETC' 51 1 . 3 1 . 3
3 'BLACK ETC' 33 0 . 8 0 . 8
4 'OTHER INC CHIN' 10 0 . 3 0 . 3
9 M 'NA' 6 0 . 2

gender'RESPONDENT'S SEX'

Storage mode: double
Measurement: nominal
Missing values: 9

Values and labels N Percent
1 'MALE' 1871 47 . 3
2 'FEMALE' 2084 52 . 7

age'RESPONDENT'S AGE LAST BIRTHDAY'

Storage mode: double
Measurement: interval
Missing values: 98, 99

Values and labels N Percent
99 M 'NA' 20 0 . 5

Min: 18 . 000
Max: 93 . 000
Mean: 45 . 433
Std.Dev.: 17 . 817

educ'AGE RESPONDENT LEFT SCHOOL'

Storage mode: double
Measurement: interval

Values and labels N Percent
0 'NO SCHOOLING' 3 0 . 1
98 'STILL AT SCHOOL' 2 0 . 1
99 'NA' 7 0 . 2

Min: 0 . 000
Max: 99 . 000
Mean: 15 . 636
Std.Dev.: 4 . 238

religion'RESPONDENT'S RELIGION'

Storage mode: double
Measurement: nominal
Missing values: 99

Values and labels N Valid Total
0 'NO RELIG' 1009 25 . 6 25 . 5
1 'XIAN NO DENOM' 66 1 . 7 1 . 7
2 'ROMAN CATHOLIC' 453 11 . 5 11 . 5
3 'C OF E,W ETC' 1767 44 . 8 44 . 7
4 'CHURCH SCOTLAND' 223 5 . 7 5 . 6
5 'METHODST' 185 4 . 7 4 . 7
6 'BAPTIST' 61 1 . 5 1 . 5
7 'URC ETC' 41 1 . 0 1 . 0
8 'OTHER XIAN' 71 1 . 8 1 . 8
9 'J WITNESS' 11 0 . 3 0 . 3
12 'JEW' 11 0 . 3 0 . 3
13 'HINDU' 20 0 . 5 0 . 5
14 'ISLAM MOSLEM' 16 0 . 4 0 . 4
15 'SIKH' 8 0 . 2 0 . 2
16 'BUDDHIST' 0 0 . 0 0 . 0
97 'OTHER NON XIAN' 2 0 . 1 0 . 1
99 M 'NA' 11 0 . 3

religatt'[IF RELIGION] FREQUENCY OF ATTENDANCE'

Storage mode: double
Measurement: nominal
Missing values: 7, 8, 9

Values and labels N Valid Total
0 'NEVER' 1089 38 . 2 27 . 5
1 'ONCE+ A WEEK' 475 16 . 7 12 . 0
2 'SEV TIME A MTH' 114 4 . 0 2 . 9
3 'ONCE+ A MTH' 176 6 . 2 4 . 5
4 'SEV TIME YR' 424 14 . 9 10 . 7
5 'ONCE+ A YR' 283 9 . 9 7 . 2
6 'LESS TH ONCE YR' 290 10 . 2 7 . 3
7 M 'VARIES DK' 74 1 . 9
8 M 'SKIPPED' 1020 25 . 8
9 M 'NA' 10 0 . 3


save(BES.1983.classvot,
     file="BES-1983-classvot.RData")

Downloadable R script and interactive version

Explanation

The link with the “jupyterhub” icon directs you to an interactive Jupyter1 notebook, which runs inside a Docker container2. There are two variants of the interative notebook. One shuts down after 60 seconds and does not require a sign it. The other requires sign in using your ORCID3 credentials, yet shuts down only after 24 hours. (There is no guarantee that such a container persists that long, it may be shut down earlier for maintenance purposes.) After shutdown all data within the container will be reset, i.e. all files created by the user will be deleted.4

Above you see a rendered version of the Jupyter notebook.5

1

For more information about Jupyter see http://jupyter.org. The Jupyter notebooks make use of the IRKernel package.

2

For more information about Docker see https://docs.docker.com/. The container images were created with repo2docker, while containers are run with docker spawner.

3

ORCID is a free service for the authentication of researchers. It also allows to showcase publications and contributions to the academic community such as peer review.. See https://info.orcid.org/what-is-orcid/ for more information.

4

The Jupyter notebooks come with NO WARRANTY whatsoever. They are provided for educational and illustrative purposes only. Do not use them for production work.

5

The notebook is rendered with the help of the nbsphinx extension.