R Markdown

This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see http://rmarkdown.rstudio.com.

When you click the Knit button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:

summary(cars)
##      speed           dist       
##  Min.   : 4.0   Min.   :  2.00  
##  1st Qu.:12.0   1st Qu.: 26.00  
##  Median :15.0   Median : 36.00  
##  Mean   :15.4   Mean   : 42.98  
##  3rd Qu.:19.0   3rd Qu.: 56.00  
##  Max.   :25.0   Max.   :120.00

Including Plots

You can also embed plots, for example:

Note that the echo = FALSE parameter was added to the code chunk to prevent printing of the R code that generated the plot.

packages <- c("tidyverse", "modelsummary", "forcats", "RColorBrewer", 
              "fst", "viridis", "knitr", "kableExtra", "rmarkdown", "ggridges", "viridis", "questionr")

new_packages <- packages[!(packages %in% installed.packages()[,"Package"])]
if(length(new_packages)) install.packages(new_packages)

lapply(packages, library, character.only = TRUE)
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr     1.1.3     ✔ readr     2.1.4
## ✔ forcats   1.0.0     ✔ stringr   1.5.0
## ✔ ggplot2   3.4.3     ✔ tibble    3.2.1
## ✔ lubridate 1.9.2     ✔ tidyr     1.3.0
## ✔ purrr     1.0.2     
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag()    masks stats::lag()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
## Loading required package: viridisLite
## 
## 
## Attaching package: 'kableExtra'
## 
## 
## The following object is masked from 'package:dplyr':
## 
##     group_rows
## [[1]]
##  [1] "lubridate" "forcats"   "stringr"   "dplyr"     "purrr"     "readr"    
##  [7] "tidyr"     "tibble"    "ggplot2"   "tidyverse" "stats"     "graphics" 
## [13] "grDevices" "utils"     "datasets"  "methods"   "base"     
## 
## [[2]]
##  [1] "modelsummary" "lubridate"    "forcats"      "stringr"      "dplyr"       
##  [6] "purrr"        "readr"        "tidyr"        "tibble"       "ggplot2"     
## [11] "tidyverse"    "stats"        "graphics"     "grDevices"    "utils"       
## [16] "datasets"     "methods"      "base"        
## 
## [[3]]
##  [1] "modelsummary" "lubridate"    "forcats"      "stringr"      "dplyr"       
##  [6] "purrr"        "readr"        "tidyr"        "tibble"       "ggplot2"     
## [11] "tidyverse"    "stats"        "graphics"     "grDevices"    "utils"       
## [16] "datasets"     "methods"      "base"        
## 
## [[4]]
##  [1] "RColorBrewer" "modelsummary" "lubridate"    "forcats"      "stringr"     
##  [6] "dplyr"        "purrr"        "readr"        "tidyr"        "tibble"      
## [11] "ggplot2"      "tidyverse"    "stats"        "graphics"     "grDevices"   
## [16] "utils"        "datasets"     "methods"      "base"        
## 
## [[5]]
##  [1] "fst"          "RColorBrewer" "modelsummary" "lubridate"    "forcats"     
##  [6] "stringr"      "dplyr"        "purrr"        "readr"        "tidyr"       
## [11] "tibble"       "ggplot2"      "tidyverse"    "stats"        "graphics"    
## [16] "grDevices"    "utils"        "datasets"     "methods"      "base"        
## 
## [[6]]
##  [1] "viridis"      "viridisLite"  "fst"          "RColorBrewer" "modelsummary"
##  [6] "lubridate"    "forcats"      "stringr"      "dplyr"        "purrr"       
## [11] "readr"        "tidyr"        "tibble"       "ggplot2"      "tidyverse"   
## [16] "stats"        "graphics"     "grDevices"    "utils"        "datasets"    
## [21] "methods"      "base"        
## 
## [[7]]
##  [1] "knitr"        "viridis"      "viridisLite"  "fst"          "RColorBrewer"
##  [6] "modelsummary" "lubridate"    "forcats"      "stringr"      "dplyr"       
## [11] "purrr"        "readr"        "tidyr"        "tibble"       "ggplot2"     
## [16] "tidyverse"    "stats"        "graphics"     "grDevices"    "utils"       
## [21] "datasets"     "methods"      "base"        
## 
## [[8]]
##  [1] "kableExtra"   "knitr"        "viridis"      "viridisLite"  "fst"         
##  [6] "RColorBrewer" "modelsummary" "lubridate"    "forcats"      "stringr"     
## [11] "dplyr"        "purrr"        "readr"        "tidyr"        "tibble"      
## [16] "ggplot2"      "tidyverse"    "stats"        "graphics"     "grDevices"   
## [21] "utils"        "datasets"     "methods"      "base"        
## 
## [[9]]
##  [1] "rmarkdown"    "kableExtra"   "knitr"        "viridis"      "viridisLite" 
##  [6] "fst"          "RColorBrewer" "modelsummary" "lubridate"    "forcats"     
## [11] "stringr"      "dplyr"        "purrr"        "readr"        "tidyr"       
## [16] "tibble"       "ggplot2"      "tidyverse"    "stats"        "graphics"    
## [21] "grDevices"    "utils"        "datasets"     "methods"      "base"        
## 
## [[10]]
##  [1] "ggridges"     "rmarkdown"    "kableExtra"   "knitr"        "viridis"     
##  [6] "viridisLite"  "fst"          "RColorBrewer" "modelsummary" "lubridate"   
## [11] "forcats"      "stringr"      "dplyr"        "purrr"        "readr"       
## [16] "tidyr"        "tibble"       "ggplot2"      "tidyverse"    "stats"       
## [21] "graphics"     "grDevices"    "utils"        "datasets"     "methods"     
## [26] "base"        
## 
## [[11]]
##  [1] "ggridges"     "rmarkdown"    "kableExtra"   "knitr"        "viridis"     
##  [6] "viridisLite"  "fst"          "RColorBrewer" "modelsummary" "lubridate"   
## [11] "forcats"      "stringr"      "dplyr"        "purrr"        "readr"       
## [16] "tidyr"        "tibble"       "ggplot2"      "tidyverse"    "stats"       
## [21] "graphics"     "grDevices"    "utils"        "datasets"     "methods"     
## [26] "base"        
## 
## [[12]]
##  [1] "questionr"    "ggridges"     "rmarkdown"    "kableExtra"   "knitr"       
##  [6] "viridis"      "viridisLite"  "fst"          "RColorBrewer" "modelsummary"
## [11] "lubridate"    "forcats"      "stringr"      "dplyr"        "purrr"       
## [16] "readr"        "tidyr"        "tibble"       "ggplot2"      "tidyverse"   
## [21] "stats"        "graphics"     "grDevices"    "utils"        "datasets"    
## [26] "methods"      "base"
#Load the Class Dataset

ess <- read_fst("All-ESS-Data.fst")
# Create year variable
table(ess$essround)
## 
##     1     2     3     4     5     6     7     8     9    10 
## 42359 47537 43000 56752 52458 54673 40185 44387 49519 59685
ess$year <- NA
replacements <- c(2002, 2004, 2006, 2008, 2010, 2012, 2014, 2016, 2018, 2020)
for(i in 1:10){
  ess$year[ess$essround == i] <- replacements[i]
}
table(ess$happy)
## 
##      0      1      2      3      4      5      6      7      8      9     10 
##   3933   3540   7343  13759  17016  52117  43707  87869 130802  76229  51006 
##     77     88     99 
##    330   2163    741
table(ess$netustm)
## 
##     0     1     2     3     4     5     6     7     8     9    10    11    12 
##   351    18    18    18    12    95    69    28    75    29   444     5    12 
##    13    14    15    16    18    19    20    21    23    24    25    27    28 
##     2    10   772     4     8     1   689     1     1     2    45     1     3 
##    29    30    31    34    35    36    38    39    40    43    44    45    46 
##     8  5076     3     1    40     1     2     1   342     1     2  1093     3 
##    47    48    49    50    55    58    59    60    61    62    63    64    65 
##     1     1     3   223    24     2    24 14889    39     8     8     2    67 
##    68    69    70    71    72    73    74    75    78    80    83    85    86 
##     6     8   194     3     2     1     2   320     1   308     1    26     1 
##    88    89    90    91    92    93    94    95    96    97    98    99   100 
##     2     2  5903     3     1     2     1    16     1     2     5     3   106 
##   105   106   107   108   110   113   115   118   119   120   121   122   123 
##   215     1     1     1   163     1     9     1    18 17583    18    27    17 
##   124   125   126   127   128   129   130   131   132   133   135   138   140 
##     1    37     1     2    12     3   121     1     2     3   224     3   140 
##   141   143   145   147   149   150   152   153   154   155   158   159   160 
##     1     1    13     1     3  4073     1     2     1    10     8     1    72 
##   165   168   170   175   177   179   180   181   182   183   185   186   188 
##   107     2    89     5     1    17 12524    11     6    19    39     1     4 
##   189   190   192   193   194   195   196   197   198   199   200   202   203 
##     3    85     6     1     1   109     1     1     1     2   109     4     2 
##   204   205   210   213   214   215   216   218   219   220   222   225   227 
##     2    23  2005     1     1     7     1     2     1    42     1    56     1 
##   230   235   237   238   239   240   241   242   243   244   245   246   248 
##    97     7     1     2    11  8565     4     3     7     8    16     2     2 
##   249   250   252   254   255   256   258   260   261   263   264   265   267 
##     1    42     1     1    51     1     1    68     2     1     3    12     1 
##   269   270   271   272   274   275   276   278   280   282   284   285   290 
##     1  1333     1     1     1     6     2     1    22     2     1    29    37 
##   295   298   299   300   301   302   303   304   305   306   308   310   311 
##     7     1     8  6885     7     4     1     4    13     1     3    35     1 
##   312   313   315   316   320   321   325   327   328   330   333   335   337 
##     1     1    30     1    37     1     5     1     1   813     1     2     1 
##   338   340   342   343   345   346   350   352   355   358   359   360   361 
##     1    16     1     1    25     1    23     1     1     1    15  4718     4 
##   362   363   365   366   368   370   372   375   377   380   385   390   395 
##     3     4    11     7     2    15     3    20     2    24     5   502     2 
##   397   398   400   403   405   410   415   416   419   420   421   422   423 
##     1     1    11     1    16    17     1     1     8  1812     2     1     1 
##   425   427   430   433   435   440   445   450   455   458   460   465   470 
##     5     3     8     1     8     7     3   225     2     1     7     7     8 
##   477   479   480   481   482   483   484   485   486   487   488   489   490 
##     1     6  4791     1     2     1     1     3     1     1    11     2    18 
##   492   494   495   500   505   507   510   520   522   525   527   528   530 
##     1     1    18    13     2     1   382     8     1    15     1     1    16 
##   533   535   538   539   540   542   545   549   550   555   556   560   565 
##     2     1     1    13  1504     1     4     1     3     4     1     7     1 
##   570   575   580   585   590   595   599   600   601   602   603   604   605 
##   168     1     3     7    14     6     3  4342     4     4     3     2     3 
##   608   609   610   611   612   614   615   620   625   630   631   635   637 
##     1     2    12     2     1     1     9     6     1   147     1     1     1 
##   640   642   645   647   650   653   655   659   660   662   665   670   671 
##     9     1     4     1    13     1     2     9   353     1     1     1     1 
##   675   680   690   693   696   699   710   719   720   721   722   725   727 
##     1     1    21     1     1     1     2     1  1786     1     1     2     2 
##   730   732   735   740   745   749   750   754   760   761   765   770   775 
##     3     1     2     3     1     1    48     1     2     1     4     2     1 
##   777   778   780   790   794   800   810   813   818   820   828   831   840 
##     2     1   137     1     1     1    13     1     1     1     1     1   286 
##   841   847   848   850   860   870   873   880   890   895   899   900   901 
##     1     1     1     1     1    11     1     2     2     1     4   307     2 
##   902   915   920   925   930   939   940   950   957   959   960   970   972 
##     1     3     3     1    10     1     2     3     1     2   207     1     1 
##   975   976   980   988   990  1000  1010  1020  1038  1050  1060  1078  1080 
##     2     1     2     1     5     1     1    35     1     2     1     1    76 
##  1115  1119  1140  1141  1145  1150  1167  1170  1179  1196  1200  1205  1220 
##     2     1     9     1     1     1     1     3     1     1    59     4     2 
##  1230  1231  1232  1234  1240  1250  1260  1284  1320  1343  1380  1410  1430 
##     2     1     1     1     2     1     1     1     6     1     7    11     1 
##  1439  1440  6666  7777  8888  9999 
##     1    70 41352   174  1106   384
table(ess$ipeqopt)
## 
##      1      2      3      4      5      6      7      8      9 
## 144304 183640  78430  29925  12546   3191   1379   4697   4378
# Data Cleaning - Filter to France and undertake a cleaning of the variables stated above

# Find the Data for France for each variable
france_data <- ess %>% # 
  filter(cntry == "FR") %>% 
  mutate(
    happy = ifelse(happy == 2, 0, ifelse(happy %in% c(7, 8, 9), NA, happy)), 
    ipeqopt = ifelse(ipeqopt %in% c(77, 88, 99), NA, ipeqopt), 
    netustm = ifelse(netustm %in% c(77, 88, 99), NA, netustm), 
  )
# Check by creating a table for each variable
table(france_data$happy)
## 
##    0    1    3    4    5    6   10   77   88 
##  275   57  346  514 2349 1869 1622   14   12
table(france_data$ipeqopt)
## 
##    1    2    3    4    5    6    7    8    9 
## 9185 5312 2736 1083  278  104   32   61  105
table(france_data$netustm)
## 
##    0    1    2    3    5   10   14   15   18   20   21   25   27   30   31   35 
##    6    1    1    1    5   34    1   71    2   33    1    2    1  314    2    1 
##   38   40   44   45   50   55   60   61   63   75   80   86   90  100  105  110 
##    2    4    2   77    5    1  764    1    1   22    2    1  246    1    4    3 
##  120  121  128  135  147  150  160  165  170  180  181  183  188  210  230  239 
##  769    1    1    2    1  119    1    2    1  560    1    1    1   46    2    1 
##  240  270  300  308  310  320  330  360  390  405  420  450  480  488  490  510 
##  354   32  236    1    1    1   32  159    9    1   62    8  164    2    1   10 
##  540  570  600  630  660  690  720  750  780  840  900  960 1020 1080 1380 6666 
##   43    7  135    3    9    1   53    1    8    9    9    3    4    1    2 1561 
## 8888 
##   14
# Complete a datasummary_skim for the 3 variables and use the select function
datasummary_skim(france_data %>% select(happy, ipeqopt, netustm))
Unique (#) Missing (%) Mean SD Min Median Max
happy 10 63 6.3 5.3 0.0 5.0 88.0
ipeqopt 10 1 1.9 1.2 1.0 2.0 9.0
netustm 82 68 1878.9 2855.5 0.0 180.0 8888.0
print("The variable happy stands for how happy an individual is and with the median being 5.0, and the mean at 6.3, it shows that the individuals in France are happy, but the population in terms of numbers that is happy is not as high. The variable netustm stands for how much internet is used, in terms of minutes, and with the median being 180.0 with a slightly left skewed distribution, it shows that the French population uses the internet daily for a long period of time. The variable ipeqopt stands for important people that are treated equally and have equal opportunities, and with a standard deviation that is the lowest, it indcates that the responses to levels of equality are close to the mean. I also noticed that for each of the variables, the distribution is slight skewed to the left.")
## [1] "The variable happy stands for how happy an individual is and with the median being 5.0, and the mean at 6.3, it shows that the individuals in France are happy, but the population in terms of numbers that is happy is not as high. The variable netustm stands for how much internet is used, in terms of minutes, and with the median being 180.0 with a slightly left skewed distribution, it shows that the French population uses the internet daily for a long period of time. The variable ipeqopt stands for important people that are treated equally and have equal opportunities, and with a standard deviation that is the lowest, it indcates that the responses to levels of equality are close to the mean. I also noticed that for each of the variables, the distribution is slight skewed to the left."

Task 2

# Calculate the average by year
happy_by_year <- france_data %>%
  group_by(year) %>%
  summarize(mean_happy = mean(happy, na.rm = TRUE))
ggplot(happy_by_year, aes(x = year, y = mean_happy)) +
  geom_line(color = "blue", size = 1) +
  geom_point(color = "red", size = 3) +
  labs(title = "Levels of Happiness of the France Population (2002-2020)",
       x = "Survey Year",
       y = "Happy (0-10)") +
  ylim(0,10) +
  theme_minimal()
## Warning: Using `size` aesthetic for lines was deprecated in ggplot2 3.4.0.
## ℹ Please use `linewidth` instead.
## This warning is displayed once every 8 hours.
## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
## generated.

print("The levels of happiness in France remained at a steady state from around 2002-2007, at around 6.3 out of 10. But, as the years went on, approaching 2010, levels of happiness starting to decrease steadily until around 5.6 out of 10. Furthermore,there was a spike in levels of happiness during the years between 2017-2019, with levels sitting at around a 7.3, and as we approached 2020, the levels dropped down to around 6.5 which could be connected to the pandemic.")
## [1] "The levels of happiness in France remained at a steady state from around 2002-2007, at around 6.3 out of 10. But, as the years went on, approaching 2010, levels of happiness starting to decrease steadily until around 5.6 out of 10. Furthermore,there was a spike in levels of happiness during the years between 2017-2019, with levels sitting at around a 7.3, and as we approached 2020, the levels dropped down to around 6.5 which could be connected to the pandemic."

Task 3

# Create a comparison visual for outcome of interest with two other countries - use your preferred geom()

ess_selected <- ess %>%
  filter(cntry %in% c("FR", "FI", "IT")) %>%
  mutate(happy = ifelse(happy %in% c(77, 88, 99), NA, happy))


task3plot <- ggplot(ess_selected, aes(x = reorder(cntry, -happy, FUN=median), y = happy, fill = cntry)) +
  geom_boxplot() +
  theme_minimal() + 
  theme(legend.position = "none") + 
  labs(title = "Boxplot Comparison for Levels of Happiness (France, Finland, Italy)", 
       x = "Country", 
       y = "Scale (0-10)")

task3plot
## Warning: Removed 111 rows containing non-finite values (`stat_boxplot()`).

print("After creating the boxplot, I noticed that levels of happiness were significantly higher for Finland than those for France or Italy. Moreover, the median for Finland, Italy France is similar, at around 7.5, but the way that the data is distributed is very distinct for each country. Furthermore, the majority of Finland's population falls below the average of happiness levels, and the mean is only where it is due to the minimal amount of people that have high levels of happiness. In addition, for France, majority of the population falls below the median of levels of happiness, hence why it is negatively skewed. Moreover, for Italy, the data is distributed so that it is below and above the median.")
## [1] "After creating the boxplot, I noticed that levels of happiness were significantly higher for Finland than those for France or Italy. Moreover, the median for Finland, Italy France is similar, at around 7.5, but the way that the data is distributed is very distinct for each country. Furthermore, the majority of Finland's population falls below the average of happiness levels, and the mean is only where it is due to the minimal amount of people that have high levels of happiness. In addition, for France, majority of the population falls below the median of levels of happiness, hence why it is negatively skewed. Moreover, for Italy, the data is distributed so that it is below and above the median."

Task 5 1. Education

france_data <- france_data %>%
  mutate(

    edulvla = case_when(
      essround < 5 & edulvla == 55 ~ NA_real_,
      TRUE ~ edulvla
    ),

    edulvlb = case_when(
      essround >= 5 & edulvlb == 5555 ~ NA_real_,
      TRUE ~ edulvlb
    ),

    educ_level = case_when(
      essround < 5 & edulvla == 5 ~ "BA",
      essround >= 5 & edulvlb > 600 ~ "BA",
      TRUE ~ "No BA"
    )
  )


table(france_data$educ_level)
## 
##    BA No BA 
##  4235 14803

2.Place of Residence

france_data <- france_data %>%
  mutate(geo = recode(as.character(domicil), 
                      '1' = "Urban", 
                      '2' = "Peri-Urban", 
                      '3' = "Rural", 
                      '4' = "Rural", 
                      '5' = "Rural",
                      '7' = NA_character_,
                      '8' = NA_character_,
                      '9' = NA_character_))

# Check by creating a table
table(france_data$geo)
## 
## Peri-Urban      Rural      Urban 
##       2361      13087       3584
table(france_data$domicil)
## 
##    1    2    3    4    5    7    8 
## 3584 2361 6257 5668 1162    3    3
happyedu <-datasummary_crosstab(happy ~ educ_level, data = france_data)
happygeo <- datasummary_crosstab(happy ~ geo, data = france_data)
happyedu
happy BA No BA All
0 N 34 241 275
% row 12.4 87.6 100.0
1 N 3 54 57
% row 5.3 94.7 100.0
3 N 47 299 346
% row 13.6 86.4 100.0
4 N 66 448 514
% row 12.8 87.2 100.0
5 N 276 2073 2349
% row 11.7 88.3 100.0
6 N 351 1518 1869
% row 18.8 81.2 100.0
10 N 293 1329 1622
% row 18.1 81.9 100.0
77 N 3 11 14
% row 21.4 78.6 100.0
88 N 1 11 12
% row 8.3 91.7 100.0
All N 4235 14803 19038
% row 22.2 77.8 100.0
happygeo
happy Peri-Urban Rural Urban All
0 N 24 205 46 275
% row 8.7 74.5 16.7 100.0
1 N 3 42 12 57
% row 5.3 73.7 21.1 100.0
3 N 40 234 72 346
% row 11.6 67.6 20.8 100.0
4 N 59 366 89 514
% row 11.5 71.2 17.3 100.0
5 N 247 1650 452 2349
% row 10.5 70.2 19.2 100.0
6 N 213 1310 346 1869
% row 11.4 70.1 18.5 100.0
10 N 200 1152 267 1622
% row 12.3 71.0 16.5 100.0
77 N 0 9 5 14
% row 0.0 64.3 35.7 100.0
88 N 1 6 5 12
% row 8.3 50.0 41.7 100.0
All N 2361 13087 3584 19038
% row 12.4 68.7 18.8 100.0
table(france_data$happy, france_data$educ_level) %>%
  cprop()
##        
##         BA    No BA All  
##   0       3.2   4.0   3.9
##   1       0.3   0.9   0.8
##   3       4.4   5.0   4.9
##   4       6.1   7.5   7.3
##   5      25.7  34.6  33.3
##   6      32.7  25.4  26.5
##   10     27.3  22.2  23.0
##   77      0.3   0.2   0.2
##   88      0.1   0.2   0.2
##   Total 100.0 100.0 100.0
print ("Based of the column percentages seen and analyzing data for levels of happiness, people living in rural areas were much higher than those that are living in urban and peri-urban areas.")
## [1] "Based of the column percentages seen and analyzing data for levels of happiness, people living in rural areas were much higher than those that are living in urban and peri-urban areas."

Task 5

# Check your clean data
france_clean <- france_data %>%
  filter(!is.na(geo) & !is.na(happy))
# Calculate the Conditional Probabilities
france_probs <- france_clean %>%
  count(happy, geo) %>%
  group_by(geo) %>%
  mutate(prob = n / sum(n))
# Plot the Data
ggplot(france_probs, aes(x = as.factor(happy), y = prob, color = geo)) +
  geom_point() +
  geom_line(aes(group = geo)) +
  labs(title = "Levels of Happiness + Satisfaction with the Legal System",
       subtitle = "by Place of Residence",
       x = "Happiness Levels",
       y = "Probability") +
  theme_minimal()

print("Based of the graph and after analyzing the plotted data, it can be seen that for all places of residence, the green, blue, and the red line start at a very similar value for probability. We can also see that the happiness levels for all 3 places of residence are sitting at a similar probability at levels 3 and 4. As you approach the levels between levels 5 and 10, the probaility for each type of residence starts to decrease and the line representing Urban residency has a higher probability at level 5, and lower at levels 7-10. Overall,this indicates that there is a small difference between probability for different residences.It also shows that as levels of happiness got higher, the probability changed drastically depending on the area in which one lives hence why there is a stronger connection with area of residence for people reporting higher levels of happiness.")
## [1] "Based of the graph and after analyzing the plotted data, it can be seen that for all places of residence, the green, blue, and the red line start at a very similar value for probability. We can also see that the happiness levels for all 3 places of residence are sitting at a similar probability at levels 3 and 4. As you approach the levels between levels 5 and 10, the probaility for each type of residence starts to decrease and the line representing Urban residency has a higher probability at level 5, and lower at levels 7-10. Overall,this indicates that there is a small difference between probability for different residences.It also shows that as levels of happiness got higher, the probability changed drastically depending on the area in which one lives hence why there is a stronger connection with area of residence for people reporting higher levels of happiness."