Libraries

library(arules)   
library(arulesViz)
library(dplyr)
library(ggplot2)

Data preprocessing

Loading data from csv file and printing first few rows in order to check if it was loaded correctly:

data <- read.csv("ESS11.csv")
head(data)
##       name essround edition   proddate  idno cntry   dweight   pspwght
## 1 ESS11e02       11       2 20.11.2024 50014    AT 1.1851145 0.3928906
## 2 ESS11e02       11       2 20.11.2024 50030    AT 0.6098981 0.3251533
## 3 ESS11e02       11       2 20.11.2024 50057    AT 1.3923296 4.0000234
## 4 ESS11e02       11       2 20.11.2024 50106    AT 0.5560615 0.1762276
## 5 ESS11e02       11       2 20.11.2024 50145    AT 0.7227953 1.0609399
## 6 ESS11e02       11       2 20.11.2024 50158    AT 0.9926053 1.3928125
##     pweight   anweight nwspol netusoft netustm ppltrst pplfair pplhlp polintr
## 1 0.3309145 0.13001321     90        5     180       5       5      5       1
## 2 0.3309145 0.10759795     90        5     570      10       0      1       2
## 3 0.3309145 1.32366590     30        5      30       6       9      8       2
## 4 0.3309145 0.05831629     15        1    6666       6       6      6       3
## 5 0.3309145 0.35108042     60        5     120       6       3      8       2
## 6 0.3309145 0.46090190    120        5     120       8       8      4       2
##   psppsgva actrolga psppipla cptppola trstprl trstlgl trstplc trstplt trstprt
## 1        4        5        4        5       6       9      10       5       5
## 2        3        2        3        2       6       6       4       1       0
## 3        4        4        4        3       7       5       8       4       4
## 4        2        2        2        3       5       6       9       3       3
## 5        3        1        4        3       6       8       8       5       5
## 6        2        3        2        3       3       5       7       5       5
##   trstep trstun vote prtvtdat prtvtebe prtvtchr prtvtccy prtvtffi prtvtffr
## 1      5      5    1        1       NA       NA       NA       NA       NA
## 2      5      5    1        5       NA       NA       NA       NA       NA
## 3      7      5    1        5       NA       NA       NA       NA       NA
## 4      4      4    2       66       NA       NA       NA       NA       NA
## 5      6      8    1        5       NA       NA       NA       NA       NA
## 6      4      6    1        7       NA       NA       NA       NA       NA
##   prtvgde1 prtvgde2 prtvtegr prtvthhu prtvteis prtvteie prtvteit prtvclt1
## 1       NA       NA       NA       NA       NA       NA       NA       NA
## 2       NA       NA       NA       NA       NA       NA       NA       NA
## 3       NA       NA       NA       NA       NA       NA       NA       NA
## 4       NA       NA       NA       NA       NA       NA       NA       NA
## 5       NA       NA       NA       NA       NA       NA       NA       NA
## 6       NA       NA       NA       NA       NA       NA       NA       NA
##   prtvclt2 prtvclt3 prtvtinl prtvtcno prtvtfpl prtvtept prtvtbrs prtvtesk
## 1       NA       NA       NA       NA       NA       NA       NA       NA
## 2       NA       NA       NA       NA       NA       NA       NA       NA
## 3       NA       NA       NA       NA       NA       NA       NA       NA
## 4       NA       NA       NA       NA       NA       NA       NA       NA
## 5       NA       NA       NA       NA       NA       NA       NA       NA
## 6       NA       NA       NA       NA       NA       NA       NA       NA
##   prtvtgsi prtvtges prtvtdse prtvthch prtvtdgb contplt donprty badge sgnptit
## 1       NA       NA       NA       NA       NA       2       2     2       2
## 2       NA       NA       NA       NA       NA       2       2     1       1
## 3       NA       NA       NA       NA       NA       1       1     2       1
## 4       NA       NA       NA       NA       NA       2       2     2       2
## 5       NA       NA       NA       NA       NA       2       2     2       1
## 6       NA       NA       NA       NA       NA       2       2     2       2
##   pbldmna bctprd pstplonl volunfp clsprty prtcleat prtclebe prtclbhr prtclccy
## 1       2      2        2       2       1        1       NA       NA       NA
## 2       1      1        2       1       1        5       NA       NA       NA
## 3       1      1        1       1       1        5       NA       NA       NA
## 4       2      2        2       2       2       66       NA       NA       NA
## 5       2      2        2       2       1        5       NA       NA       NA
## 6       2      1        2       2       2       66       NA       NA       NA
##   prtclgfi prtclgfr prtclgde prtclegr prtclihu prtcleis prtclfie prtclfit
## 1       NA       NA       NA       NA       NA       NA       NA       NA
## 2       NA       NA       NA       NA       NA       NA       NA       NA
## 3       NA       NA       NA       NA       NA       NA       NA       NA
## 4       NA       NA       NA       NA       NA       NA       NA       NA
## 5       NA       NA       NA       NA       NA       NA       NA       NA
## 6       NA       NA       NA       NA       NA       NA       NA       NA
##   prtclclt prtclhnl prtclcno prtcljpl prtclgpt prtclbrs prtclesk prtclgsi
## 1       NA       NA       NA       NA       NA       NA       NA       NA
## 2       NA       NA       NA       NA       NA       NA       NA       NA
## 3       NA       NA       NA       NA       NA       NA       NA       NA
## 4       NA       NA       NA       NA       NA       NA       NA       NA
## 5       NA       NA       NA       NA       NA       NA       NA       NA
## 6       NA       NA       NA       NA       NA       NA       NA       NA
##   prtclhes prtcldse prtclhch prtcldgb prtdgcl lrscale stflife stfeco stfgov
## 1       NA       NA       NA       NA       2       5       8      6      4
## 2       NA       NA       NA       NA       2       0       9      2      5
## 3       NA       NA       NA       NA       2       3      10      6      5
## 4       NA       NA       NA       NA       6       5       7      4      4
## 5       NA       NA       NA       NA       2       2       9      6      7
## 6       NA       NA       NA       NA       6       4       8      4      2
##   stfdem stfedu stfhlth gincdif freehms hmsfmlsh hmsacld euftf lrnobed loylead
## 1      6      8       8       2       2        4       3     6       4       4
## 2      7     10      10       1       1        5       1     9       2       5
## 3      6      5       8       1       1        5       1     7       5       3
## 4      6      5       2       1       2        4       3     5       2       9
## 5      8      9       9       2       2        4       2    10       1       2
## 6      3      3       7       2       2        4       2     3       2       2
##   imsmetn imdfetn impcntr imbgeco imueclt imwbcnt happy sclmeet inprdsc sclact
## 1       2       2       3       7       3       5     8       4       1      3
## 2       2       2       2       6       5       9     9       7       4      4
## 3       1       1       1       9       9       8     9       4       4      3
## 4       2       2       2       6       6       5     7       6       3      3
## 5       1       1       2      10      10      10     9       5       4      3
## 6       2       3       3       5       6       6     8       6       4      2
##   crmvct aesfdrk health hlthhmp atchctr atcherp rlgblg rlgdnm rlgdnbat rlgdnacy
## 1      2       2      3       3      10       5      1      1        1       NA
## 2      1       3      2       2       8       8      2     66     6666       NA
## 3      2       3      1       3       9       7      2     66     6666       NA
## 4      2       3      3       3      10       8      1      3       10       NA
## 5      2       1      2       3      10      10      1      1        1       NA
## 6      2       2      1       3       8       6      1      1        1       NA
##   rlgdnafi rlgdnade rlgdnagr rlgdnhu rlgdnais rlgdnie rlgdnlt rlgdnanl rlgdnno
## 1       NA       NA       NA      NA       NA      NA      NA       NA      NA
## 2       NA       NA       NA      NA       NA      NA      NA       NA      NA
## 3       NA       NA       NA      NA       NA      NA      NA       NA      NA
## 4       NA       NA       NA      NA       NA      NA      NA       NA      NA
## 5       NA       NA       NA      NA       NA      NA      NA       NA      NA
## 6       NA       NA       NA      NA       NA      NA      NA       NA      NA
##   rlgdnapl rlgdnapt rlgdnrs rlgdnask rlgdnase rlgdnach rlgdngb rlgblge rlgdnme
## 1       NA       NA      NA       NA       NA       NA      NA       6      66
## 2       NA       NA      NA       NA       NA       NA      NA       2      66
## 3       NA       NA      NA       NA       NA       NA      NA       1       1
## 4       NA       NA      NA       NA       NA       NA      NA       6      66
## 5       NA       NA      NA       NA       NA       NA      NA       6      66
## 6       NA       NA      NA       NA       NA       NA      NA       6      66
##   rlgdebat rlgdeacy rlgdeafi rlgdeade rlgdeagr rlgdehu rlgdeais rlgdeie rlgdelt
## 1     6666       NA       NA       NA       NA      NA       NA      NA      NA
## 2     6666       NA       NA       NA       NA      NA       NA      NA      NA
## 3        1       NA       NA       NA       NA      NA       NA      NA      NA
## 4     6666       NA       NA       NA       NA      NA       NA      NA      NA
## 5     6666       NA       NA       NA       NA      NA       NA      NA      NA
## 6     6666       NA       NA       NA       NA      NA       NA      NA      NA
##   rlgdeanl rlgdeno rlgdeapl rlgdeapt rlgders rlgdeask rlgdease rlgdeach rlgdegb
## 1       NA      NA       NA       NA      NA       NA       NA       NA      NA
## 2       NA      NA       NA       NA      NA       NA       NA       NA      NA
## 3       NA      NA       NA       NA      NA       NA       NA       NA      NA
## 4       NA      NA       NA       NA      NA       NA       NA       NA      NA
## 5       NA      NA       NA       NA      NA       NA       NA       NA      NA
## 6       NA      NA       NA       NA      NA       NA       NA       NA      NA
##   rlgdgr rlgatnd pray dscrgrp dscrrce dscrntn dscrrlg dscrlng dscretn dscrage
## 1      5       6    5       2       0       0       0       0       0       0
## 2      0       7    6       2       0       0       0       0       0       0
## 3      8       5    3       1       0       0       0       0       0       0
## 4      6       6    3       2       0       0       0       0       0       0
## 5      1       7    7       2       0       0       0       0       0       0
## 6      3       5    1       2       0       0       0       0       0       0
##   dscrgnd dscrsex dscrdsb dscroth dscrdk dscrref dscrnap dscrna ctzcntr brncntr
## 1       0       0       0       0      0       0       1      0       1       1
## 2       0       0       0       0      0       0       1      0       1       1
## 3       1       0       0       0      0       0       0      0       1       1
## 4       0       0       0       0      0       0       1      0       2       2
## 5       0       0       0       0      0       0       1      0       1       1
## 6       0       0       0       0      0       0       1      0       1       2
##   cntbrthd livecnta lnghom1 lnghom2 feethngr facntr fbrncntc mocntr mbrncntc
## 1     6666     6666     GER     000        1      1     6666      1     6666
## 2     6666     6666     GER     ENG        8      1     6666      1     6666
## 3     6666     6666     GER     ENG        1      1     6666      1     6666
## 4       RO     1989     GER     RUM        2      2       RO      2       RO
## 5     6666     6666     GER     000        1      1     6666      1     6666
## 6       CZ     1965     GER     ENG        1      2       CZ      2       CZ
##   ccnthum ccrdprs wrclmch admrclc testjc34 testjc35 testjc36 testjc37 testjc38
## 1       4       4       4       2       66       66       66        2        2
## 2       3      10       5       3       66       66       66        6        6
## 3       4       8       5       2       66       66       66        3        4
## 4       4       6       4       2       66       66       66        4        4
## 5       5      10       4       3       66       66       66        6        6
## 6       5       8       4       3       66       66       66        6        6
##   testjc39 testjc40 testjc41 testjc42 vteurmmb vteubcmb ctrlife etfruit eatveg
## 1        3        6        6        6        1       NA       8       3      3
## 2        6        3        3        2       55       NA       8       1      1
## 3        3        6        6        6        1       NA       9       4      3
## 4        4        6        6        6       55       NA       8       2      2
## 5        6        4        2        1        1       NA       9       3      3
## 6        6        3        2        0        1       NA       8       5      3
##   dosprt cgtsmok alcfreq alcwkdy alcwknd icgndra alcbnge height weighta dshltgp
## 1      3       4       3      20      22       1       5    178      90       1
## 2      5       5       3      70      64       2       2    168      74       1
## 3      3       1       4      72      72       2       5    180      95       1
## 4      3       6       7    6666    6666       6       6    167      70       1
## 5      3       1       2      24      48       2       4    168      67       0
## 6      4       5       2      24      24       2       2    155      60       1
##   dshltms dshltnt dshltref dshltdk dshltna medtrun medtrnp medtrnt medtroc
## 1       1       0        0       0       0       2       0       0       0
## 2       0       0        0       0       0       2       0       0       0
## 3       1       0        0       0       0       2       0       0       0
## 4       1       0        0       0       0       2       0       0       0
## 5       1       0        0       0       0       2       0       0       0
## 6       1       0        0       0       0       2       0       0       0
##   medtrnl medtrwl medtrnaa medtroth medtrnap medtrref medtrdk medtrna medtrnu
## 1       0       0        0        0        1        0       0       0       1
## 2       0       0        0        0        1        0       0       0       2
## 3       0       0        0        0        1        0       0       0       1
## 4       0       0        0        0        1        0       0       0       1
## 5       0       0        0        0        1        0       0       0       1
## 6       0       0        0        0        1        0       0       0       1
##   hlpfmly hlpfmhr trhltacu trhltacp trhltcm trhltch trhltos trhltho trhltht
## 1       2      66        0        0       0       0       0       0       0
## 2       1       2        0        0       0       0       0       0       0
## 3       1       1        0        0       1       0       0       0       0
## 4       2      66        0        0       0       0       0       0       0
## 5       2      66        0        0       0       0       0       1       1
## 6       1       1        0        0       0       0       0       0       1
##   trhlthy trhltmt trhltpt trhltre trhltsh trhltnt trhltref trhltdk trhltna
## 1       0       0       0       0       0       1        0       0       0
## 2       0       0       0       0       0       1        0       0       0
## 3       0       0       0       0       0       0        0       0       0
## 4       0       0       0       0       0       1        0       0       0
## 5       0       0       0       0       0       0        0       0       0
## 6       0       1       1       0       0       0        0       0       0
##   fltdpr flteeff slprl wrhpp fltlnl enjlf fltsd cldgng hltprhc hltprhb hltprbp
## 1      1       1     1     3      1     3     1      1       0       1       0
## 2      2       2     3     3      3     4     2      2       1       0       0
## 3      2       2     3     3      1     3     1      2       0       0       0
## 4      2       2     3     2      2     2     2      2       0       1       0
## 5      1       1     1     3      1     3     1      1       0       0       0
## 6      1       2     2     4      1     4     1      2       0       1       0
##   hltpral hltprbn hltprpa hltprpf hltprsd hltprsc hltprsh hltprdi hltprnt
## 1       0       0       0       0       0       0       0       0       0
## 2       0       0       0       0       0       0       0       0       0
## 3       0       0       0       1       0       0       0       0       0
## 4       0       1       0       0       0       0       0       1       0
## 5       0       0       0       0       0       0       0       0       1
## 6       0       0       0       0       1       0       0       0       0
##   hltprref hltprdk hltprna hltphhc hltphhb hltphbp hltphal hltphbn hltphpa
## 1        0       0       0       0       0       0       0       0       0
## 2        0       0       0       0       0       0       0       0       0
## 3        0       0       0       0       0       0       0       0       1
## 4        0       0       0       0       0       0       0       1       0
## 5        0       0       0       0       0       0       0       0       0
## 6        0       0       0       0       0       0       0       0       0
##   hltphpf hltphsd hltphsc hltphsh hltphdi hltphnt hltphnap hltphref hltphdk
## 1       0       0       0       0       0       1        0        0       0
## 2       0       0       0       0       0       0        0        1       0
## 3       1       0       0       0       0       0        0        0       0
## 4       0       0       0       0       1       0        0        0       0
## 5       0       0       0       0       0       0        1        0       0
## 6       0       0       0       0       0       1        0        0       0
##   hltphna hltprca cancfre cnfpplh fnsdfml jbexpvi jbexpti jbexpml jbexpmc
## 1       0       3       6       4       5       0       0       0       0
## 2       0       3       6       2       4       0       0       0       0
## 3       0       3       6       4       2       0       0       0       0
## 4       0       3       6       4       3       0       1       1       0
## 5       0       3       6       5       5       0       0       0       0
## 6       0       3       6       4       4       0       0       0       0
##   jbexpnt jbexpnap jbexpref jbexpdk jbexpna jbexevl jbexevh jbexevc jbexera
## 1       0        1        0       0       0       0       0       0       0
## 2       1        0        0       0       0       0       0       0       0
## 3       1        0        0       0       0       0       0       0       0
## 4       0        0        0       0       0       0       0       0       0
## 5       1        0        0       0       0       0       0       0       0
## 6       1        0        0       0       0       0       0       0       0
##   jbexecp jbexebs jbexent jbexenap jbexeref jbexedk jbexena nobingnd likrisk
## 1       0       0       0        1        0       0       0        1       2
## 2       0       0       1        0        0       0       0        2       0
## 3       0       0       1        0        0       0       0        2       0
## 4       1       1       0        0        0       0       0        2       0
## 5       0       0       1        0        0       0       0        2       1
## 6       0       0       1        0        0       0       0        2       2
##   liklead sothnds actcomp mascfel femifel impbemw trmedmw trwrkmw trplcmw
## 1       4       4       5       4       0       3       3       3       3
## 2       0       6       6       3       6       3       3       2       3
## 3       3       6       6       0       6       5       3       3       3
## 4       1       6       6       0       6       5       3       1       3
## 5       0       6       6       0       5       5       3       3       3
## 6       4       5       3       6       6       6       3       2       3
##   trmdcnt trwkcnt trplcnt eqwrkbg eqpolbg eqmgmbg eqpaybg eqparep eqparlv
## 1       3       3       3       6       6       6       6       4       4
## 2       1       1       8       6       5       5       5       2       4
## 3       1       1       1       5       6       6       6       2       8
## 4       3       1       2       5       5       5       6       1       8
## 5       3       1       3       6       6       6       6       1       5
## 6       3       1       3       5       5       5       6       2       3
##   freinsw fineqpy wsekpwr weasoff wlespdm wexashr wprtbym wbrgwrm hhmmb gndr
## 1       4       3       2       3       2       2       2       2     2    1
## 2       1       2       3       3       4       2       2       3     1    2
## 3       2       1       2       2       4       2       4       2     3    2
## 4       4       1       3       3       4       2       3       2     1    2
## 5       1       1       2       2       4       1       3       3     2    1
## 6       2       1       3       4       4       4       3       1     2    2
##   gndr2 gndr3 gndr4 gndr5 gndr6 gndr7 gndr8 gndr9 gndr10 gndr11 gndr12 yrbrn
## 1     2     6     6     6     6     6    NA    NA     NA     NA     NA  1958
## 2     6     6     6     6     6     6    NA    NA     NA     NA     NA  2002
## 3     1     2     6     6     6     6    NA    NA     NA     NA     NA  1970
## 4     6     6     6     6     6     6    NA    NA     NA     NA     NA  1945
## 5     1     6     6     6     6     6    NA    NA     NA     NA     NA  1959
## 6     1     6     6     6     6     6    NA    NA     NA     NA     NA  1964
##   agea yrbrn2 yrbrn3 yrbrn4 yrbrn5 yrbrn6 yrbrn7 yrbrn8 yrbrn9 yrbrn10 yrbrn11
## 1   65   1957   6666   6666   6666   6666   6666     NA     NA      NA      NA
## 2   21   6666   6666   6666   6666   6666   6666     NA     NA      NA      NA
## 3   53   1970   2001   6666   6666   6666   6666     NA     NA      NA      NA
## 4   78   6666   6666   6666   6666   6666   6666     NA     NA      NA      NA
## 5   64   1962   6666   6666   6666   6666   6666     NA     NA      NA      NA
## 6   59   1956   6666   6666   6666   6666   6666     NA     NA      NA      NA
##   yrbrn12 rshipa2 rshipa3 rshipa4 rshipa5 rshipa6 rshipa7 rshipa8 rshipa9
## 1      NA       1      66      66      66      66      66      NA      NA
## 2      NA      66      66      66      66      66      66      NA      NA
## 3      NA       1       2      66      66      66      66      NA      NA
## 4      NA      66      66      66      66      66      66      NA      NA
## 5      NA       1      66      66      66      66      66      NA      NA
## 6      NA       1      66      66      66      66      66      NA      NA
##   rshipa10 rshipa11 rshipa12 rshpsts rshpsgb lvgptnea dvrcdeva marsts marstgb
## 1       NA       NA       NA       1      NA        1        2     66      NA
## 2       NA       NA       NA      66      NA        2        2      6      NA
## 3       NA       NA       NA       1      NA        1        2     66      NA
## 4       NA       NA       NA      66      NA        1        1      4      NA
## 5       NA       NA       NA       1      NA        1        2     66      NA
## 6       NA       NA       NA       1      NA        1        1     66      NA
##   maritalb chldhhe domicil paccmoro paccdwlr pacclift paccnbsh paccocrw
## 1        1       1       3        0        0        0        0        0
## 2        6       2       1        1        0        0        0        0
## 3        1       6       3        0        0        0        0        0
## 4        4       1       1        0        0        0        0        0
## 5        1       1       4        0        0        0        0        0
## 6        1       1       4        0        0        0        0        0
##   paccxhoc paccnois paccinro paccnt paccref paccdk paccna edulvlb eisced
## 1        0        0        0      1       0      0      0     322      3
## 2        0        0        0      0       0      0      0     423      5
## 3        0        0        0      1       0      0      0     610      6
## 4        0        0        0      1       0      0      0     422      5
## 5        0        0        0      1       0      0      0     322      3
## 6        0        0        0      1       0      0      0     313      4
##   edlveat edlvebe edlvehr edlvgcy edlvdfi edlvdfr edudde1 educde2 edlvegr
## 1       6      NA      NA      NA      NA      NA      NA      NA      NA
## 2      10      NA      NA      NA      NA      NA      NA      NA      NA
## 3      12      NA      NA      NA      NA      NA      NA      NA      NA
## 4       9      NA      NA      NA      NA      NA      NA      NA      NA
## 5       6      NA      NA      NA      NA      NA      NA      NA      NA
## 6       8      NA      NA      NA      NA      NA      NA      NA      NA
##   edlvdahu edlvdis edlvdie edlvfit edlvdlt edlvenl edlveno edlvipl edlvept
## 1       NA      NA      NA      NA      NA      NA      NA      NA      NA
## 2       NA      NA      NA      NA      NA      NA      NA      NA      NA
## 3       NA      NA      NA      NA      NA      NA      NA      NA      NA
## 4       NA      NA      NA      NA      NA      NA      NA      NA      NA
## 5       NA      NA      NA      NA      NA      NA      NA      NA      NA
## 6       NA      NA      NA      NA      NA      NA      NA      NA      NA
##   edlvdrs edlvdsk edlvesi edlvies edlvdse edlvdch educgb1 edubgb2 edagegb
## 1      NA      NA      NA      NA      NA      NA      NA      NA      NA
## 2      NA      NA      NA      NA      NA      NA      NA      NA      NA
## 3      NA      NA      NA      NA      NA      NA      NA      NA      NA
## 4      NA      NA      NA      NA      NA      NA      NA      NA      NA
## 5      NA      NA      NA      NA      NA      NA      NA      NA      NA
## 6      NA      NA      NA      NA      NA      NA      NA      NA      NA
##   eduyrs pdwrk edctn uempla uempli dsbld rtrd cmsrv hswrk dngoth dngref dngdk
## 1     12     0     0      0      0     0    1     0     0      0      0     0
## 2     14     0     1      0      0     0    0     0     0      0      0     0
## 3     16     1     0      0      0     0    0     0     0      0      0     0
## 4     14     0     0      0      0     0    1     0     0      0      0     0
## 5     12     0     0      0      0     0    1     0     0      0      0     0
## 6     16     1     0      0      0     0    0     0     0      0      0     0
##   dngna mainact mnactic crpdwk pdjobev pdjobyr emplrel emplno wrkctra estsz
## 1     0      66       6      2       2    6666       6  66666       6     6
## 2     0      66       2      2       1    2023       1  66666       2     2
## 3     0      66       1      6       6    6666       1  66666       1     1
## 4     0      66       6      2       1    2005       1  66666       1     5
## 5     0      66       6      2       1    2021       1  66666       1     2
## 6     0      66       1      6       6    6666       1  66666       1     5
##   jbspv njbspv wkdcorga iorgact wkhct wkhtot nacer2 tporgwk isco08 wrkac6m
## 1     6  66666       66      66   666    666    666      66  66666       6
## 2     2  66666        0       0    32     32     14       4   5249       2
## 3     1      4       10       9    25     25     88       6   2635       2
## 4     2  66666        5       0    39     39     87       2   2221       2
## 5     2  66666        7       7    40     35     47       4   5223       2
## 6     1     12       10       7    40     40     21       4   1112       2
##   uemp3m uemp12m uemp5yr mbtru hincsrca hinctnta hincfel edulvlpb eiscedp
## 1      2       6       6     3        4        6       1      322       3
## 2      2       6       6     3        8        1       2     6666      66
## 3      2       6       6     3        1        5       1      520       5
## 4      2       6       6     3        4        2       2     6666      66
## 5      2       6       6     2        4       77       2      322       3
## 6      2       6       6     1        1        9       1      322       3
##   edlvpfat edlvpebe edlvpehr edlvpgcy edlvpdfi edlvpdfr edupdde1 edupcde2
## 1        6       NA       NA       NA       NA       NA       NA       NA
## 2     6666       NA       NA       NA       NA       NA       NA       NA
## 3       11       NA       NA       NA       NA       NA       NA       NA
## 4     6666       NA       NA       NA       NA       NA       NA       NA
## 5        6       NA       NA       NA       NA       NA       NA       NA
## 6        6       NA       NA       NA       NA       NA       NA       NA
##   edlvpegr edlvpdahu edlvpdis edlvpdie edlvpfit edlvpdlt edlvpenl edlvpeno
## 1       NA        NA       NA       NA       NA       NA       NA       NA
## 2       NA        NA       NA       NA       NA       NA       NA       NA
## 3       NA        NA       NA       NA       NA       NA       NA       NA
## 4       NA        NA       NA       NA       NA       NA       NA       NA
## 5       NA        NA       NA       NA       NA       NA       NA       NA
## 6       NA        NA       NA       NA       NA       NA       NA       NA
##   edlvphpl edlvpept edlvpdrs edlvpdsk edlvpesi edlvphes edlvpdse edlvpdch
## 1       NA       NA       NA       NA       NA       NA       NA       NA
## 2       NA       NA       NA       NA       NA       NA       NA       NA
## 3       NA       NA       NA       NA       NA       NA       NA       NA
## 4       NA       NA       NA       NA       NA       NA       NA       NA
## 5       NA       NA       NA       NA       NA       NA       NA       NA
## 6       NA       NA       NA       NA       NA       NA       NA       NA
##   edupcgb1 edupbgb2 edagepgb pdwrkp edctnp uemplap uemplip dsbldp rtrdp cmsrvp
## 1       NA       NA       NA      0      0       0       0      0     1      0
## 2       NA       NA       NA      0      0       0       0      0     0      0
## 3       NA       NA       NA      1      0       0       0      0     0      0
## 4       NA       NA       NA      0      0       0       0      0     0      0
## 5       NA       NA       NA      0      0       0       0      0     1      0
## 6       NA       NA       NA      1      0       0       0      0     0      0
##   hswrkp dngothp dngdkp dngnapp dngrefp dngnap mnactp crpdwkp isco08p emprelp
## 1      0       0      0       0       0      0     66       2   66666       6
## 2      0       0      0       1       0      0     66       6   66666       6
## 3      0       0      0       0       0      0     66       6    2635       1
## 4      0       0      0       1       0      0     66       6   66666       6
## 5      0       0      0       0       0      0     66       2   66666       6
## 6      0       0      0       0       0      0     66       6    3321       2
##   wkhtotp edulvlfb eiscedf edlvfeat edlvfebe edlvfehr edlvfgcy edlvfdfi
## 1     666      322       3        7       NA       NA       NA       NA
## 2     666      322       3        6       NA       NA       NA       NA
## 3       1      322       3        6       NA       NA       NA       NA
## 4     666      322       3        6       NA       NA       NA       NA
## 5     666      322       3        6       NA       NA       NA       NA
## 6       1      800       7       18       NA       NA       NA       NA
##   edlvfdfr edufcde1 edufbde2 edlvfegr edlvfdahu edlvfdis edlvfdie edlvffit
## 1       NA       NA       NA       NA        NA       NA       NA       NA
## 2       NA       NA       NA       NA        NA       NA       NA       NA
## 3       NA       NA       NA       NA        NA       NA       NA       NA
## 4       NA       NA       NA       NA        NA       NA       NA       NA
## 5       NA       NA       NA       NA        NA       NA       NA       NA
## 6       NA       NA       NA       NA        NA       NA       NA       NA
##   edlvfdlt edlvfenl edlvfeno edlvfgpl edlvfept edlvfdrs edlvfdsk edlvfesi
## 1       NA       NA       NA       NA       NA       NA       NA       NA
## 2       NA       NA       NA       NA       NA       NA       NA       NA
## 3       NA       NA       NA       NA       NA       NA       NA       NA
## 4       NA       NA       NA       NA       NA       NA       NA       NA
## 5       NA       NA       NA       NA       NA       NA       NA       NA
## 6       NA       NA       NA       NA       NA       NA       NA       NA
##   edlvfges edlvfdse edlvfdch edufcgb1 edufbgb2 edagefgb emprf14 occf14b
## 1       NA       NA       NA       NA       NA       NA       2       9
## 2       NA       NA       NA       NA       NA       NA       2       9
## 3       NA       NA       NA       NA       NA       NA       1       6
## 4       NA       NA       NA       NA       NA       NA       1       5
## 5       NA       NA       NA       NA       NA       NA       1       4
## 6       NA       NA       NA       NA       NA       NA       1       1
##   edulvlmb eiscedm edlvmeat edlvmebe edlvmehr edlvmgcy edlvmdfi edlvmdfr
## 1      212       2        3       NA       NA       NA       NA       NA
## 2      322       3        6       NA       NA       NA       NA       NA
## 3      322       3        7       NA       NA       NA       NA       NA
## 4      212       2        3       NA       NA       NA       NA       NA
## 5      212       2        3       NA       NA       NA       NA       NA
## 6      610       6       13       NA       NA       NA       NA       NA
##   edumcde1 edumbde2 edlvmegr edlvmdahu edlvmdis edlvmdie edlvmfit edlvmdlt
## 1       NA       NA       NA        NA       NA       NA       NA       NA
## 2       NA       NA       NA        NA       NA       NA       NA       NA
## 3       NA       NA       NA        NA       NA       NA       NA       NA
## 4       NA       NA       NA        NA       NA       NA       NA       NA
## 5       NA       NA       NA        NA       NA       NA       NA       NA
## 6       NA       NA       NA        NA       NA       NA       NA       NA
##   edlvmenl edlvmeno edlvmgpl edlvmept edlvmdrs edlvmdsk edlvmesi edlvmges
## 1       NA       NA       NA       NA       NA       NA       NA       NA
## 2       NA       NA       NA       NA       NA       NA       NA       NA
## 3       NA       NA       NA       NA       NA       NA       NA       NA
## 4       NA       NA       NA       NA       NA       NA       NA       NA
## 5       NA       NA       NA       NA       NA       NA       NA       NA
## 6       NA       NA       NA       NA       NA       NA       NA       NA
##   edlvmdse edlvmdch edumcgb1 edumbgb2 edagemgb emprm14 occm14b atncrse anctrya1
## 1       NA       NA       NA       NA       NA       2       9       2    11010
## 2       NA       NA       NA       NA       NA       2       9       2    11010
## 3       NA       NA       NA       NA       NA       3      66       1    11010
## 4       NA       NA       NA       NA       NA       1       4       2    14090
## 5       NA       NA       NA       NA       NA       1       7       2    11010
## 6       NA       NA       NA       NA       NA       1       1       2    11010
##   anctrya2 regunit region ipcrtiva impricha ipeqopta ipshabta impsafea impdiffa
## 1   555555       2   AT31        3        5        2        2        2        4
## 2   555555       2   AT22        2        4        2        4        4        4
## 3    11070       2   AT33        1        4        1        3        2        4
## 4    11010       2   AT31        3        4        2        3        1        4
## 5    11018       2   AT32        3        4        2        2        2        4
## 6    11018       2   AT33        1        2        2        1        2        2
##   ipfrulea ipudrsta ipmodsta ipgdtima impfreea iphlppla ipsucesa ipstrgva
## 1        2        2        2        2        2        2        3        2
## 2        4        2        2        2        2        1        4        2
## 3        3        1        3        3        2        1        3        2
## 4        3        3        2        3        2        2        3        3
## 5        5        2        3        3        2        2        2        2
## 6        2        2        3        2        2        1        2        1
##   ipadvnta ipbhprpa iprspota iplylfra impenva imptrada impfuna testji1 testji2
## 1        5        2        2        2       2        3       3       6       6
## 2        4        2        4        1       1        4       2       6       6
## 3        4        3        3        1       1        3       2       6       6
## 4        4        3        3        2       2        2       3       6       6
## 5        4        2        2        2       2        2       2       6       6
## 6        3        1        2        1       2        2       2       6       6
##   testji3 testji4 testji5 testji6 testji7 testji8 testji9 respc19a symtc19
## 1       6       3       3       2      66      66      66        1       2
## 2       6       6       6       6      10       2       2        1       2
## 3       6       8       8       8      66      66      66        1       2
## 4       6       1       1       1      66      66      66        1       2
## 5       6       6       6       6       8       4       3        3       6
## 6       6       6       6       6       7       4       1        1       2
##   symtnc19 vacc19 recon               inwds               ainws
## 1        6      1     2 2023-11-12 14:49:50 2023-11-12 14:49:50
## 2        6      1     1 2023-10-18 09:56:32 2023-10-18 09:56:32
## 3        6      1     1 2023-09-30 13:22:49 2023-09-30 13:22:49
## 4        6      1     2 2023-06-30 14:31:46 2023-06-30 14:31:46
## 5        6      1     2 2023-07-11 10:11:00 2023-07-11 10:11:00
## 6        6      1     2 2023-10-16 08:35:24 2023-10-16 08:35:24
##                 ainwe               binwe               cinwe
## 1 2023-11-12 14:50:23 2023-11-12 15:01:14 2023-11-12 15:03:07
## 2 2023-10-18 09:58:32 2023-10-18 10:07:21 2023-10-18 10:11:42
## 3 2023-09-30 13:24:24 2023-09-30 13:34:23 2023-09-30 13:41:50
## 4 2023-06-30 14:32:40 2023-06-30 14:42:30 2023-06-30 14:50:31
## 5 2023-07-11 10:13:36 2023-07-11 10:18:33 2023-07-11 10:23:56
## 6 2023-10-16 08:37:00 2023-10-16 08:49:01 2023-10-16 08:55:53
##                 dinwe               einwe               finwe
## 1 2023-11-12 15:08:28 2023-11-12 15:14:58 2023-11-12 15:18:41
## 2 2023-10-18 10:19:27 2023-10-18 10:25:47 2023-10-18 10:32:34
## 3 2023-09-30 13:50:25 2023-09-30 13:56:10 2023-09-30 14:03:15
## 4 2023-06-30 14:53:56 2023-06-30 14:57:00 2023-06-30 15:04:03
## 5 2023-07-11 10:43:23 2023-07-11 10:56:16 2023-07-11 11:03:31
## 6 2023-10-16 09:07:39 2023-10-16 09:14:29 2023-10-16 09:29:26
##                 hinwe               iinwe               kinwe rinwe
## 1 2023-11-12 15:20:19 2023-11-12 15:20:37 2023-11-12 15:20:46      
## 2 2023-10-18 10:36:39 2023-10-18 10:37:18 2023-10-18 10:37:49      
## 3 2023-09-30 14:05:12 2023-09-30 14:05:27 2023-09-30 14:05:41      
## 4 2023-06-30 15:05:22 2023-06-30 15:05:41 2023-06-30 15:06:02      
## 5 2023-07-11 11:07:49 2023-07-11 11:08:12 2023-07-11 11:08:26      
## 6 2023-10-16 09:32:29 2023-10-16 09:33:12 2023-10-16 09:33:34      
##                 inwde               jinws               jinwe inwtm mode domain
## 1 2023-11-12 15:26:55 2023-11-12 15:21:28 2023-11-12 15:26:55    30    1      2
## 2 2023-10-18 10:44:18 2023-10-18 10:42:22 2023-10-18 10:44:18    40    1      1
## 3 2023-09-30 14:13:33 2023-09-30 14:08:31 2023-09-30 14:13:33    42    1      2
## 4 2023-06-30 15:11:21 2023-06-30 15:08:05 2023-06-30 15:11:21    34    1      1
## 5 2023-07-11 11:14:03 2023-07-11 11:10:02 2023-07-11 11:14:03    57    1      2
## 6 2023-10-16 09:42:52 2023-10-16 09:38:14 2023-10-16 09:42:52    57    1      2
##           prob stratum psu
## 1 0.0005786479     107 317
## 2 0.0011243912      69 128
## 3 0.0004925300      18 418
## 4 0.0012332522     101 295
## 5 0.0009487666     115 344
## 6 0.0006908728       7 373

The dataset contains many variables. I am selecting only those that I believe are most likely to influence hincfel:

data <- data[, c("hincfel", "uempla", "uempli", "gndr", "hinctnta", "health", "stflife", "ppltrst")]
data <- na.omit(data)
head(data)
##   hincfel uempla uempli gndr hinctnta health stflife ppltrst
## 1       1      0      0    1        6      3       8       5
## 2       2      0      0    2        1      2       9      10
## 3       1      0      0    2        5      1      10       6
## 4       2      0      0    2        2      3       7       6
## 5       2      0      0    1       77      2       9       6
## 6       1      0      0    2        9      1       8       8

Since association rule mining works best with categorical data, I convert numerical values into meaningful categories. It will also help with further rules analysis. I took categories directly from ESS11 variable description

data$hincfel <- ifelse(data$hincfel == 1, "Living comfortably", 
                ifelse(data$hincfel == 2, "Coping", 
                ifelse(data$hincfel == 3, "Difficult", 
                ifelse(data$hincfel == 4, "Very difficult", NA))))

data$gndr <- ifelse(data$gndr == 1, "Male",
             ifelse(data$gndr == 2, "Female", NA))

data$hinctnta <- ifelse(data$hinctnta %in% c(1,2), "Low income",
                 ifelse(data$hinctnta %in% c(3,4,5), "Lower-middle income",
                 ifelse(data$hinctnta %in% c(6,7,8), "Upper-middle income",
                 ifelse(data$hinctnta %in% c(9,10), "High income", NA))))

data$health <- ifelse(data$health == 1, "Very good",
               ifelse(data$health == 2, "Good",
               ifelse(data$health == 3, "Fair",
               ifelse(data$health == 4, "Bad",
               ifelse(data$health == 5, "Very bad", NA)))))

data$stflife <- ifelse(data$stflife %in% c(0,1,2,3), "Dissatisfied",
                ifelse(data$stflife %in% c(4,5,6), "Neutral",
                ifelse(data$stflife %in% c(7,8,9,10), "Satisfied", NA)))

data$ppltrst <- ifelse(data$ppltrst %in% c(0,1,2,3), "Low trust",
                ifelse(data$ppltrst %in% c(4,5,6), "Moderate trust",
                ifelse(data$ppltrst %in% c(7,8,9,10), "High trust", NA)))

Here I am changing all variables to factor data type:

data[] <- lapply(data, as.factor)
str(data)
## 'data.frame':    40156 obs. of  8 variables:
##  $ hincfel : Factor w/ 4 levels "Coping","Difficult",..: 3 1 3 1 1 3 1 3 1 1 ...
##  $ uempla  : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
##  $ uempli  : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...
##  $ gndr    : Factor w/ 2 levels "Female","Male": 2 1 1 1 2 1 1 1 1 1 ...
##  $ hinctnta: Factor w/ 4 levels "High income",..: 4 2 3 2 NA 1 3 1 4 3 ...
##  $ health  : Factor w/ 5 levels "Bad","Fair","Good",..: 2 3 5 2 3 5 3 3 3 3 ...
##  $ stflife : Factor w/ 3 levels "Dissatisfied",..: 3 3 3 3 3 3 3 3 3 3 ...
##  $ ppltrst : Factor w/ 3 levels "High trust","Low trust",..: 3 1 3 3 3 1 1 1 1 2 ...
summary(data)
##                hincfel      uempla    uempli        gndr      
##  Coping            :18108   0:39069   0:39441   Female:21396  
##  Difficult         : 5862   1: 1087   1:  715   Male  :18760  
##  Living comfortably:14309                                     
##  Very difficult    : 1426                                     
##  NA's              :  451                                     
##                                                               
##                 hinctnta           health              stflife     
##  High income        : 5502   Bad      : 2418   Dissatisfied: 2358  
##  Low income         : 5186   Fair     : 9928   Neutral     : 8791  
##  Lower-middle income:10284   Good     :17079   Satisfied   :28714  
##  Upper-middle income:10754   Very bad :  448   NA's        :  293  
##  NA's               : 8430   Very good:10230                       
##                              NA's     :   53                       
##            ppltrst     
##  High trust    :13682  
##  Low trust     :10125  
##  Moderate trust:16250  
##  NA's          :   99  
##                        
## 

I see that 451 respondents did not provide their feeling about household income, so we are removing these rows:

data <- data[!is.na(data$hincfel), ]

Association measures - Apriori algorithm

In order to proceed with Apriori alogirthm we need to convert the dataset to transactions:

transactions <- as(data, "transactions")
summary(transactions)
## transactions as itemMatrix in sparse format with
##  39705 rows (elements/itemsets/transactions) and
##  25 columns (items) and a density of 0.3115275 
## 
## most frequent items:
##          uempli=0          uempla=0 stflife=Satisfied       gndr=Female 
##             39003             38633             28437             21140 
##         gndr=Male           (Other) 
##             18565            163452 
## 
## element (itemset/transaction) length distribution:
## sizes
##     5     6     7     8 
##     3   129  8143 31430 
## 
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##   5.000   8.000   8.000   7.788   8.000   8.000 
## 
## includes extended item information - examples:
##                       labels variables             levels
## 1             hincfel=Coping   hincfel             Coping
## 2          hincfel=Difficult   hincfel          Difficult
## 3 hincfel=Living comfortably   hincfel Living comfortably
## 
## includes extended transaction information - examples:
##   transactionID
## 1             1
## 2             2
## 3             3
inspect(head(transactions, 5))
##     items                           transactionID
## [1] {hincfel=Living comfortably,                 
##      uempla=0,                                   
##      uempli=0,                                   
##      gndr=Male,                                  
##      hinctnta=Upper-middle income,               
##      health=Fair,                                
##      stflife=Satisfied,                          
##      ppltrst=Moderate trust}                    1
## [2] {hincfel=Coping,                             
##      uempla=0,                                   
##      uempli=0,                                   
##      gndr=Female,                                
##      hinctnta=Low income,                        
##      health=Good,                                
##      stflife=Satisfied,                          
##      ppltrst=High trust}                        2
## [3] {hincfel=Living comfortably,                 
##      uempla=0,                                   
##      uempli=0,                                   
##      gndr=Female,                                
##      hinctnta=Lower-middle income,               
##      health=Very good,                           
##      stflife=Satisfied,                          
##      ppltrst=Moderate trust}                    3
## [4] {hincfel=Coping,                             
##      uempla=0,                                   
##      uempli=0,                                   
##      gndr=Female,                                
##      hinctnta=Low income,                        
##      health=Fair,                                
##      stflife=Satisfied,                          
##      ppltrst=Moderate trust}                    4
## [5] {hincfel=Coping,                             
##      uempla=0,                                   
##      uempli=0,                                   
##      gndr=Male,                                  
##      health=Good,                                
##      stflife=Satisfied,                          
##      ppltrst=Moderate trust}                    5

The transactions dataset consists of 39705 transactions (respondents) and 25 unique items (categorical attributes).

The most frequent items in respondents’ data are:

summary(data$hincfel)
##             Coping          Difficult Living comfortably     Very difficult 
##              18108               5862              14309               1426

The hincfel variable represents respondents’ perceptions of their household income, ranging from Living comfortably, Coping, Difficult, and Very difficult. The majority of respondents fall into the Coping category with 18108 responses, followed by Living comfortably with 14309 responses. A total of 5862 respondents reported experiencing financial difficulties, while only 1426 respondents indicated that they find it Very difficult to manage on their current income. This distribution suggests that while many respondents feel financially stable, a significant portion still faces financial struggles.

Applying the Apriori algorithm

First of all, we begin with creating rules for all categories of hincfel. We will extract rules that meet the minimum support of 4% and confidence of 40%. This ensures that the rule appears in at least 4% of all transactions and that the consequent product is strongly associated with the antecedent in 40% of relevant cases.

rules <- apriori(transactions, 
                 parameter = list(supp = 0.04, conf = 0.4),
                 appearance = list(rhs= c("hincfel=Living comfortably", "hincfel=Coping", "hincfel=Difficult","hincfel=Very difficult"), default = "lhs"))
## Apriori
## 
## Parameter specification:
##  confidence minval smax arem  aval originalSupport maxtime support minlen
##         0.4    0.1    1 none FALSE            TRUE       5    0.04      1
##  maxlen target  ext
##      10  rules TRUE
## 
## Algorithmic control:
##  filter tree heap memopt load sort verbose
##     0.1 TRUE TRUE  FALSE TRUE    2    TRUE
## 
## Absolute minimum support count: 1588 
## 
## set item appearances ...[4 item(s)] done [0.00s].
## set transactions ...[25 item(s), 39705 transaction(s)] done [0.01s].
## sorting and recoding items ... [21 item(s)] done [0.00s].
## creating transaction tree ... done [0.01s].
## checking subsets of size 1 2 3 4 5 6 done [0.00s].
## writing ... [474 rule(s)] done [0.00s].
## creating S4 object  ... done [0.00s].
summary(rules)
## set of 474 rules
## 
## rule length distribution (lhs + rhs):sizes
##   1   2   3   4   5   6 
##   1  20 103 184 132  34 
## 
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##   1.000   3.000   4.000   4.114   5.000   6.000 
## 
## summary of quality measures:
##     support          confidence        coverage            lift       
##  Min.   :0.04020   Min.   :0.4022   Min.   :0.05516   Min.   :0.8819  
##  1st Qu.:0.05142   1st Qu.:0.4438   1st Qu.:0.10439   1st Qu.:1.0169  
##  Median :0.06352   Median :0.4771   Median :0.13406   Median :1.1377  
##  Mean   :0.08594   Mean   :0.4957   Mean   :0.18080   Mean   :1.2125  
##  3rd Qu.:0.10228   3rd Qu.:0.5190   3rd Qu.:0.20965   3rd Qu.:1.3112  
##  Max.   :0.45606   Max.   :0.7708   Max.   :1.00000   Max.   :2.1387  
##      count      
##  Min.   : 1596  
##  1st Qu.: 2042  
##  Median : 2522  
##  Mean   : 3412  
##  3rd Qu.: 4061  
##  Max.   :18108  
## 
## mining info:
##          data ntransactions support confidence
##  transactions         39705    0.04        0.4
##                                                                                                                                                                                                                 call
##  apriori(data = transactions, parameter = list(supp = 0.04, conf = 0.4), appearance = list(rhs = c("hincfel=Living comfortably", "hincfel=Coping", "hincfel=Difficult", "hincfel=Very difficult"), default = "lhs"))
plot(rules, measure = c("support", "confidence"), shading = "lift")

A total of 474 rules were generated, with support values ranging from 0.04 to 0.45 and confidence varying between 0.4 and 0.75. Lift values are mostly concentrated around 1, with a small cluster of stronger associations appearing in the top-left region.

plot(rules, method="graph")
## Warning: Too many rules supplied. Only plotting the best 100 using 'lift'
## (change control parameter max if needed).

Hincfel Categories Analysis

rules_living_comfortably <- apriori(transactions, 
                 parameter = list(supp = 0.04, conf = 0.4),
                 appearance = list(rhs= c("hincfel=Living comfortably"), default = "lhs"))
## Apriori
## 
## Parameter specification:
##  confidence minval smax arem  aval originalSupport maxtime support minlen
##         0.4    0.1    1 none FALSE            TRUE       5    0.04      1
##  maxlen target  ext
##      10  rules TRUE
## 
## Algorithmic control:
##  filter tree heap memopt load sort verbose
##     0.1 TRUE TRUE  FALSE TRUE    2    TRUE
## 
## Absolute minimum support count: 1588 
## 
## set item appearances ...[1 item(s)] done [0.00s].
## set transactions ...[25 item(s), 39705 transaction(s)] done [0.01s].
## sorting and recoding items ... [21 item(s)] done [0.00s].
## creating transaction tree ... done [0.01s].
## checking subsets of size 1 2 3 4 5 6 done [0.00s].
## writing ... [193 rule(s)] done [0.00s].
## creating S4 object  ... done [0.00s].
plot(rules_living_comfortably, measure = c("support", "confidence"), shading = "lift")

rules_living_comfortably_sorted<-sort(rules_living_comfortably, by="confidence", decreasing=TRUE)
inspect(head(rules_living_comfortably_sorted))
##     lhs                        rhs                             support confidence   coverage     lift count
## [1] {uempla=0,                                                                                             
##      uempli=0,                                                                                             
##      hinctnta=High income,                                                                                 
##      stflife=Satisfied,                                                                                    
##      ppltrst=High trust}    => {hincfel=Living comfortably} 0.04606473  0.7707543 0.05976577 2.138710  1829
## [2] {uempli=0,                                                                                             
##      hinctnta=High income,                                                                                 
##      stflife=Satisfied,                                                                                    
##      ppltrst=High trust}    => {hincfel=Living comfortably} 0.04639214  0.7700669 0.06024430 2.136802  1842
## [3] {uempla=0,                                                                                             
##      hinctnta=High income,                                                                                 
##      stflife=Satisfied,                                                                                    
##      ppltrst=High trust}    => {hincfel=Living comfortably} 0.04626621  0.7699078 0.06009319 2.136361  1837
## [4] {hinctnta=High income,                                                                                 
##      stflife=Satisfied,                                                                                    
##      ppltrst=High trust}    => {hincfel=Living comfortably} 0.04659363  0.7692308 0.06057172 2.134482  1850
## [5] {uempla=0,                                                                                             
##      gndr=Male,                                                                                            
##      hinctnta=High income,                                                                                 
##      stflife=Satisfied}     => {hincfel=Living comfortably} 0.04782773  0.7629570 0.06268732 2.117074  1899
## [6] {uempla=0,                                                                                             
##      uempli=0,                                                                                             
##      gndr=Male,                                                                                            
##      hinctnta=High income,                                                                                 
##      stflife=Satisfied}     => {hincfel=Living comfortably} 0.04765143  0.7629032 0.06246065 2.116924  1892

The rules indicate that individuals who feel financially comfortable are most often characterized by:

  • high household income
  • satisfaction with life
  • high trust in people
  • employment stability
rules_coping <- apriori(transactions, 
                 parameter = list(supp = 0.04, conf = 0.4),
                 appearance = list(rhs= c("hincfel=Coping"), default = "lhs"))
## Apriori
## 
## Parameter specification:
##  confidence minval smax arem  aval originalSupport maxtime support minlen
##         0.4    0.1    1 none FALSE            TRUE       5    0.04      1
##  maxlen target  ext
##      10  rules TRUE
## 
## Algorithmic control:
##  filter tree heap memopt load sort verbose
##     0.1 TRUE TRUE  FALSE TRUE    2    TRUE
## 
## Absolute minimum support count: 1588 
## 
## set item appearances ...[1 item(s)] done [0.00s].
## set transactions ...[25 item(s), 39705 transaction(s)] done [0.01s].
## sorting and recoding items ... [21 item(s)] done [0.00s].
## creating transaction tree ... done [0.01s].
## checking subsets of size 1 2 3 4 5 6 done [0.00s].
## writing ... [281 rule(s)] done [0.00s].
## creating S4 object  ... done [0.00s].
plot(rules_coping, measure = c("support", "confidence"), shading = "lift")

rules_coping_sorted<-sort(rules_coping, by="confidence", decreasing=TRUE)
inspect(head(rules_coping_sorted))
##     lhs                                rhs                 support confidence   coverage     lift count
## [1] {uempla=0,                                                                                         
##      hinctnta=Lower-middle income,                                                                     
##      health=Fair}                   => {hincfel=Coping} 0.04070016  0.5526676 0.07364312 1.211822  1616
## [2] {uempli=0,                                                                                         
##      hinctnta=Lower-middle income,                                                                     
##      health=Fair}                   => {hincfel=Coping} 0.04070016  0.5517241 0.07376905 1.209753  1616
## [3] {hinctnta=Lower-middle income,                                                                     
##      health=Fair}                   => {hincfel=Coping} 0.04153129  0.5505843 0.07543131 1.207254  1649
## [4] {uempla=0,                                                                                         
##      uempli=0,                                                                                         
##      hinctnta=Lower-middle income,                                                                     
##      ppltrst=Moderate trust}        => {hincfel=Coping} 0.05649163  0.5500245 0.10270747 1.206026  2243
## [5] {uempla=0,                                                                                         
##      hinctnta=Lower-middle income,                                                                     
##      ppltrst=Moderate trust}        => {hincfel=Coping} 0.05739831  0.5488921 0.10457121 1.203543  2279
## [6] {uempli=0,                                                                                         
##      hinctnta=Lower-middle income,                                                                     
##      ppltrst=Moderate trust}        => {hincfel=Coping} 0.05782647  0.5474487 0.10562901 1.200378  2296

The rules indicate that individuals who feel coping financially are most often characterized by:

  • lower-middle household income
  • fair health
  • moderate trust in people
  • employment stability
rules_difficult <- apriori(transactions, 
                 parameter = list(supp = 0.02, conf = 0.2),
                 appearance = list(rhs= c("hincfel=Difficult"), default = "lhs"))
## Apriori
## 
## Parameter specification:
##  confidence minval smax arem  aval originalSupport maxtime support minlen
##         0.2    0.1    1 none FALSE            TRUE       5    0.02      1
##  maxlen target  ext
##      10  rules TRUE
## 
## Algorithmic control:
##  filter tree heap memopt load sort verbose
##     0.1 TRUE TRUE  FALSE TRUE    2    TRUE
## 
## Absolute minimum support count: 794 
## 
## set item appearances ...[1 item(s)] done [0.00s].
## set transactions ...[25 item(s), 39705 transaction(s)] done [0.01s].
## sorting and recoding items ... [23 item(s)] done [0.00s].
## creating transaction tree ... done [0.01s].
## checking subsets of size 1 2 3 4 5 6 7 done [0.00s].
## writing ... [42 rule(s)] done [0.00s].
## creating S4 object  ... done [0.00s].
plot(rules_difficult, measure = c("support", "confidence"), shading = "lift")

rules_difficult_sorted<-sort(rules_difficult, by="confidence", decreasing=TRUE)
inspect(head(rules_difficult_sorted))
##     lhs                      rhs                    support confidence   coverage     lift count
## [1] {gndr=Female,                                                                               
##      hinctnta=Low income} => {hincfel=Difficult} 0.02647022  0.3223926 0.08210553 2.183657  1051
## [2] {uempla=0,                                                                                  
##      gndr=Female,                                                                               
##      hinctnta=Low income} => {hincfel=Difficult} 0.02493389  0.3196642 0.07800025 2.165177   990
## [3] {uempli=0,                                                                                  
##      gndr=Female,                                                                               
##      hinctnta=Low income} => {hincfel=Difficult} 0.02533686  0.3192637 0.07936028 2.162464  1006
## [4] {hinctnta=Low income} => {hincfel=Difficult} 0.04135499  0.3172334 0.13036142 2.148712  1642
## [5] {uempla=0,                                                                                  
##      uempli=0,                                                                                  
##      gndr=Female,                                                                               
##      hinctnta=Low income} => {hincfel=Difficult} 0.02382571  0.3164938 0.07528019 2.143703   946
## [6] {uempli=0,                                                                                  
##      hinctnta=Low income} => {hincfel=Difficult} 0.03908828  0.3135354 0.12466944 2.123664  1552

The rules indicate that individuals who feel financially struggling are most often characterized by:

  • low household income
  • being female
  • not actively seeking employment

These factors suggest that women with low income are more likely to experience financial difficulties than men with low income.

rules_very_difficult <- apriori(transactions, 
                 parameter = list(supp = 0.01, conf = 0.1),
                 appearance = list(rhs= c("hincfel=Very difficult"), default = "lhs"))
## Apriori
## 
## Parameter specification:
##  confidence minval smax arem  aval originalSupport maxtime support minlen
##         0.1    0.1    1 none FALSE            TRUE       5    0.01      1
##  maxlen target  ext
##      10  rules TRUE
## 
## Algorithmic control:
##  filter tree heap memopt load sort verbose
##     0.1 TRUE TRUE  FALSE TRUE    2    TRUE
## 
## Absolute minimum support count: 397 
## 
## set item appearances ...[1 item(s)] done [0.00s].
## set transactions ...[25 item(s), 39705 transaction(s)] done [0.01s].
## sorting and recoding items ... [25 item(s)] done [0.00s].
## creating transaction tree ... done [0.01s].
## checking subsets of size 1 2 3 4 5 6 7 8 done [0.00s].
## writing ... [6 rule(s)] done [0.00s].
## creating S4 object  ... done [0.00s].
plot(rules_very_difficult, measure = c("support", "confidence"), shading = "lift")

rules_very_difficult_sorted<-sort(rules_very_difficult, by="confidence", decreasing=TRUE)
inspect(head(rules_very_difficult_sorted))
##     lhs                      rhs                         support confidence   coverage     lift count
## [1] {gndr=Female,                                                                                    
##      hinctnta=Low income} => {hincfel=Very difficult} 0.01077950  0.1312883 0.08210553 3.655543   428
## [2] {hinctnta=Low income} => {hincfel=Very difficult} 0.01687445  0.1294436 0.13036142 3.604178   670
## [3] {uempli=0,                                                                                       
##      gndr=Female,                                                                                    
##      hinctnta=Low income} => {hincfel=Very difficult} 0.01002393  0.1263091 0.07936028 3.516903   398
## [4] {uempli=0,                                                                                       
##      hinctnta=Low income} => {hincfel=Very difficult} 0.01538849  0.1234343 0.12466944 3.436859   611
## [5] {uempla=0,                                                                                       
##      hinctnta=Low income} => {hincfel=Very difficult} 0.01468329  0.1202062 0.12215086 3.346975   583
## [6] {uempla=0,                                                                                       
##      uempli=0,                                                                                       
##      hinctnta=Low income} => {hincfel=Very difficult} 0.01319733  0.1132483 0.11653444 3.153243   524

This results are very similar to the results for individuals who feel financially struggling (Difficult).

Conclusions

The association rules reveal clear patterns in financial well-being, highlighting the influence of income, employment status, health, and social trust on individuals perceptions of their financial situation.

The findings emphasize the role of economic stability, employment opportunities, health status and social trust in shaping financial well-being.