# 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: 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 Israel's dataset
israel_dataset <- ess[ess$cntry == "IL", ]
# Cleaning Israel's dataset
israel_clean <- israel_dataset %>%
dplyr::select(eduail1, hinctnta, happy, rlgdgr, essround, yrbrn, rlgdnm, imprich, inprdsc) %>%
filter(!yrbrn %in% c(7777, 8888)) %>%
mutate(
happy = ifelse(happy %in% c(77, 88, 99), NA, happy),
rlgdgr = ifelse(rlgdgr %in% c(77, 88, 99), NA, rlgdgr),
eduail1 = ifelse(eduail1 %in% c(4444, 5555, 7777, 8888, 9999), NA, eduail1),
hinctnta = ifelse(hinctnta %in% c(77, 88, 99), NA, hinctnta),
rlgdnm = ifelse(rlgdnm %in% c(77,99), NA, rlgdnm),
imprich = ifelse(imprich %in% c(7, 8, 9), NA, imprich),
inprdsc = ifelse(inprdsc %in% c(77, 88, 99), NA, inprdsc),
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(rlgdgr) & !is.na(eduail1) & !is.na(hinctnta) & !is.na(rlgdnm) & !is.na(imprich) & !is.na(inprdsc)) %>%
mutate(
eduail1 = case_when(
eduail1 == 1 ~ "Not completed Primary Education",
eduail1 == 2 ~ "Primary School",
eduail1 == 3 ~ "Junior High School",
eduail1 %in% 4:9 ~ "Secondary School",
eduail1 %in% 10:11 ~ "Post-Secondary School (Non-Tetiary)",
eduail1 %in% 12:13 ~ "Bachelor's Degree",
eduail1 %in% 14:16 ~ "Master's Degree",
eduail1 == 17 ~ "Doctorate Degree",
TRUE ~ as.character(eduail1)
)) %>%
mutate(
inprdsc = case_when(
inprdsc == 0 ~ "None",
inprdsc == 1 ~ "1",
inprdsc == 2 ~ "2",
inprdsc == 3 ~ "3",
inprdsc == 4 ~ "4-6",
inprdsc == 5 ~ "7-9",
inprdsc == 6 ~ "10 or more",
TRUE ~ as.character(inprdsc)
))
unique(israel_clean$eduail1)
## [1] "Post-Secondary School (Non-Tetiary)" "Master's Degree"
## [3] "Secondary School" "Bachelor's Degree"
## [5] "Junior High School" "Doctorate Degree"
## [7] "Primary School" "Not completed Primary Education"
unique(israel_clean$inprdsc)
## [1] "4-6" "2" "3" "None" "10 or more"
## [6] "7-9" "1"
test_stat <- israel_clean %>%
specify(explanatory = eduail1,
response = happy) %>%
hypothesize(null = "independence") %>%
calculate(stat = "F")
print(test_stat$stat)
## [1] 9.288192
null_distribution <- israel_clean %>%
specify(explanatory = eduail1,
response = happy) %>%
hypothesize(null = "independence") %>%
generate(reps = 1000, type = "permute") %>%
calculate(stat = "f")
p_val <- null_distribution %>%
get_pvalue(obs_stat = test_stat, direction = "greater")
## Warning: Please be cautious in reporting a p-value of 0. This result is an
## approximation based on the number of `reps` chosen in the `generate()` step.
## See `?get_p_value()` for more information.
p_val
## # A tibble: 1 × 1
## p_value
## <dbl>
## 1 0
null_distribution %>%
visualize() +
shade_p_value(obs_stat = test_stat, direction = "greater")
## Warning in min(diff(unique_loc)): no non-missing arguments to min; returning
## Inf
friend_stat <- israel_clean %>%
specify(explanatory = inprdsc,
response = happy) %>%
hypothesize(null = "independence") %>%
calculate(stat = "F")
print(friend_stat$stat)
## [1] 18.358
null_friend <- israel_clean %>%
specify(explanatory = inprdsc,
response = happy) %>%
hypothesize(null = "independence") %>%
generate(reps = 1000, type = "permute") %>%
calculate(stat = "F")
p_friend <- null_friend %>%
get_pvalue(obs_stat = friend_stat, direction = "greater")
## Warning: Please be cautious in reporting a p-value of 0. This result is an
## approximation based on the number of `reps` chosen in the `generate()` step.
## See `?get_p_value()` for more information.
p_friend
## # A tibble: 1 × 1
## p_value
## <dbl>
## 1 0
null_friend %>%
visualize() +
shade_p_value(obs_stat = friend_stat, direction = "greater")
## Warning in min(diff(unique_loc)): no non-missing arguments to min; returning
## Inf
model1 <- lm(happy ~ eduail1, data = israel_clean)
model2 <- lm(happy ~ eduail1 + inprdsc, data = israel_clean)
model3 <- lm(happy ~ eduail1 + inprdsc + eduail1*inprdsc, data = israel_clean)
modelsummary(
list(model1, model2, model3))
| (1) | (2) | (3) | |
|---|---|---|---|
| (Intercept) | 7.916 | 7.755 | 7.830 |
| (0.079) | (0.105) | (0.200) | |
| eduail1Doctorate Degree | 0.116 | 0.121 | 1.170 |
| (0.350) | (0.347) | (0.691) | |
| eduail1Junior High School | −0.779 | −0.650 | −1.014 |
| (0.152) | (0.152) | (0.306) | |
| eduail1Master’s Degree | −0.022 | −0.049 | −0.023 |
| (0.139) | (0.138) | (0.391) | |
| eduail1Not completed Primary Education | −0.751 | −0.639 | −1.348 |
| (0.209) | (0.207) | (0.412) | |
| eduail1Post-Secondary School (Non-Tetiary) | −0.161 | −0.111 | −0.141 |
| (0.120) | (0.118) | (0.278) | |
| eduail1Primary School | −0.890 | −0.647 | −0.860 |
| (0.149) | (0.150) | (0.305) | |
| eduail1Secondary School | −0.317 | −0.224 | −0.223 |
| (0.096) | (0.095) | (0.228) | |
| inprdsc10 or more | 0.344 | −0.357 | |
| (0.158) | (0.370) | ||
| inprdsc2 | 0.023 | 0.204 | |
| (0.106) | (0.264) | ||
| inprdsc3 | 0.321 | 0.110 | |
| (0.105) | (0.252) | ||
| inprdsc4-6 | 0.241 | 0.142 | |
| (0.106) | (0.254) | ||
| inprdsc7-9 | 0.526 | 0.101 | |
| (0.186) | (0.401) | ||
| inprdscNone | −0.824 | −0.011 | |
| (0.138) | (0.446) | ||
| eduail1Doctorate Degree × inprdsc10 or more | −0.143 | ||
| (1.205) | |||
| eduail1Junior High School × inprdsc10 or more | −0.458 | ||
| (0.881) | |||
| eduail1Master’s Degree × inprdsc10 or more | 0.884 | ||
| (0.646) | |||
| eduail1Not completed Primary Education × inprdsc10 or more | 0.876 | ||
| (1.069) | |||
| eduail1Post-Secondary School (Non-Tetiary) × inprdsc10 or more | 0.705 | ||
| (0.548) | |||
| eduail1Primary School × inprdsc10 or more | 2.003 | ||
| (0.678) | |||
| eduail1Secondary School × inprdsc10 or more | 0.766 | ||
| (0.448) | |||
| eduail1Doctorate Degree × inprdsc2 | −2.204 | ||
| (2.003) | |||
| eduail1Junior High School × inprdsc2 | 0.372 | ||
| (0.447) | |||
| eduail1Master’s Degree × inprdsc2 | −0.196 | ||
| (0.498) | |||
| eduail1Not completed Primary Education × inprdsc2 | 0.647 | ||
| (0.628) | |||
| eduail1Post-Secondary School (Non-Tetiary) × inprdsc2 | −0.257 | ||
| (0.379) | |||
| eduail1Primary School × inprdsc2 | 0.120 | ||
| (0.475) | |||
| eduail1Secondary School × inprdsc2 | −0.473 | ||
| (0.310) | |||
| eduail1Doctorate Degree × inprdsc3 | −1.510 | ||
| (1.097) | |||
| eduail1Junior High School × inprdsc3 | 0.694 | ||
| (0.448) | |||
| eduail1Master’s Degree × inprdsc3 | 0.041 | ||
| (0.476) | |||
| eduail1Not completed Primary Education × inprdsc3 | 0.908 | ||
| (0.594) | |||
| eduail1Post-Secondary School (Non-Tetiary) × inprdsc3 | 0.134 | ||
| (0.375) | |||
| eduail1Primary School × inprdsc3 | 0.483 | ||
| (0.475) | |||
| eduail1Secondary School × inprdsc3 | 0.210 | ||
| (0.301) | |||
| eduail1Doctorate Degree × inprdsc4-6 | −1.392 | ||
| (0.970) | |||
| eduail1Junior High School × inprdsc4-6 | 0.086 | ||
| (0.521) | |||
| eduail1Master’s Degree × inprdsc4-6 | 0.101 | ||
| (0.471) | |||
| eduail1Not completed Primary Education × inprdsc4-6 | 1.443 | ||
| (0.654) | |||
| eduail1Post-Secondary School (Non-Tetiary) × inprdsc4-6 | 0.108 | ||
| (0.372) | |||
| eduail1Primary School × inprdsc4-6 | 0.474 | ||
| (0.489) | |||
| eduail1Secondary School × inprdsc4-6 | −0.056 | ||
| (0.304) | |||
| eduail1Doctorate Degree × inprdsc7-9 | −1.435 | ||
| (1.329) | |||
| eduail1Junior High School × inprdsc7-9 | 1.797 | ||
| (0.846) | |||
| eduail1Master’s Degree × inprdsc7-9 | −0.158 | ||
| (0.752) | |||
| eduail1Not completed Primary Education × inprdsc7-9 | 3.417 | ||
| (1.948) | |||
| eduail1Post-Secondary School (Non-Tetiary) × inprdsc7-9 | 0.835 | ||
| (0.646) | |||
| eduail1Primary School × inprdsc7-9 | 0.929 | ||
| (1.402) | |||
| eduail1Secondary School × inprdsc7-9 | 0.351 | ||
| (0.491) | |||
| eduail1Doctorate Degree × inprdscNone | −2.489 | ||
| (1.546) | |||
| eduail1Junior High School × inprdscNone | −0.239 | ||
| (0.637) | |||
| eduail1Master’s Degree × inprdscNone | −2.795 | ||
| (0.947) | |||
| eduail1Not completed Primary Education × inprdscNone | −0.070 | ||
| (0.824) | |||
| eduail1Post-Secondary School (Non-Tetiary) × inprdscNone | −1.306 | ||
| (0.606) | |||
| eduail1Primary School × inprdscNone | −1.135 | ||
| (0.567) | |||
| eduail1Secondary School × inprdscNone | −0.712 | ||
| (0.491) | |||
| Num.Obs. | 3092 | 3092 | 3092 |
| R2 | 0.021 | 0.046 | 0.065 |
| R2 Adj. | 0.018 | 0.042 | 0.048 |
| AIC | 12758.6 | 12688.0 | 12710.5 |
| BIC | 12812.9 | 12778.6 | 13054.6 |
| Log.Lik. | −6370.290 | −6329.011 | −6298.242 |
| RMSE | 1.90 | 1.87 | 1.86 |
interaction_plot <- effect("eduail1*inprdsc", model3, na.rm=TRUE)
plot(interaction_plot,
main="Interaction effect Education Level x Number of Intimate Friends",
xlab="Education Level",
ylab="Happiness Levels")
# Installing package
remotes::install_github("datalorax/equatiomatic", force = TRUE)
## Downloading GitHub repo datalorax/equatiomatic@HEAD
## xfun (0.40 -> 0.41 ) [CRAN]
## rlang (1.1.1 -> 1.1.2) [CRAN]
## dplyr (1.1.3 -> 1.1.4) [CRAN]
## Installing 3 packages: xfun, rlang, dplyr
## Warning: package 'dplyr' is in use and will not be installed
## Installing packages into 'C:/Users/yi en/AppData/Local/R/win-library/4.2'
## (as 'lib' is unspecified)
## package 'xfun' successfully unpacked and MD5 sums checked
## Warning: cannot remove prior installation of package 'xfun'
## Warning in file.copy(savedcopy, lib, recursive = TRUE): problem copying
## C:\Users\yi en\AppData\Local\R\win-library\4.2\00LOCK\xfun\libs\x64\xfun.dll to
## C:\Users\yi en\AppData\Local\R\win-library\4.2\xfun\libs\x64\xfun.dll:
## Permission denied
## Warning: restored 'xfun'
## package 'rlang' successfully unpacked and MD5 sums checked
## Warning: cannot remove prior installation of package 'rlang'
## Warning in file.copy(savedcopy, lib, recursive = TRUE): problem copying
## C:\Users\yi en\AppData\Local\R\win-library\4.2\00LOCK\rlang\libs\x64\rlang.dll
## to C:\Users\yi en\AppData\Local\R\win-library\4.2\rlang\libs\x64\rlang.dll:
## Permission denied
## Warning: restored 'rlang'
##
## The downloaded binary packages are in
## C:\Users\yi en\AppData\Local\Temp\RtmpW8BQwW\downloaded_packages
## ── R CMD build ─────────────────────────────────────────────────────────────────
## WARNING: Rtools is required to build R packages, but is not currently installed.
##
## Please download and install Rtools 4.2 from https://cran.r-project.org/bin/windows/Rtools/.
##
checking for file 'C:\Users\yi en\AppData\Local\Temp\RtmpW8BQwW\remotes6e746d13043\datalorax-equatiomatic-29ff168/DESCRIPTION' ...
checking for file 'C:\Users\yi en\AppData\Local\Temp\RtmpW8BQwW\remotes6e746d13043\datalorax-equatiomatic-29ff168/DESCRIPTION' ...
✔ checking for file 'C:\Users\yi en\AppData\Local\Temp\RtmpW8BQwW\remotes6e746d13043\datalorax-equatiomatic-29ff168/DESCRIPTION' (769ms)
##
─ preparing 'equatiomatic': (1.5s)
## checking DESCRIPTION meta-information ...
checking DESCRIPTION meta-information ...
✔ checking DESCRIPTION meta-information
##
─ checking for LF line-endings in source and make files and shell scripts
##
─ checking for empty or unneeded directories
##
─ building 'equatiomatic_0.3.1.tar.gz'
##
##
## Installing package into 'C:/Users/yi en/AppData/Local/R/win-library/4.2'
## (as 'lib' is unspecified)
# Getting the equation
equatiomatic::extract_eq(model3, use_coefs = TRUE)
\[ \operatorname{\widehat{happy}} = 7.83 + 1.17(\operatorname{eduail1}_{\operatorname{Doctorate\ Degree}}) - 1.01(\operatorname{eduail1}_{\operatorname{Junior\ High\ School}}) - 0.02(\operatorname{eduail1}_{\operatorname{Master's\ Degree}}) - 1.35(\operatorname{eduail1}_{\operatorname{Not\ completed\ Primary\ Education}}) - 0.14(\operatorname{eduail1}_{\operatorname{Post-Secondary\ School\ (Non-Tetiary)}}) - 0.86(\operatorname{eduail1}_{\operatorname{Primary\ School}}) - 0.22(\operatorname{eduail1}_{\operatorname{Secondary\ School}}) - 0.36(\operatorname{inprdsc}_{\operatorname{10\ or\ more}}) + 0.2(\operatorname{inprdsc}_{\operatorname{2}}) + 0.11(\operatorname{inprdsc}_{\operatorname{3}}) + 0.14(\operatorname{inprdsc}_{\operatorname{4-6}}) + 0.1(\operatorname{inprdsc}_{\operatorname{7-9}}) - 0.01(\operatorname{inprdsc}_{\operatorname{None}}) - 0.14(\operatorname{eduail1}_{\operatorname{Doctorate\ Degree}} \times \operatorname{inprdsc}_{\operatorname{10\ or\ more}}) - 0.46(\operatorname{eduail1}_{\operatorname{Junior\ High\ School}} \times \operatorname{inprdsc}_{\operatorname{10\ or\ more}}) + 0.88(\operatorname{eduail1}_{\operatorname{Master's\ Degree}} \times \operatorname{inprdsc}_{\operatorname{10\ or\ more}}) + 0.88(\operatorname{eduail1}_{\operatorname{Not\ completed\ Primary\ Education}} \times \operatorname{inprdsc}_{\operatorname{10\ or\ more}}) + 0.7(\operatorname{eduail1}_{\operatorname{Post-Secondary\ School\ (Non-Tetiary)}} \times \operatorname{inprdsc}_{\operatorname{10\ or\ more}}) + 2(\operatorname{eduail1}_{\operatorname{Primary\ School}} \times \operatorname{inprdsc}_{\operatorname{10\ or\ more}}) + 0.77(\operatorname{eduail1}_{\operatorname{Secondary\ School}} \times \operatorname{inprdsc}_{\operatorname{10\ or\ more}}) - 2.2(\operatorname{eduail1}_{\operatorname{Doctorate\ Degree}} \times \operatorname{inprdsc}_{\operatorname{2}}) + 0.37(\operatorname{eduail1}_{\operatorname{Junior\ High\ School}} \times \operatorname{inprdsc}_{\operatorname{2}}) - 0.2(\operatorname{eduail1}_{\operatorname{Master's\ Degree}} \times \operatorname{inprdsc}_{\operatorname{2}}) + 0.65(\operatorname{eduail1}_{\operatorname{Not\ completed\ Primary\ Education}} \times \operatorname{inprdsc}_{\operatorname{2}}) - 0.26(\operatorname{eduail1}_{\operatorname{Post-Secondary\ School\ (Non-Tetiary)}} \times \operatorname{inprdsc}_{\operatorname{2}}) + 0.12(\operatorname{eduail1}_{\operatorname{Primary\ School}} \times \operatorname{inprdsc}_{\operatorname{2}}) - 0.47(\operatorname{eduail1}_{\operatorname{Secondary\ School}} \times \operatorname{inprdsc}_{\operatorname{2}}) - 1.51(\operatorname{eduail1}_{\operatorname{Doctorate\ Degree}} \times \operatorname{inprdsc}_{\operatorname{3}}) + 0.69(\operatorname{eduail1}_{\operatorname{Junior\ High\ School}} \times \operatorname{inprdsc}_{\operatorname{3}}) + 0.04(\operatorname{eduail1}_{\operatorname{Master's\ Degree}} \times \operatorname{inprdsc}_{\operatorname{3}}) + 0.91(\operatorname{eduail1}_{\operatorname{Not\ completed\ Primary\ Education}} \times \operatorname{inprdsc}_{\operatorname{3}}) + 0.13(\operatorname{eduail1}_{\operatorname{Post-Secondary\ School\ (Non-Tetiary)}} \times \operatorname{inprdsc}_{\operatorname{3}}) + 0.48(\operatorname{eduail1}_{\operatorname{Primary\ School}} \times \operatorname{inprdsc}_{\operatorname{3}}) + 0.21(\operatorname{eduail1}_{\operatorname{Secondary\ School}} \times \operatorname{inprdsc}_{\operatorname{3}}) - 1.39(\operatorname{eduail1}_{\operatorname{Doctorate\ Degree}} \times \operatorname{inprdsc}_{\operatorname{4-6}}) + 0.09(\operatorname{eduail1}_{\operatorname{Junior\ High\ School}} \times \operatorname{inprdsc}_{\operatorname{4-6}}) + 0.1(\operatorname{eduail1}_{\operatorname{Master's\ Degree}} \times \operatorname{inprdsc}_{\operatorname{4-6}}) + 1.44(\operatorname{eduail1}_{\operatorname{Not\ completed\ Primary\ Education}} \times \operatorname{inprdsc}_{\operatorname{4-6}}) + 0.11(\operatorname{eduail1}_{\operatorname{Post-Secondary\ School\ (Non-Tetiary)}} \times \operatorname{inprdsc}_{\operatorname{4-6}}) + 0.47(\operatorname{eduail1}_{\operatorname{Primary\ School}} \times \operatorname{inprdsc}_{\operatorname{4-6}}) - 0.06(\operatorname{eduail1}_{\operatorname{Secondary\ School}} \times \operatorname{inprdsc}_{\operatorname{4-6}}) - 1.43(\operatorname{eduail1}_{\operatorname{Doctorate\ Degree}} \times \operatorname{inprdsc}_{\operatorname{7-9}}) + 1.8(\operatorname{eduail1}_{\operatorname{Junior\ High\ School}} \times \operatorname{inprdsc}_{\operatorname{7-9}}) - 0.16(\operatorname{eduail1}_{\operatorname{Master's\ Degree}} \times \operatorname{inprdsc}_{\operatorname{7-9}}) + 3.42(\operatorname{eduail1}_{\operatorname{Not\ completed\ Primary\ Education}} \times \operatorname{inprdsc}_{\operatorname{7-9}}) + 0.84(\operatorname{eduail1}_{\operatorname{Post-Secondary\ School\ (Non-Tetiary)}} \times \operatorname{inprdsc}_{\operatorname{7-9}}) + 0.93(\operatorname{eduail1}_{\operatorname{Primary\ School}} \times \operatorname{inprdsc}_{\operatorname{7-9}}) + 0.35(\operatorname{eduail1}_{\operatorname{Secondary\ School}} \times \operatorname{inprdsc}_{\operatorname{7-9}}) - 2.49(\operatorname{eduail1}_{\operatorname{Doctorate\ Degree}} \times \operatorname{inprdsc}_{\operatorname{None}}) - 0.24(\operatorname{eduail1}_{\operatorname{Junior\ High\ School}} \times \operatorname{inprdsc}_{\operatorname{None}}) - 2.8(\operatorname{eduail1}_{\operatorname{Master's\ Degree}} \times \operatorname{inprdsc}_{\operatorname{None}}) - 0.07(\operatorname{eduail1}_{\operatorname{Not\ completed\ Primary\ Education}} \times \operatorname{inprdsc}_{\operatorname{None}}) - 1.31(\operatorname{eduail1}_{\operatorname{Post-Secondary\ School\ (Non-Tetiary)}} \times \operatorname{inprdsc}_{\operatorname{None}}) - 1.13(\operatorname{eduail1}_{\operatorname{Primary\ School}} \times \operatorname{inprdsc}_{\operatorname{None}}) - 0.71(\operatorname{eduail1}_{\operatorname{Secondary\ School}} \times \operatorname{inprdsc}_{\operatorname{None}}) \]