Installing the packages
packages <- c("tidyverse", "infer", "fst", "modelsummary", "effects", "survey", "MASS", "kableExtra", "flextable", "equatiomatic", "broom", "forcats", "RColorBrewer", "viridis", "knitr", "ggridges", "sandwich")
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.4 ✔ readr 2.1.4
## ✔ forcats 1.0.0 ✔ stringr 1.5.1
## ✔ 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: carData
##
## lattice theme set by effectsTheme()
## See ?effectsTheme for details.
##
## Loading required package: grid
##
## Loading required package: Matrix
##
##
## Attaching package: 'Matrix'
##
##
## The following objects are masked from 'package:tidyr':
##
## expand, pack, unpack
##
##
## Loading required package: survival
##
##
## Attaching package: 'survey'
##
##
## The following object is masked from 'package:graphics':
##
## dotchart
##
##
##
## Attaching package: 'MASS'
##
##
## The following object is masked from 'package:dplyr':
##
## select
##
##
##
## Attaching package: 'kableExtra'
##
##
## The following object is masked from 'package:dplyr':
##
## group_rows
##
##
##
## Attaching package: 'flextable'
##
##
## The following objects are masked from 'package:kableExtra':
##
## as_image, footnote
##
##
## The following object is masked from 'package:purrr':
##
## compose
##
##
## Loading required package: viridisLite
## [[1]]
## [1] "lubridate" "forcats" "stringr" "dplyr" "purrr" "readr"
## [7] "tidyr" "tibble" "ggplot2" "tidyverse" "stats" "graphics"
## [13] "grDevices" "utils" "datasets" "methods" "base"
##
## [[2]]
## [1] "infer" "lubridate" "forcats" "stringr" "dplyr" "purrr"
## [7] "readr" "tidyr" "tibble" "ggplot2" "tidyverse" "stats"
## [13] "graphics" "grDevices" "utils" "datasets" "methods" "base"
##
## [[3]]
## [1] "fst" "infer" "lubridate" "forcats" "stringr" "dplyr"
## [7] "purrr" "readr" "tidyr" "tibble" "ggplot2" "tidyverse"
## [13] "stats" "graphics" "grDevices" "utils" "datasets" "methods"
## [19] "base"
##
## [[4]]
## [1] "modelsummary" "fst" "infer" "lubridate" "forcats"
## [6] "stringr" "dplyr" "purrr" "readr" "tidyr"
## [11] "tibble" "ggplot2" "tidyverse" "stats" "graphics"
## [16] "grDevices" "utils" "datasets" "methods" "base"
##
## [[5]]
## [1] "effects" "carData" "modelsummary" "fst" "infer"
## [6] "lubridate" "forcats" "stringr" "dplyr" "purrr"
## [11] "readr" "tidyr" "tibble" "ggplot2" "tidyverse"
## [16] "stats" "graphics" "grDevices" "utils" "datasets"
## [21] "methods" "base"
##
## [[6]]
## [1] "survey" "survival" "Matrix" "grid" "effects"
## [6] "carData" "modelsummary" "fst" "infer" "lubridate"
## [11] "forcats" "stringr" "dplyr" "purrr" "readr"
## [16] "tidyr" "tibble" "ggplot2" "tidyverse" "stats"
## [21] "graphics" "grDevices" "utils" "datasets" "methods"
## [26] "base"
##
## [[7]]
## [1] "MASS" "survey" "survival" "Matrix" "grid"
## [6] "effects" "carData" "modelsummary" "fst" "infer"
## [11] "lubridate" "forcats" "stringr" "dplyr" "purrr"
## [16] "readr" "tidyr" "tibble" "ggplot2" "tidyverse"
## [21] "stats" "graphics" "grDevices" "utils" "datasets"
## [26] "methods" "base"
##
## [[8]]
## [1] "kableExtra" "MASS" "survey" "survival" "Matrix"
## [6] "grid" "effects" "carData" "modelsummary" "fst"
## [11] "infer" "lubridate" "forcats" "stringr" "dplyr"
## [16] "purrr" "readr" "tidyr" "tibble" "ggplot2"
## [21] "tidyverse" "stats" "graphics" "grDevices" "utils"
## [26] "datasets" "methods" "base"
##
## [[9]]
## [1] "flextable" "kableExtra" "MASS" "survey" "survival"
## [6] "Matrix" "grid" "effects" "carData" "modelsummary"
## [11] "fst" "infer" "lubridate" "forcats" "stringr"
## [16] "dplyr" "purrr" "readr" "tidyr" "tibble"
## [21] "ggplot2" "tidyverse" "stats" "graphics" "grDevices"
## [26] "utils" "datasets" "methods" "base"
##
## [[10]]
## [1] "equatiomatic" "flextable" "kableExtra" "MASS" "survey"
## [6] "survival" "Matrix" "grid" "effects" "carData"
## [11] "modelsummary" "fst" "infer" "lubridate" "forcats"
## [16] "stringr" "dplyr" "purrr" "readr" "tidyr"
## [21] "tibble" "ggplot2" "tidyverse" "stats" "graphics"
## [26] "grDevices" "utils" "datasets" "methods" "base"
##
## [[11]]
## [1] "broom" "equatiomatic" "flextable" "kableExtra" "MASS"
## [6] "survey" "survival" "Matrix" "grid" "effects"
## [11] "carData" "modelsummary" "fst" "infer" "lubridate"
## [16] "forcats" "stringr" "dplyr" "purrr" "readr"
## [21] "tidyr" "tibble" "ggplot2" "tidyverse" "stats"
## [26] "graphics" "grDevices" "utils" "datasets" "methods"
## [31] "base"
##
## [[12]]
## [1] "broom" "equatiomatic" "flextable" "kableExtra" "MASS"
## [6] "survey" "survival" "Matrix" "grid" "effects"
## [11] "carData" "modelsummary" "fst" "infer" "lubridate"
## [16] "forcats" "stringr" "dplyr" "purrr" "readr"
## [21] "tidyr" "tibble" "ggplot2" "tidyverse" "stats"
## [26] "graphics" "grDevices" "utils" "datasets" "methods"
## [31] "base"
##
## [[13]]
## [1] "RColorBrewer" "broom" "equatiomatic" "flextable" "kableExtra"
## [6] "MASS" "survey" "survival" "Matrix" "grid"
## [11] "effects" "carData" "modelsummary" "fst" "infer"
## [16] "lubridate" "forcats" "stringr" "dplyr" "purrr"
## [21] "readr" "tidyr" "tibble" "ggplot2" "tidyverse"
## [26] "stats" "graphics" "grDevices" "utils" "datasets"
## [31] "methods" "base"
##
## [[14]]
## [1] "viridis" "viridisLite" "RColorBrewer" "broom" "equatiomatic"
## [6] "flextable" "kableExtra" "MASS" "survey" "survival"
## [11] "Matrix" "grid" "effects" "carData" "modelsummary"
## [16] "fst" "infer" "lubridate" "forcats" "stringr"
## [21] "dplyr" "purrr" "readr" "tidyr" "tibble"
## [26] "ggplot2" "tidyverse" "stats" "graphics" "grDevices"
## [31] "utils" "datasets" "methods" "base"
##
## [[15]]
## [1] "knitr" "viridis" "viridisLite" "RColorBrewer" "broom"
## [6] "equatiomatic" "flextable" "kableExtra" "MASS" "survey"
## [11] "survival" "Matrix" "grid" "effects" "carData"
## [16] "modelsummary" "fst" "infer" "lubridate" "forcats"
## [21] "stringr" "dplyr" "purrr" "readr" "tidyr"
## [26] "tibble" "ggplot2" "tidyverse" "stats" "graphics"
## [31] "grDevices" "utils" "datasets" "methods" "base"
##
## [[16]]
## [1] "ggridges" "knitr" "viridis" "viridisLite" "RColorBrewer"
## [6] "broom" "equatiomatic" "flextable" "kableExtra" "MASS"
## [11] "survey" "survival" "Matrix" "grid" "effects"
## [16] "carData" "modelsummary" "fst" "infer" "lubridate"
## [21] "forcats" "stringr" "dplyr" "purrr" "readr"
## [26] "tidyr" "tibble" "ggplot2" "tidyverse" "stats"
## [31] "graphics" "grDevices" "utils" "datasets" "methods"
## [36] "base"
##
## [[17]]
## [1] "sandwich" "ggridges" "knitr" "viridis" "viridisLite"
## [6] "RColorBrewer" "broom" "equatiomatic" "flextable" "kableExtra"
## [11] "MASS" "survey" "survival" "Matrix" "grid"
## [16] "effects" "carData" "modelsummary" "fst" "infer"
## [21] "lubridate" "forcats" "stringr" "dplyr" "purrr"
## [26] "readr" "tidyr" "tibble" "ggplot2" "tidyverse"
## [31] "stats" "graphics" "grDevices" "utils" "datasets"
## [36] "methods" "base"
Load in the ESS dataset
ess <- read_fst("All-ESS-Data.fst")
Filtering for country and recoding the variables of interest
german_data <- ess %>%
filter(cntry == "DE") %>%
mutate(
minority_immigration = recode(as.character(imdfetn),
'1' = "Allow many to come and live here",
'2' = "Allow some",
'3' = "Allow a few",
'4' = "Allow none",
'7' = NA_character_,
'8' = NA_character_,
'9' = NA_character_),
born_in_country = recode(as.character(brncntr),
'1' = "Yes",
'2' = "No",
'7' = NA_character_,
'8' = NA_character_,
'9' = NA_character_),
lr = recode(as.character(lrscale),
'0' = "Left",
'1' = "Left",
'2' = "Left",
'3' = "Left",
'4' = "Center",
'5' = "Center",
'6' = "Center",
'7' = "Right",
'8' = "Right",
'9' = "Right",
'10' = "Right",
'77' = NA_character_,
'88' = NA_character_,
'99' = NA_character_),
)
Creating a flextable (summary statistics)
german_table <- german_data %>%
mutate(
imdfetn = ifelse(imdfetn %in% c(7, 8, 9), NA, imdfetn),
lrscale = ifelse(lrscale %in% c(77, 88, 99), NA, lrscale),
brncntr = ifelse(brncntr == 1, 2, ifelse(brncntr %in% c(7, 8, 9), NA, brncntr))
)
summary_table <- datasummary_skim(german_table %>% dplyr::select(imdfetn, lrscale, brncntr), output = "flextable")
## Warning: The histogram argument is only supported for (a) output types "default",
## "html", "kableExtra", or "gt"; (b) writing to file paths with extensions
## ".html", ".jpg", or ".png"; and (c) Rmarkdown, knitr or Quarto documents
## compiled to PDF (via kableExtra) or HTML (via kableExtra or gt). Use
## `histogram=FALSE` to silence this warning.
summary_table
| Unique (#) | Missing (%) | Mean | SD | Min | Median | Max |
|---|---|---|---|---|---|---|---|
imdfetn | 5 | 2 | 2.2 | 0.8 | 1.0 | 2.0 | 4.0 |
lrscale | 12 | 7 | 4.5 | 1.9 | 0.0 | 5.0 | 10.0 |
brncntr | 2 | 0 | 2.0 | 0.0 | 2.0 | 2.0 | 2.0 |
Editing and saving flextable as .pdf
german_data_v2 <- german_table %>%
rename(
`Allow minority race/ethnic group immigration` = imdfetn,
`Placement on Left-Right Scale` = lrscale,
`Born in Country` = brncntr
)
summary_table_v2 <- datasummary_skim(german_data_v2 %>% dplyr::select(`Allow minority race/ethnic group immigration`, `Placement on Left-Right Scale`, `Born in Country`), output = "flextable")
## Warning: The histogram argument is only supported for (a) output types "default",
## "html", "kableExtra", or "gt"; (b) writing to file paths with extensions
## ".html", ".jpg", or ".png"; and (c) Rmarkdown, knitr or Quarto documents
## compiled to PDF (via kableExtra) or HTML (via kableExtra or gt). Use
## `histogram=FALSE` to silence this warning.
summary_table_v2
| Unique (#) | Missing (%) | Mean | SD | Min | Median | Max |
|---|---|---|---|---|---|---|---|
Allow minority race/ethnic group immigration | 5 | 2 | 2.2 | 0.8 | 1.0 | 2.0 | 4.0 |
Placement on Left-Right Scale | 12 | 7 | 4.5 | 1.9 | 0.0 | 5.0 | 10.0 |
Born in Country | 2 | 0 | 2.0 | 0.0 | 2.0 | 2.0 | 2.0 |
set_flextable_defaults(fonts_ignore=TRUE)
print(summary_table_v2, preview = "pdf")
## a flextable object.
## col_keys: ` `, `Unique (#)`, `Missing (%)`, `Mean`, `SD`, `Min`, `Median`, `Max`
## header has 1 row(s)
## body has 3 row(s)
## original dataset sample:
## Unique (#) Missing (%) Mean SD
## 1 Allow minority race/ethnic group immigration 5 2 2.2 0.8
## 2 Placement on Left-Right Scale 12 7 4.5 1.9
## 3 Born in Country 2 0 2.0 0.0
## Min Median Max
## 1 1.0 2.0 4.0
## 2 0.0 5.0 10.0
## 3 2.0 2.0 2.0
Redoing the variables (outcome, predictors)
german_data_v3 <- ess %>%
filter(cntry == "DE")
df <- german_data_v3 %>%
mutate(
imdfetn = ifelse(imdfetn %in% c(7, 8, 9), NA, imdfetn))
df$minority_immigration <- scales::rescale(df$imdfetn, to=c(1,4), na.rm = TRUE)
df <- df %>% filter(!is.na(minority_immigration))
ggplot(df, aes(x = minority_immigration)) +
geom_histogram(bins = 4, fill = "orange", color = "grey") +
theme_minimal() +
labs(title = "Histogram of Allowing Minority Immigration",
x = "Allowing Minority Immigration Scale",
y = "Count")
df <- df %>%
mutate(
LR = case_when(
lrscale %in% 0:3 ~ "Left",
lrscale %in% 4:6 ~ "Center",
lrscale %in% 7:10 ~ "Right",
lrscale %in% c(77, 88, 99) ~ NA_character_
),
nativity = case_when(
brncntr == 1 ~ 1,
TRUE ~ 0
)
)
Viewing tables and extra bath for new predictors
table(df$nativity)
##
## 0 1
## 3241 30375
table(df$LR)
##
## Center Left Right
## 18601 9211 3797
df <- df %>% filter(!is.na(LR))
df <- df %>% filter(!is.na(nativity))
Creating a new data summary table
dst <- df %>%
mutate(
LR_n = as.numeric(factor(LR, levels = c("Left", "Center", "Right"))),
nativity_n = as.numeric(nativity)
)
dst <- dst %>%
rename(
`Placement on Political LR Scale` = LR_n,
`Born in Germany` = nativity_n,
`Allow Minority Immigration` = minority_immigration
)
new_table <- datasummary_skim(dst %>% dplyr::select(`Placement on Political LR Scale`, `Born in Germany`, `Allow Minority Immigration`), output = "flextable")
## Warning: The histogram argument is only supported for (a) output types "default",
## "html", "kableExtra", or "gt"; (b) writing to file paths with extensions
## ".html", ".jpg", or ".png"; and (c) Rmarkdown, knitr or Quarto documents
## compiled to PDF (via kableExtra) or HTML (via kableExtra or gt). Use
## `histogram=FALSE` to silence this warning.
new_table
| Unique (#) | Missing (%) | Mean | SD | Min | Median | Max |
|---|---|---|---|---|---|---|---|
Placement on Political LR Scale | 3 | 0 | 1.8 | 0.6 | 1.0 | 2.0 | 3.0 |
Born in Germany | 2 | 0 | 0.9 | 0.3 | 0.0 | 1.0 | 1.0 |
Allow Minority Immigration | 4 | 0 | 2.2 | 0.8 | 1.0 | 2.0 | 4.0 |
set_flextable_defaults(fonts_ignore=TRUE)
print(new_table, preview = "pdf")
## a flextable object.
## col_keys: ` `, `Unique (#)`, `Missing (%)`, `Mean`, `SD`, `Min`, `Median`, `Max`
## header has 1 row(s)
## body has 3 row(s)
## original dataset sample:
## Unique (#) Missing (%) Mean SD Min Median
## 1 Placement on Political LR Scale 3 0 1.8 0.6 1.0 2.0
## 2 Born in Germany 2 0 0.9 0.3 0.0 1.0
## 3 Allow Minority Immigration 4 0 2.2 0.8 1.0 2.0
## Max
## 1 3.0
## 2 1.0
## 3 4.0
Calculating the test statistic
test_stat <- df %>%
specify(explanatory = LR,
response = minority_immigration) %>%
hypothesize(null = "independence") %>%
calculate(stat = "F")
print(test_stat$stat)
## [1] 963.9554
Simulating the null distribution
null_distribution <- df %>%
specify(explanatory = LR,
response = minority_immigration) %>%
hypothesize(null = "independence") %>%
generate(reps = 1000, type = "permute") %>%
calculate(stat = "F")
Calculating the p-value of the sample
p_value <- null_distribution %>%
get_pvalue(obs_stat = test_stat, direction = "two-sided")
## 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_value
## # A tibble: 1 × 1
## p_value
## <dbl>
## 1 0
Visualizing the null distribution and confidence intervals (0.95) with linear regression
ci <- null_distribution %>%
get_confidence_interval(level = 0.95, type = "percentile")
null_distribution %>%
visualize() +
shade_p_value(obs_stat = test_stat, direction = "two-sided") +
shade_confidence_interval(endpoints = ci)
## Warning: F usually corresponds to right-tailed tests. Proceed with caution.
null_distribution
## Response: minority_immigration (numeric)
## Explanatory: LR (factor)
## Null Hypothesis: independence
## # A tibble: 1,000 × 2
## replicate stat
## <int> <dbl>
## 1 1 0.801
## 2 2 2.64
## 3 3 0.00890
## 4 4 0.137
## 5 5 0.465
## 6 6 0.228
## 7 7 0.651
## 8 8 0.866
## 9 9 0.576
## 10 10 2.67
## # ℹ 990 more rows
test_stat <- 963.9554
conf_int <- null_distribution %>%
get_confidence_interval(level = 0.95, type = "percentile")
null_distribution %>%
visualize(bins = 10, method = "simulation") +
geom_vline(aes(xintercept = test_stat), linetype = "dashed", size = 1) +
shade_p_value(obs_stat = test_stat, direction = "greater") +
shade_confidence_interval(endpoints = conf_int) +
coord_cartesian(xlim = c(0, max(null_distribution$stat) * 1.1)) + # Set manual x-axis limits
labs(title = "Simulation-Based Null Distribution",
x = "F-statistic (ANOVA)",
y = "Count")
## 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.
## Warning in min(diff(unique_loc)): no non-missing arguments to min; returning
## Inf
Regression modelling
df$weight <- df$weight * df$weight
model1 <- lm(minority_immigration ~ LR, data = df, weights = weight)
model2 <- lm(minority_immigration ~ LR + nativity, data = df, weights = weight)
model3 <- lm(minority_immigration ~ LR + LR*nativity, data = df, weights = weight)
Model summary
modelsummary(
list(model1, model2, model3),
fmt = 1,
estimate = c("{estimate} ({std.error}){stars}",
"{estimate} ({std.error}){stars}",
"{estimate} ({std.error}){stars}"),
statistic = NULL,
coef_omit = "Intercept")
| Â (1) | Â Â (2) | Â Â (3) | |
|---|---|---|---|
| LRLeft | −0.3 (0.0)*** | −0.3 (0.0)*** | 0.0 (0.2) |
| LRRight | −0.1 (0.1)** | −0.1 (0.1)** | 0.3 (0.2) |
| nativity | 0.0 (0.1) | 0.1 (0.1) | |
| LRLeft × nativity | −0.3 (0.2)* | ||
| LRRight × nativity | −0.4 (0.2)* | ||
| Num.Obs. | 2890 | 2890 | 2890 |
| R2 | 0.035 | 0.035 | 0.037 |
| R2 Adj. | 0.034 | 0.034 | 0.035 |
| AIC | 9319.7 | 9321.7 | 9318.4 |
| BIC | 9343.6 | 9351.5 | 9360.2 |
| Log.Lik. | −4655.838 | −4655.838 | −4652.204 |
| RMSE | 0.78 | 0.78 | 0.78 |
More in-depth model summary
models <- list(
"Model 1: Single" = lm(minority_immigration ~ LR, data = df, weights = weight),
"Model 2: Multivariate" = lm(minority_immigration ~ LR + nativity, data = df, weights = weight),
"Model 3: Interaction" = lm(minority_immigration ~ LR + LR*nativity, data = df, weights = weight)
)
modelsummary(models, vcov = "robust")
| Model 1: Single | Â Model 2: Multivariate | Â Model 3: Interaction | |
|---|---|---|---|
| (Intercept) | 2.166 | 2.167 | 2.086 |
| (0.086) | (0.404) | (0.552) | |
| LRLeft | −0.311 | −0.311 | 0.012 |
| (0.152) | (0.152) | (0.558) | |
| LRRight | −0.140 | −0.140 | 0.264 |
| (0.234) | (0.235) | (0.564) | |
| nativity | −0.001 | 0.086 | |
| (0.401) | (0.559) | ||
| LRLeft × nativity | −0.336 | ||
| (0.580) | |||
| LRRight × nativity | −0.433 | ||
| (0.616) | |||
| Num.Obs. | 2890 | 2890 | 2890 |
| R2 | 0.035 | 0.035 | 0.037 |
| R2 Adj. | 0.034 | 0.034 | 0.035 |
| AIC | 9319.7 | 9321.7 | 9318.4 |
| BIC | 9343.6 | 9351.5 | 9360.2 |
| Log.Lik. | −4655.838 | −4655.838 | −4652.204 |
| RMSE | 0.78 | 0.78 | 0.78 |
| Std.Errors | HC3 | HC3 | HC3 |
Relabeling and adding title
modelsummary(models, fmt = 1,
estimate = c("{estimate} ({std.error}){stars}",
"{estimate} ({std.error}){stars}",
"{estimate} ({std.error}){stars}"),
statistic = NULL,
coef_rename = c("LRLeft" = "Left", "LRRight" = "Right", "nativity" = "Native", "LRLeft × nativity" = "Left-leaning Native", "LRRight × nativity" = "Right-leaning Native"),
title = 'Table 2. Regression models predicting minority immigration attitudes')
| Model 1: Single | Â Model 2: Multivariate | Â Model 3: Interaction | |
|---|---|---|---|
| (Intercept) | 2.2 (0.0)*** | 2.2 (0.1)*** | 2.1 (0.1)*** |
| Left | −0.3 (0.0)*** | −0.3 (0.0)*** | 0.0 (0.2) |
| Right | −0.1 (0.1)** | −0.1 (0.1)** | 0.3 (0.2) |
| Native | 0.0 (0.1) | 0.1 (0.1) | |
| Left:Native | −0.3 (0.2)* | ||
| Right:Native | −0.4 (0.2)* | ||
| Num.Obs. | 2890 | 2890 | 2890 |
| R2 | 0.035 | 0.035 | 0.037 |
| R2 Adj. | 0.034 | 0.034 | 0.035 |
| AIC | 9319.7 | 9321.7 | 9318.4 |
| BIC | 9343.6 | 9351.5 | 9360.2 |
| Log.Lik. | −4655.838 | −4655.838 | −4652.204 |
| RMSE | 0.78 | 0.78 | 0.78 |
Creating an interaction plot (third visual)
interaction_plot <- effect("LR*nativity", model3, na.rm = TRUE)
plot(interaction_plot,
main = "Interaction effect",
xlab = "Nativity",
ylab = "Allow Minority Immigration")
interaction_plot
##
## LR*nativity effect
## nativity
## LR 0 0.2 0.5 0.8 1
## Center 2.086063 2.103208 2.128925 2.154643 2.171787
## Left 2.097712 2.047712 1.972713 1.897713 1.847713
## Right 2.350172 2.280722 2.176546 2.072371 2.002921
Creating an equatiomatic equation
equatiomatic::extract_eq(model3, use_coefs = TRUE)
\[ \operatorname{\widehat{minority\_immigration}} = 2.09 + 0.01(\operatorname{LR}_{\operatorname{Left}}) + 0.26(\operatorname{LR}_{\operatorname{Right}}) + 0.09(\operatorname{nativity}) - 0.34(\operatorname{LR}_{\operatorname{Left}} \times \operatorname{nativity}) - 0.43(\operatorname{LR}_{\operatorname{Right}} \times \operatorname{nativity}) \]