Setting Up
# List of packages
packages <- c("tidyverse", "modelsummary", "forcats", "RColorBrewer",
"fst", "viridis", "knitr", "kableExtra", "rmarkdown", "ggridges", "viridis", "questionr", "flextable", "infer","effects", "survey", "MASS", "dplyr", "htmltools")
# Install packages if they aren't installed already
new_packages <- packages[!(packages %in% installed.packages()[,"Package"])]
if(length(new_packages)) install.packages(new_packages)
# Load the packages
lapply(packages, library, character.only = TRUE)
## Warning: package 'tidyverse' was built under R version 4.2.3
## Warning: package 'ggplot2' was built under R version 4.2.3
## Warning: package 'tibble' was built under R version 4.2.3
## Warning: package 'tidyr' was built under R version 4.2.3
## Warning: package 'readr' was built under R version 4.2.3
## Warning: package 'purrr' was built under R version 4.2.3
## Warning: package 'dplyr' was built under R version 4.2.3
## Warning: package 'stringr' was built under R version 4.2.3
## Warning: package 'forcats' was built under R version 4.2.3
## Warning: package 'lubridate' was built under R version 4.2.3
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr 1.1.3 ✔ readr 2.1.4
## ✔ forcats 1.0.0 ✔ stringr 1.5.1
## ✔ ggplot2 3.4.4 ✔ tibble 3.2.1
## ✔ lubridate 1.9.3 ✔ 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
## Warning: package 'modelsummary' was built under R version 4.2.3
## Warning in !is.null(rmarkdown::metadata$output) && rmarkdown::metadata$output
## %in% : 'length(x) = 3 > 1' in coercion to 'logical(1)'
## Warning: package 'fst' was built under R version 4.2.3
## Warning: package 'viridis' was built under R version 4.2.3
## Loading required package: viridisLite
## Warning: package 'viridisLite' was built under R version 4.2.3
## Warning: package 'knitr' was built under R version 4.2.3
## Warning: package 'kableExtra' was built under R version 4.2.3
##
## Attaching package: 'kableExtra'
##
## The following object is masked from 'package:dplyr':
##
## group_rows
## Warning: package 'rmarkdown' was built under R version 4.2.3
## Warning: package 'ggridges' was built under R version 4.2.3
## Warning: package 'questionr' was built under R version 4.2.3
## Warning: package 'flextable' was built under R version 4.2.3
##
## Attaching package: 'flextable'
##
## The following objects are masked from 'package:kableExtra':
##
## as_image, footnote
##
## The following object is masked from 'package:purrr':
##
## compose
## Warning: package 'infer' was built under R version 4.2.3
## Warning: package 'effects' was built under R version 4.2.3
## Loading required package: carData
## Warning: package 'carData' was built under R version 4.2.3
## lattice theme set by effectsTheme()
## See ?effectsTheme for details.
## Warning: package 'survey' was built under R version 4.2.3
## Loading required package: grid
## Loading required package: Matrix
## Warning: package 'Matrix' was built under R version 4.2.3
##
## Attaching package: 'Matrix'
##
## The following objects are masked from 'package:tidyr':
##
## expand, pack, unpack
##
## Loading required package: survival
## Warning: package 'survival' was built under R version 4.2.3
##
## Attaching package: 'survey'
##
## The following object is masked from 'package:graphics':
##
## dotchart
## Warning: package 'MASS' was built under R version 4.2.3
##
## Attaching package: 'MASS'
##
## The following object is masked from 'package:dplyr':
##
## select
## Warning: package 'htmltools' was built under R version 4.2.3
## [[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"
##
## [[13]]
## [1] "flextable" "questionr" "ggridges" "rmarkdown" "kableExtra"
## [6] "knitr" "viridis" "viridisLite" "fst" "RColorBrewer"
## [11] "modelsummary" "lubridate" "forcats" "stringr" "dplyr"
## [16] "purrr" "readr" "tidyr" "tibble" "ggplot2"
## [21] "tidyverse" "stats" "graphics" "grDevices" "utils"
## [26] "datasets" "methods" "base"
##
## [[14]]
## [1] "infer" "flextable" "questionr" "ggridges" "rmarkdown"
## [6] "kableExtra" "knitr" "viridis" "viridisLite" "fst"
## [11] "RColorBrewer" "modelsummary" "lubridate" "forcats" "stringr"
## [16] "dplyr" "purrr" "readr" "tidyr" "tibble"
## [21] "ggplot2" "tidyverse" "stats" "graphics" "grDevices"
## [26] "utils" "datasets" "methods" "base"
##
## [[15]]
## [1] "effects" "carData" "infer" "flextable" "questionr"
## [6] "ggridges" "rmarkdown" "kableExtra" "knitr" "viridis"
## [11] "viridisLite" "fst" "RColorBrewer" "modelsummary" "lubridate"
## [16] "forcats" "stringr" "dplyr" "purrr" "readr"
## [21] "tidyr" "tibble" "ggplot2" "tidyverse" "stats"
## [26] "graphics" "grDevices" "utils" "datasets" "methods"
## [31] "base"
##
## [[16]]
## [1] "survey" "survival" "Matrix" "grid" "effects"
## [6] "carData" "infer" "flextable" "questionr" "ggridges"
## [11] "rmarkdown" "kableExtra" "knitr" "viridis" "viridisLite"
## [16] "fst" "RColorBrewer" "modelsummary" "lubridate" "forcats"
## [21] "stringr" "dplyr" "purrr" "readr" "tidyr"
## [26] "tibble" "ggplot2" "tidyverse" "stats" "graphics"
## [31] "grDevices" "utils" "datasets" "methods" "base"
##
## [[17]]
## [1] "MASS" "survey" "survival" "Matrix" "grid"
## [6] "effects" "carData" "infer" "flextable" "questionr"
## [11] "ggridges" "rmarkdown" "kableExtra" "knitr" "viridis"
## [16] "viridisLite" "fst" "RColorBrewer" "modelsummary" "lubridate"
## [21] "forcats" "stringr" "dplyr" "purrr" "readr"
## [26] "tidyr" "tibble" "ggplot2" "tidyverse" "stats"
## [31] "graphics" "grDevices" "utils" "datasets" "methods"
## [36] "base"
##
## [[18]]
## [1] "MASS" "survey" "survival" "Matrix" "grid"
## [6] "effects" "carData" "infer" "flextable" "questionr"
## [11] "ggridges" "rmarkdown" "kableExtra" "knitr" "viridis"
## [16] "viridisLite" "fst" "RColorBrewer" "modelsummary" "lubridate"
## [21] "forcats" "stringr" "dplyr" "purrr" "readr"
## [26] "tidyr" "tibble" "ggplot2" "tidyverse" "stats"
## [31] "graphics" "grDevices" "utils" "datasets" "methods"
## [36] "base"
##
## [[19]]
## [1] "htmltools" "MASS" "survey" "survival" "Matrix"
## [6] "grid" "effects" "carData" "infer" "flextable"
## [11] "questionr" "ggridges" "rmarkdown" "kableExtra" "knitr"
## [16] "viridis" "viridisLite" "fst" "RColorBrewer" "modelsummary"
## [21] "lubridate" "forcats" "stringr" "dplyr" "purrr"
## [26] "readr" "tidyr" "tibble" "ggplot2" "tidyverse"
## [31] "stats" "graphics" "grDevices" "utils" "datasets"
## [36] "methods" "base"
ess <- read_fst("All-ESS-Data.fst")
## Warning: package 'fstcore' was built under R version 4.2.3
library(fst)
Creating and Cleaning Israel Dataset
# Creating Israel's dataset
israel_dataset <- ess[ess$cntry == "IL", ]
# Selecting Israel's dataset
israel_clean <- israel_dataset %>%
dplyr::select(edlvail, hinctnta, happy, essround, yrbrn, sclmeet, weight, health, crvctef, eduail1, stflife)
# Cleaning dataset
israel_clean <- israel_clean %>%
mutate(
happy = ifelse(happy %in% c(77, 88, 99), NA, happy),
hinctnta = ifelse(hinctnta %in% c(77, 88, 99), NA, hinctnta),
crvctef = ifelse(crvctef %in% c(6, 7, 8, 9), NA, crvctef),
health = ifelse(health %in% c(7, 8, 9), NA, health),
edlvail = ifelse(edlvail %in% c(77, 99), NA, edlvail),
sclmeet = ifelse(sclmeet %in% c(77, 88, 99), NA, sclmeet),
stflife = ifelse(stflife %in% c(77, 88, 99), NA, stflife),
year = case_when(essround == 1 ~ 2002,
essround == 2 ~ 2004,
essround == 3 ~ 2006,
essround == 4 ~ 2008,
essround == 5 ~ 2010,
essround == 6 ~ 2012,
essround == 7 ~ 2014,
essround == 8 ~ 2016,
essround == 9 ~ 2018,
essround == 10 ~ 2020)) %>%
filter(!is.na(happy) & !is.na(crvctef) & !is.na(edlvail) & !is.na(hinctnta) & !is.na(health) & !is.na(sclmeet) & !is.na(stflife) )
table(israel_clean$crvctef)
##
## 1 2 3
## 51 202 447
table(israel_clean$edlvail)
##
## 0 1 2 3 4 5 6 7 8 9 10
## 21 61 161 110 12 12 94 152 43 24 10
table(israel_clean$health)
##
## 1 2 3 4 5
## 197 300 139 53 11
table(israel_clean$stflife)
##
## 0 1 2 3 4 5 6 7 8 9 10
## 12 7 10 15 25 73 64 86 231 106 71
Data Summary
datasummary_skim(israel_clean)
Unique (#)
Missing (%)
Mean
SD
Min
Median
Max
edlvail
11
0
4.4
2.6
0.0
3.0
10.0
hinctnta
10
0
5.8
2.7
1.0
6.0
10.0
happy
11
0
7.4
1.9
0.0
8.0
10.0
essround
1
0
4.0
0.0
4.0
4.0
4.0
yrbrn
77
0
1990.3
457.1
1917.0
1961.0
9999.0
sclmeet
7
0
5.2
1.5
1.0
5.0
7.0
health
5
0
2.1
1.0
1.0
2.0
5.0
crvctef
3
0
2.6
0.6
1.0
3.0
3.0
stflife
11
0
7.2
2.1
0.0
8.0
10.0
year
1
0
2008.0
0.0
2008.0
2008.0
2008.0
# Recoding Variables
israel_clean <- israel_clean %>%
mutate(
edlvail = factor(
case_when(
edlvail == 0 ~ "No primary education",
edlvail %in% 1:5 ~ "Education up to High School",
edlvail %in% 6:7 ~ "Post-Secondary School (Non-Tetiary) or BA",
edlvail %in% 8:10 ~ "MA or PHD",
TRUE ~ as.character(edlvail) # Convert to character for consistency
),
levels = c("No primary education", "Up to Secondary School", "Post-Secondary School (Non-Tetiary) or BA", "MA or PHD")
)
) %>%
mutate(
sclmeet = factor(
case_when(
sclmeet == 1 ~ "Never",
sclmeet %in% 2:4 ~ "Up to Several Times Per Month",
sclmeet %in% 5:7 ~ "At least Once A Week",
TRUE ~ as.character(sclmeet) # Convert to character for consistency
),
levels = c("Never", "Up to Several Times Per Month", "At least Once A Week")
)) %>%
mutate(
hinctnta = factor(
case_when(
hinctnta %in% 1:3 ~ "1st-3rd Deciles",
hinctnta %in% 4:6 ~ "4th-6th Deciles",
hinctnta %in% 7:10 ~ "7th-10th Deciles",
TRUE ~ as.character(hinctnta) # Convert to character for consistency
),
))
Double-checking that dataset is clean
levels(israel_clean$edlvail)
## [1] "No primary education"
## [2] "Up to Secondary School"
## [3] "Post-Secondary School (Non-Tetiary) or BA"
## [4] "MA or PHD"
levels(israel_clean$sclmeet)
## [1] "Never" "Up to Several Times Per Month"
## [3] "At least Once A Week"
levels(israel_clean$hinctnta)
## [1] "1st-3rd Deciles" "4th-6th Deciles" "7th-10th Deciles"
Scaling Output of Happiness
# Happiness scale (high levels of high self-reported happiness, good self-reported health levels, few worries about being a victim of crime, and high satisfaction with life as an indicator of happiness)
# Differentiating happiness values
israel_clean$happy <- ifelse(israel_clean$happy < 5, NA, israel_clean$happy)
israel_clean$health <- ifelse(israel_clean$health > 3, NA, israel_clean$health)
israel_clean$crvctef <- ifelse(israel_clean$crvctef < 3, NA, israel_clean$crvctef)
israel_clean$stflife <- ifelse(israel_clean$stflife < 5, NA, israel_clean$stflife)
# Creating and rescaling the happiness variable
israel_clean$happiness <- scales::rescale(israel_clean$happy + israel_clean$health + israel_clean$crvctef + israel_clean$stflife, na.rm = TRUE, to = c(0, 100))
ggplot(israel_clean, aes(x = happiness)) +
geom_histogram(bins = 30, fill = "blue", color = "black") +
theme_minimal() +
labs(title = "Histogram of Happiness Scale",
x = "Happiness Scale",
y = "Count")
## Warning: Removed 309 rows containing non-finite values (`stat_bin()`).
table(israel_clean$happiness)
##
## 0 8.33333333333333 16.6666666666667 25
## 2 12 16 23
## 33.3333333333333 41.6666666666667 50 58.3333333333333
## 13 28 41 112
## 66.6666666666667 75 83.3333333333333 91.6666666666667
## 65 44 21 12
## 100
## 2
Modelling (Education Attainment and Frequency of Social
Engagements)
model1 <- lm(happiness ~ edlvail, data = israel_clean)
modelfriend2 <- lm(happiness ~ edlvail + sclmeet, data = israel_clean)
modelfriend3 <- lm(happiness ~ edlvail + sclmeet + edlvail*sclmeet, data = israel_clean)
modelsummary(
list(model1, modelfriend2, modelfriend3))
 (1)
  (2)
  (3)
(Intercept)
33.333
2.441
7.627
(8.607)
(21.079)
(21.400)
edlvailPost-Secondary School (Non-Tetiary) or BA
22.240
22.559
17.373
(8.745)
(8.722)
(9.702)
edlvailMA or PHD
21.895
22.030
13.925
(9.019)
(8.995)
(10.027)
sclmeetUp to Several Times Per Month
28.931
0.707
(19.391)
(28.667)
sclmeetAt least Once A Week
31.382
31.957
(19.268)
(19.157)
edlvailPost-Secondary School (Non-Tetiary) or BA × sclmeetUp to Several
Times Per Month
26.486
(21.622)
edlvailMA or PHD × sclmeetUp to Several Times Per Month
37.998
(22.189)
Num.Obs.
210
210
210
R2
0.030
0.045
0.066
R2 Adj.
0.021
0.027
0.038
AIC
1843.0
1843.7
1843.1
BIC
1856.4
1863.8
1869.9
Log.Lik.
−917.492
−915.870
−913.570
RMSE
19.11
18.96
18.75
## Adding Stars
modelsummary(
list(model1, modelfriend2, modelfriend3),
fmt = 1,
estimate = c( "{estimate} ({std.error}){stars}",
"{estimate} ({std.error}){stars}",
"{estimate} ({std.error}){stars}"),
statistic = NULL,
coef_omit = "Intercept")
 (1)
  (2)
  (3)
edlvailPost-Secondary School (Non-Tetiary) or BA
22.2 (8.7)*
22.6 (8.7)*
17.4 (9.7)+
edlvailMA or PHD
21.9 (9.0)*
22.0 (9.0)*
13.9 (10.0)
sclmeetUp to Several Times Per Month
28.9 (19.4)
0.7 (28.7)
sclmeetAt least Once A Week
31.4 (19.3)
32.0 (19.2)+
edlvailPost-Secondary School (Non-Tetiary) or BA × sclmeetUp to Several
Times Per Month
26.5 (21.6)
edlvailMA or PHD × sclmeetUp to Several Times Per Month
38.0 (22.2)+
Num.Obs.
210
210
210
R2
0.030
0.045
0.066
R2 Adj.
0.021
0.027
0.038
AIC
1843.0
1843.7
1843.1
BIC
1856.4
1863.8
1869.9
Log.Lik.
−917.492
−915.870
−913.570
RMSE
19.11
18.96
18.75
Model Checks
# set graphical parameters
par(mfrow = c(2,2)) # plot 2 X 2 matrix, by row
# plot diagnostics plots
plot(modelfriend3, pch = 19, col = scales::alpha("grey", .8), cex = .5)
## Warning: not plotting observations with leverage one:
## 78, 150
Interaction Plot (Education Attainment and Frequency of Social
Engagements)
edusocial_interaction <- effect("edlvail*sclmeet", modelfriend3, na.rm=TRUE)
## Note:
## 2 values in the edlvail*sclmeet effect are not estimable
plot(edusocial_interaction,
main="Interaction effect Education Level and Frequency of Social Engagements",
xlab="Education Attainment",
ylab="Happiness Levels")
Modelling (Education Attainment and Income Decile)
model1 <- lm(happiness ~ edlvail, data = israel_clean)
modelinc2 <- lm(happiness ~ edlvail + hinctnta, data = israel_clean)
modelinc3 <- lm(happiness ~ edlvail + hinctnta + edlvail*hinctnta, data = israel_clean)
modelsummary(
list(model1, modelinc2, modelinc3))
 (1)
  (2)
  (3)
(Intercept)
33.333
31.424
22.222
(8.607)
(8.550)
(10.762)
edlvailPost-Secondary School (Non-Tetiary) or BA
22.240
14.356
27.183
(8.745)
(8.781)
(11.859)
edlvailMA or PHD
21.895
14.178
20.486
(9.019)
(8.999)
(12.619)
hinctnta4th-6th Deciles
4.775
27.778
(4.589)
(17.016)
hinctnta7th-10th Deciles
13.432
18.403
(4.222)
(7.346)
edlvailPost-Secondary School (Non-Tetiary) or BA × hinctnta4th-6th
Deciles
−26.214
(17.957)
edlvailMA or PHD × hinctnta4th-6th Deciles
−24.653
(19.176)
edlvailPost-Secondary School (Non-Tetiary) or BA × hinctnta7th-10th
Deciles
−9.302
(9.075)
Num.Obs.
210
210
210
R2
0.030
0.096
0.112
R2 Adj.
0.021
0.078
0.082
AIC
1843.0
1832.3
1834.4
BIC
1856.4
1852.3
1864.6
Log.Lik.
−917.492
−910.129
−908.216
RMSE
19.11
18.45
18.28
## Adding Stars
modelsummary(
list(model1, modelinc2, modelinc3),
fmt = 1,
estimate = c( "{estimate} ({std.error}){stars}",
"{estimate} ({std.error}){stars}",
"{estimate} ({std.error}){stars}"),
statistic = NULL,
coef_omit = "Intercept")
 (1)
  (2)
  (3)
edlvailPost-Secondary School (Non-Tetiary) or BA
22.2 (8.7)*
14.4 (8.8)
27.2 (11.9)*
edlvailMA or PHD
21.9 (9.0)*
14.2 (9.0)
20.5 (12.6)
hinctnta4th-6th Deciles
4.8 (4.6)
27.8 (17.0)
hinctnta7th-10th Deciles
13.4 (4.2)**
18.4 (7.3)*
edlvailPost-Secondary School (Non-Tetiary) or BA × hinctnta4th-6th
Deciles
−26.2 (18.0)
edlvailMA or PHD × hinctnta4th-6th Deciles
−24.7 (19.2)
edlvailPost-Secondary School (Non-Tetiary) or BA × hinctnta7th-10th
Deciles
−9.3 (9.1)
Num.Obs.
210
210
210
R2
0.030
0.096
0.112
R2 Adj.
0.021
0.078
0.082
AIC
1843.0
1832.3
1834.4
BIC
1856.4
1852.3
1864.6
Log.Lik.
−917.492
−910.129
−908.216
RMSE
19.11
18.45
18.28
Model Checks
# set graphical parameters
par(mfrow = c(2,2)) # plot 2 X 2 matrix, by row
# plot diagnostics plots
plot(modelinc3, pch = 19, col = scales::alpha("grey", .8), cex = .5)
Interaction Plot (Education Attainment and Income Decile)
eduinc_interaction <- effect("edlvail*hinctnta", modelinc3, na.rm=TRUE)
## Note:
## 1 value in the edlvail*hinctnta effect are not estimable
plot(eduinc_interaction,
main="Interaction effect Education Level and Income Decile",
xlab="Education Attainment",
ylab="Happiness Levels")