Problem Set 6 Due: August 7, 2024

Submit both the .Rmd (R markdown file) and R Pubs published version (with link provided). Copy/paste all the tasks as text and provide the relevant code and text answer when prompted.

Task 1 Using the Civil dataset, perform a simple linear regression with public_sector_corruption as the dependent variable and polyarchy as the independent variable. Visualize the relationship with a scatter plot and overlay the regression line. Use the sjPlot package to create regression tables and interpret the results.

# List of packages
packages <- c("tidyverse", "gapminder", "fst", "viridis", "ggridges", "modelsummary","packrat","rsconnect")

# 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)
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr     1.1.4     ✔ readr     2.1.5
## ✔ forcats   1.0.0     ✔ stringr   1.5.1
## ✔ ggplot2   3.5.1     ✔ tibble    3.2.1
## ✔ lubridate 1.9.3     ✔ tidyr     1.3.1
## ✔ 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
## 载入需要的程序包:viridisLite
## 
## `modelsummary` 2.0.0 now uses `tinytable` as its default table-drawing
##   backend. Learn more at: https://vincentarelbundock.github.io/tinytable/
## 
## Revert to `kableExtra` for one session:
## 
##   options(modelsummary_factory_default = 'kableExtra')
##   options(modelsummary_factory_latex = 'kableExtra')
##   options(modelsummary_factory_html = 'kableExtra')
## 
## Silence this message forever:
## 
##   config_modelsummary(startup_message = FALSE)
## [[1]]
##  [1] "lubridate" "forcats"   "stringr"   "dplyr"     "purrr"     "readr"    
##  [7] "tidyr"     "tibble"    "ggplot2"   "tidyverse" "stats"     "graphics" 
## [13] "grDevices" "utils"     "datasets"  "methods"   "base"     
## 
## [[2]]
##  [1] "gapminder" "lubridate" "forcats"   "stringr"   "dplyr"     "purrr"    
##  [7] "readr"     "tidyr"     "tibble"    "ggplot2"   "tidyverse" "stats"    
## [13] "graphics"  "grDevices" "utils"     "datasets"  "methods"   "base"     
## 
## [[3]]
##  [1] "fst"       "gapminder" "lubridate" "forcats"   "stringr"   "dplyr"    
##  [7] "purrr"     "readr"     "tidyr"     "tibble"    "ggplot2"   "tidyverse"
## [13] "stats"     "graphics"  "grDevices" "utils"     "datasets"  "methods"  
## [19] "base"     
## 
## [[4]]
##  [1] "viridis"     "viridisLite" "fst"         "gapminder"   "lubridate"  
##  [6] "forcats"     "stringr"     "dplyr"       "purrr"       "readr"      
## [11] "tidyr"       "tibble"      "ggplot2"     "tidyverse"   "stats"      
## [16] "graphics"    "grDevices"   "utils"       "datasets"    "methods"    
## [21] "base"       
## 
## [[5]]
##  [1] "ggridges"    "viridis"     "viridisLite" "fst"         "gapminder"  
##  [6] "lubridate"   "forcats"     "stringr"     "dplyr"       "purrr"      
## [11] "readr"       "tidyr"       "tibble"      "ggplot2"     "tidyverse"  
## [16] "stats"       "graphics"    "grDevices"   "utils"       "datasets"   
## [21] "methods"     "base"       
## 
## [[6]]
##  [1] "modelsummary" "ggridges"     "viridis"      "viridisLite"  "fst"         
##  [6] "gapminder"    "lubridate"    "forcats"      "stringr"      "dplyr"       
## [11] "purrr"        "readr"        "tidyr"        "tibble"       "ggplot2"     
## [16] "tidyverse"    "stats"        "graphics"     "grDevices"    "utils"       
## [21] "datasets"     "methods"      "base"        
## 
## [[7]]
##  [1] "packrat"      "modelsummary" "ggridges"     "viridis"      "viridisLite" 
##  [6] "fst"          "gapminder"    "lubridate"    "forcats"      "stringr"     
## [11] "dplyr"        "purrr"        "readr"        "tidyr"        "tibble"      
## [16] "ggplot2"      "tidyverse"    "stats"        "graphics"     "grDevices"   
## [21] "utils"        "datasets"     "methods"      "base"        
## 
## [[8]]
##  [1] "rsconnect"    "packrat"      "modelsummary" "ggridges"     "viridis"     
##  [6] "viridisLite"  "fst"          "gapminder"    "lubridate"    "forcats"     
## [11] "stringr"      "dplyr"        "purrr"        "readr"        "tidyr"       
## [16] "tibble"       "ggplot2"      "tidyverse"    "stats"        "graphics"    
## [21] "grDevices"    "utils"        "datasets"     "methods"      "base"
library(magrittr)
## 
## 载入程序包:'magrittr'
## 
## The following object is masked from 'package:purrr':
## 
##     set_names
## 
## The following object is masked from 'package:tidyr':
## 
##     extract
library(dplyr)
options(repos = c(CRAN = "https://cloud.r-project.org/"))
install.packages("ggrepel")
## 程序包'ggrepel'打开成功,MD5和检查也通过
## Warning: 无法删除软件包 'ggrepel' 的先前安装
## Warning in file.copy(savedcopy, lib, recursive = TRUE): 拷贝D:\UT多伦多大学\SOC
## 252\R-4.4.1\library\00LOCK\ggrepel\libs\x64\ggrepel.dll到D:\UT多伦多大学\SOC
## 252\R-4.4.1\library\ggrepel\libs\x64\ggrepel.dll时出了问题:Permission denied
## Warning: 回复了'ggrepel'
## 
## 下载的二进制程序包在
##  C:\Users\14661\AppData\Local\Temp\RtmpiAjYEj\downloaded_packages里
install.packages("ggrepel")
## 程序包'ggrepel'打开成功,MD5和检查也通过
## Warning: 无法删除软件包 'ggrepel' 的先前安装
## Warning in file.copy(savedcopy, lib, recursive = TRUE): 拷贝D:\UT多伦多大学\SOC
## 252\R-4.4.1\library\00LOCK\ggrepel\libs\x64\ggrepel.dll到D:\UT多伦多大学\SOC
## 252\R-4.4.1\library\ggrepel\libs\x64\ggrepel.dll时出了问题:Permission denied
## Warning: 回复了'ggrepel'
## 
## 下载的二进制程序包在
##  C:\Users\14661\AppData\Local\Temp\RtmpiAjYEj\downloaded_packages里
library(ggrepel)
library(ggplot2)
load("Civil.RData")

Civil <- corruption


# Display the first few rows and structure of the dataset
head(Civil)
##   country_name country_text_id year                           region
## 1       Mexico             MEX 2020  Latin America and the Caribbean
## 2     Suriname             SUR 2020  Latin America and the Caribbean
## 3       Sweden             SWE 2020 Western Europe and North America
## 4  Switzerland             CHE 2020 Western Europe and North America
## 5        Ghana             GHA 2020               Sub-Saharan Africa
## 6 South Africa             ZAF 2020               Sub-Saharan Africa
##   disclose_donations_ord public_sector_corruption polyarchy civil_liberties
## 1                      3                     48.8      64.7            71.2
## 2                      1                     24.8      76.1            87.7
## 3                      2                      1.3      90.8            96.9
## 4                      0                      1.4      89.4            94.8
## 5                      2                     65.2      72.0            90.4
## 6                      1                     57.1      70.3            82.2
##   disclose_donations iso2c population gdp_percapita     capital longitude
## 1               TRUE    MX  128932753      8922.612 Mexico City  -99.1276
## 2              FALSE    SR     586634      7529.614  Paramaribo  -55.1679
## 3              FALSE    SE   10353442     51541.656   Stockholm   18.0645
## 4              FALSE    CH    8636561     85685.290        Bern   7.44821
## 5              FALSE    GH   31072945      2020.624       Accra  -0.20795
## 6              FALSE    ZA   59308690      5659.207    Pretoria   28.1871
##   latitude              income log_gdp_percapita
## 1   19.427 Upper middle income          9.096344
## 2   5.8232 Upper middle income          8.926599
## 3  59.3327         High income         10.850146
## 4   46.948         High income         11.358436
## 5  5.57045 Lower middle income          7.611162
## 6  -25.746 Upper middle income          8.641039
str(Civil)
## 'data.frame':    168 obs. of  17 variables:
##  $ country_name            : chr  "Mexico" "Suriname" "Sweden" "Switzerland" ...
##  $ country_text_id         : chr  "MEX" "SUR" "SWE" "CHE" ...
##  $ year                    : num  2020 2020 2020 2020 2020 2020 2020 2020 2020 2020 ...
##  $ region                  : Factor w/ 6 levels "Eastern Europe and Central Asia",..: 2 2 5 5 4 4 6 6 1 1 ...
##  $ disclose_donations_ord  : num  3 1 2 0 2 1 3 2 3 2 ...
##  $ public_sector_corruption: num  48.8 24.8 1.3 1.4 65.2 57.1 3.7 36.8 70.6 71.2 ...
##  $ polyarchy               : num  64.7 76.1 90.8 89.4 72 70.3 83.2 43.6 26.2 48.5 ...
##  $ civil_liberties         : num  71.2 87.7 96.9 94.8 90.4 82.2 92.8 56.9 43 85.5 ...
##  $ disclose_donations      : logi  TRUE FALSE FALSE FALSE FALSE FALSE ...
##  $ iso2c                   : chr  "MX" "SR" "SE" "CH" ...
##  $ population              : num  1.29e+08 5.87e+05 1.04e+07 8.64e+06 3.11e+07 ...
##   ..- attr(*, "label")= chr "Population, total"
##  $ gdp_percapita           : num  8923 7530 51542 85685 2021 ...
##   ..- attr(*, "label")= chr "GDP per capita (constant 2015 US$)"
##  $ capital                 : chr  "Mexico City" "Paramaribo" "Stockholm" "Bern" ...
##  $ longitude               : chr  "-99.1276" "-55.1679" "18.0645" "7.44821" ...
##  $ latitude                : chr  "19.427" "5.8232" "59.3327" "46.948" ...
##  $ income                  : chr  "Upper middle income" "Upper middle income" "High income" "High income" ...
##  $ log_gdp_percapita       : num  9.1 8.93 10.85 11.36 7.61 ...
##   ..- attr(*, "label")= chr "GDP per capita (constant 2015 US$)"
plot_corruption <- corruption %>%
  mutate(highlight = polyarchy == min(polyarchy) | polyarchy == max(polyarchy))

ggplot(plot_corruption, aes(x = polyarchy, y = public_sector_corruption)) +
  geom_point(aes(color = highlight)) +
  stat_smooth(method = "lm", formula = y ~ x, linewidth = 1, color = "blue") +
  geom_label_repel(data = filter(plot_corruption, highlight == TRUE), 
                   aes(label = country_name), seed = 1234) +
  scale_color_manual(values = c("grey30", "red"), guide = "none") +
  labs(x = "polyarchy Index", y = "Public Sector Corruption Index") +
  theme_minimal()

model_simple <- lm(public_sector_corruption ~ polyarchy, data = corruption)
summary(model_simple)
## 
## Call:
## lm(formula = public_sector_corruption ~ polyarchy, data = corruption)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -69.498 -14.334   1.448  16.985  44.436 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept) 89.44444    3.95373   22.62   <2e-16 ***
## polyarchy   -0.82641    0.06786  -12.18   <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 21.68 on 166 degrees of freedom
## Multiple R-squared:  0.4718, Adjusted R-squared:  0.4686 
## F-statistic: 148.3 on 1 and 166 DF,  p-value: < 2.2e-16
library(modelsummary)
# Displaying the model summary in a neat table
modelsummary(model_simple, stars = TRUE, statistic = "std.error")
tinytable_7eaq9d54ct76kgkwk920
(1)
+ p < 0.1, * p < 0.05, ** p < 0.01, *** p < 0.001
(Intercept) 89.444***
(3.954)
polyarchy -0.826***
(0.068)
Num.Obs. 168
R2 0.472
R2 Adj. 0.469
AIC 1514.4
BIC 1523.7
Log.Lik. -754.181
RMSE 21.55
coef(model_simple)["polyarchy"]
##  polyarchy 
## -0.8264102

This coefficient represents the marginal effect of polyarchy on public sector corruption.

The coefficient for polyarchy is -0.8264102. This means that for each one-unit increase in the polyarchy index, the public sector corruption index decreases by approximately 0.80 units, on average, holding all else constant.

Task 2 Extend the model from Task 1 by adding a quadratic term for polyarchy to capture potential non-linear relationships. Visualize the polynomial relationship using ggplot2. Calculate the marginal effects of polyarchy at different levels (30, 60, 90) using both manual calculations and the marginaleffects package. Interpret the results.

model_sq <- lm(public_sector_corruption ~ polyarchy + I(polyarchy^2), data = corruption)
summary(model_sq)
## 
## Call:
## lm(formula = public_sector_corruption ~ polyarchy + I(polyarchy^2), 
##     data = corruption)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -64.462  -7.475   1.418  14.107  35.187 
## 
## Coefficients:
##                 Estimate Std. Error t value Pr(>|t|)    
## (Intercept)    53.116104   7.019792   7.567 2.55e-12 ***
## polyarchy       0.974653   0.305335   3.192  0.00169 ** 
## I(polyarchy^2) -0.017310   0.002874  -6.023 1.08e-08 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 19.69 on 165 degrees of freedom
## Multiple R-squared:  0.567,  Adjusted R-squared:  0.5618 
## F-statistic:   108 on 2 and 165 DF,  p-value: < 2.2e-16
# Displaying the model summary
modelsummary(model_sq, stars = TRUE, statistic = "std.error")
tinytable_k49e0lcvylg40qzdmx77
(1)
+ p < 0.1, * p < 0.05, ** p < 0.01, *** p < 0.001
(Intercept) 53.116***
(7.020)
polyarchy 0.975**
(0.305)
I(polyarchy^2) -0.017***
(0.003)
Num.Obs. 168
R2 0.567
R2 Adj. 0.562
AIC 1483.0
BIC 1495.5
Log.Lik. -737.489
RMSE 19.51
# Visualizing the polynomial relationship
ggplot(plot_corruption, aes(x = polyarchy, y = public_sector_corruption)) +
  geom_point(aes(color = highlight)) +
  stat_smooth(method = "lm", formula = y ~ x + I(x^2), linewidth = 1, color = "blue") +
  geom_label_repel(data = filter(plot_corruption, highlight == TRUE), 
                   aes(label = country_name), seed = 1234) +
  scale_color_manual(values = c("grey30", "red"), guide = "none") +
  labs(x = "polyarchy Index", y = "Public Sector Corruption Index") +
  theme_minimal()

# Extract coefficients
polyarchy1 <- coef(model_sq)["polyarchy"]
polyarchy2 <- coef(model_sq)["I(polyarchy^2)"]

# Function to calculate slope
polyarchy_slope <- function(x) polyarchy1 + (2 * polyarchy2 * x)

# Calculate slopes at different levels of civil liberties
polyarchy_slope(c(30, 60, 90))
## [1] -0.06392759 -1.10250800 -2.14108840

Interpretation:

At a polyarchy value of 30, the marginal effect is -0.06392759. This means that around this level of polyarchy, increasing polyarchy slightly is associated with a decrease in public sector corruption.

At a polyarchy value of 60 the marginal effect is -1.10250800. Here, an increase in polyarchy is associated with a decrease in public sector corruption.

At a polyarchy value of 90, the marginal effect is -2.14108840, indicating a stronger negative relationship at higher levels of polyarchy.

Task 3 Using the Civil dataset, fit a logistic regression model predicting the presence of campaign finance disclosure laws (disclose_donations) with public_sector_corruption and log_gdp_percapita as predictors. Use the sjPlot package to create regression tables and interpret the results.

plot_corruption <- corruption %>%
  mutate(highlight = disclose_donations == min(disclose_donations) | disclose_donations == max(disclose_donations))

ggplot(plot_corruption, aes(x = disclose_donations, y = public_sector_corruption)) +
  geom_point(aes(color = highlight)) +
  stat_smooth(method = "lm", formula = y ~ x, linewidth = 1, color = "blue") +
  geom_label_repel(data = filter(plot_corruption, highlight == TRUE), 
                   aes(label = country_name), seed = 1234) +
  scale_color_manual(values = c("grey30", "red"), guide = "none") +
  labs(x = "disclose_donations Index", y = "Public Sector Corruption Index") +
  theme_minimal()
## Warning: ggrepel: 154 unlabeled data points (too many overlaps). Consider
## increasing max.overlaps

model2 <- lm(public_sector_corruption ~ disclose_donations, data = corruption)
summary(model2)
## 
## Call:
## lm(formula = public_sector_corruption ~ disclose_donations, data = corruption)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -58.812 -16.611   1.988  16.439  52.290 
## 
## Coefficients:
##                        Estimate Std. Error t value Pr(>|t|)    
## (Intercept)              60.112      2.158   27.86   <2e-16 ***
## disclose_donationsTRUE  -40.702      3.641  -11.18   <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 22.53 on 166 degrees of freedom
## Multiple R-squared:  0.4294, Adjusted R-squared:  0.426 
## F-statistic: 124.9 on 1 and 166 DF,  p-value: < 2.2e-16
# Displaying the model summary in a neat table
modelsummary(model2, stars = TRUE, statistic = "std.error")
tinytable_bdd70y9fypuqy04q3pbn
(1)
+ p < 0.1, * p < 0.05, ** p < 0.01, *** p < 0.001
(Intercept) 60.112***
(2.158)
disclose_donationsTRUE -40.702***
(3.641)
Num.Obs. 168
R2 0.429
R2 Adj. 0.426
AIC 1527.3
BIC 1536.7
Log.Lik. -760.665
RMSE 22.39
coef(model2)["disclose_donations"]
## <NA> 
##   NA
model3 <- lm(public_sector_corruption ~ log_gdp_percapita + I(log_gdp_percapita^2), data = corruption)
summary(model3)
## 
## Call:
## lm(formula = public_sector_corruption ~ log_gdp_percapita + I(log_gdp_percapita^2), 
##     data = corruption)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -58.836 -10.394  -0.556  13.638  42.700 
## 
## Coefficients:
##                        Estimate Std. Error t value Pr(>|t|)   
## (Intercept)             30.2657    53.9292   0.561  0.57541   
## log_gdp_percapita       19.7086    12.6657   1.556  0.12161   
## I(log_gdp_percapita^2)  -2.0342     0.7302  -2.786  0.00596 **
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 20 on 165 degrees of freedom
## Multiple R-squared:  0.5532, Adjusted R-squared:  0.5477 
## F-statistic: 102.1 on 2 and 165 DF,  p-value: < 2.2e-16
# Displaying the model summary
modelsummary(model3, stars = TRUE, statistic = "std.error")
tinytable_o1bofmsz2o68777f0brn
(1)
+ p < 0.1, * p < 0.05, ** p < 0.01, *** p < 0.001
(Intercept) 30.266
(53.929)
log_gdp_percapita 19.709
(12.666)
I(log_gdp_percapita^2) -2.034**
(0.730)
Num.Obs. 168
R2 0.553
R2 Adj. 0.548
AIC 1488.3
BIC 1500.8
Log.Lik. -740.133
RMSE 19.82
# Visualizing the polynomial relationship
ggplot(plot_corruption, aes(x = log_gdp_percapita, y = public_sector_corruption)) +
  geom_point(aes(color = highlight)) +
  stat_smooth(method = "lm", formula = y ~ x + I(x^2), linewidth = 1, color = "blue") +
  geom_label_repel(data = filter(plot_corruption, highlight == TRUE), 
                   aes(label = country_name), seed = 1234) +
  scale_color_manual(values = c("grey30", "red"), guide = "none") +
  labs(x = "log_gdp_percapita Index", y = "Public Sector Corruption Index") +
  theme_minimal()
## Warning: ggrepel: 148 unlabeled data points (too many overlaps). Consider
## increasing max.overlaps

Task 4 Calculate the marginal effects of public_sector_corruption from the logistic regression model in Task 3 at representative values (20, 50, 80). Use the marginaleffects and emmeans packages to compute these effects. Visualize the predicted probabilities of having campaign finance disclosure laws across a range of public_sector_corruption values using ggplot2.

# Extract coefficients
log_gdp_percapita1 <- coef(model3)["log_gdp_percapita"]
log_gdp_percapita2 <- coef(model3)["I(log_gdp_percapita^2)"]

# Function to calculate slope
log_gdp_percapita_slope <- function(x) log_gdp_percapita1 + (2 * log_gdp_percapita2 * x)

# Calculate slopes at different levels of civil liberties
log_gdp_percapita_slope(c(20, 50, 80))
## [1]  -61.65913 -183.71071 -305.76229

Interpretation:

At a log_gdp_percapita value of 25, the marginal effect is -61.65913. This means that around this level of log_gdp_percapita, increasing log_gdp_percapita slightly is associated with a decrease in public sector corruption.

At a log_gdp_percapita value of 55, the marginal effect is -183.71071. Here, an increase in log_gdp_percapita is associated with a decrease in public sector corruption.

At a log_gdp_percapita value of 80, the marginal effect is -305.76229, indicating a stronger negative relationship at higher levels of log_gdp_percapita.

library(ggeffects)
library(parameters)
## 
## 载入程序包:'parameters'
## The following object is masked from 'package:modelsummary':
## 
##     supported_models

Task 5 Explore the interaction effect between public_sector_corruption and region in the logistic regression model from Task 3. Use the datagrid() function from the marginaleffects package to create a dataset with representative values for regions. Fit the logistic regression model with the interaction term and visualize the interaction effects using ggplot2. Interpret the results and discuss the implications of the interaction effect.

# Adding region to the polynomial model
model_region <- lm(public_sector_corruption ~ log_gdp_percapita + I(log_gdp_percapita^2) + region, data = corruption)
summary(model_region)
## 
## Call:
## lm(formula = public_sector_corruption ~ log_gdp_percapita + I(log_gdp_percapita^2) + 
##     region, data = corruption)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -56.977 -10.234   0.072  13.375  40.526 
## 
## Coefficients:
##                                        Estimate Std. Error t value Pr(>|t|)  
## (Intercept)                             94.1083    68.1710   1.380   0.1694  
## log_gdp_percapita                        5.5391    15.9087   0.348   0.7282  
## I(log_gdp_percapita^2)                  -1.2496     0.9329  -1.339   0.1823  
## regionLatin America and the Caribbean   -1.0270     5.4569  -0.188   0.8510  
## regionMiddle East and North Africa      12.7152     5.8724   2.165   0.0319 *
## regionSub-Saharan Africa                -5.0651     5.6506  -0.896   0.3714  
## regionWestern Europe and North America  -5.0302     7.5163  -0.669   0.5043  
## regionAsia and Pacific                  -4.7110     5.4415  -0.866   0.3879  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 19.61 on 160 degrees of freedom
## Multiple R-squared:  0.5835, Adjusted R-squared:  0.5653 
## F-statistic: 32.03 on 7 and 160 DF,  p-value: < 2.2e-16
library(modelsummary)
# Displaying the model summary
modelsummary(model_region, stars = TRUE, statistic = "std.error")
tinytable_drx4qwvwp7g9g2cua791
(1)
+ p < 0.1, * p < 0.05, ** p < 0.01, *** p < 0.001
(Intercept) 94.108
(68.171)
log_gdp_percapita 5.539
(15.909)
I(log_gdp_percapita^2) -1.250
(0.933)
regionLatin America and the Caribbean -1.027
(5.457)
regionMiddle East and North Africa 12.715*
(5.872)
regionSub-Saharan Africa -5.065
(5.651)
regionWestern Europe and North America -5.030
(7.516)
regionAsia and Pacific -4.711
(5.442)
Num.Obs. 168
R2 0.584
R2 Adj. 0.565
AIC 1486.4
BIC 1514.6
Log.Lik. -734.218
RMSE 19.13