CASD_2

# loading libraries
library(tidyverse)
Warning: Paket 'tidyverse' wurde unter R Version 4.2.2 erstellt
── Attaching packages ─────────────────────────────────────── tidyverse 1.3.2 ──
✔ ggplot2 3.4.0     ✔ purrr   1.0.1
✔ tibble  3.1.8     ✔ dplyr   1.1.0
✔ tidyr   1.3.0     ✔ stringr 1.5.0
✔ readr   2.1.3     ✔ forcats 1.0.0
Warning: Paket 'ggplot2' wurde unter R Version 4.2.2 erstellt
Warning: Paket 'tibble' wurde unter R Version 4.2.2 erstellt
Warning: Paket 'tidyr' wurde unter R Version 4.2.2 erstellt
Warning: Paket 'readr' wurde unter R Version 4.2.2 erstellt
Warning: Paket 'purrr' wurde unter R Version 4.2.2 erstellt
Warning: Paket 'dplyr' wurde unter R Version 4.2.2 erstellt
Warning: Paket 'stringr' wurde unter R Version 4.2.2 erstellt
Warning: Paket 'forcats' wurde unter R Version 4.2.2 erstellt
── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
✖ dplyr::filter() masks stats::filter()
✖ dplyr::lag()    masks stats::lag()
library(tidyquant)
Warning: Paket 'tidyquant' wurde unter R Version 4.2.2 erstellt
Lade nötiges Paket: lubridate
Warning: Paket 'lubridate' wurde unter R Version 4.2.2 erstellt

Attache Paket: 'lubridate'

Die folgenden Objekte sind maskiert von 'package:base':

    date, intersect, setdiff, union

Lade nötiges Paket: PerformanceAnalytics
Warning: Paket 'PerformanceAnalytics' wurde unter R Version 4.2.2 erstellt
Lade nötiges Paket: xts
Warning: Paket 'xts' wurde unter R Version 4.2.2 erstellt
Lade nötiges Paket: zoo
Warning: Paket 'zoo' wurde unter R Version 4.2.2 erstellt

Attache Paket: 'zoo'

Die folgenden Objekte sind maskiert von 'package:base':

    as.Date, as.Date.numeric


Attache Paket: 'xts'

Die folgenden Objekte sind maskiert von 'package:dplyr':

    first, last


Attache Paket: 'PerformanceAnalytics'

Das folgende Objekt ist maskiert 'package:graphics':

    legend

Lade nötiges Paket: quantmod
Warning: Paket 'quantmod' wurde unter R Version 4.2.2 erstellt
Lade nötiges Paket: TTR
Warning: Paket 'TTR' wurde unter R Version 4.2.2 erstellt
Registered S3 method overwritten by 'quantmod':
  method            from
  as.zoo.data.frame zoo 
library(scales)
Warning: Paket 'scales' wurde unter R Version 4.2.2 erstellt

Attache Paket: 'scales'

Das folgende Objekt ist maskiert 'package:purrr':

    discard

Das folgende Objekt ist maskiert 'package:readr':

    col_factor
library(ggrepel)
Warning: Paket 'ggrepel' wurde unter R Version 4.2.2 erstellt
library(readxl)
Warning: Paket 'readxl' wurde unter R Version 4.2.2 erstellt
library(readr)
library(janitor)
Warning: Paket 'janitor' wurde unter R Version 4.2.2 erstellt

Attache Paket: 'janitor'

Die folgenden Objekte sind maskiert von 'package:stats':

    chisq.test, fisher.test
library(here)
Warning: Paket 'here' wurde unter R Version 4.2.2 erstellt
here() starts at C:/Users/Bentje/Documents/JHU/Spring23/SustFin/CASD
library(rnaturalearth)
Warning: Paket 'rnaturalearth' wurde unter R Version 4.2.2 erstellt
library(countrycode)
Warning: Paket 'countrycode' wurde unter R Version 4.2.2 erstellt
library(wbstats)
Warning: Paket 'wbstats' wurde unter R Version 4.2.2 erstellt
options(scipen=10)
# getwd()
# read processed datasets
final_energy_imports <- read_csv("./processed_01/final_energy_imports.csv")
Rows: 2016 Columns: 10
── Column specification ────────────────────────────────────────────────────────
Delimiter: ","
chr (8): country_name, iso3c, country_or_region, indicator, industry, partne...
dbl (2): year, energy_imports

ℹ Use `spec()` to retrieve the full column specification for this data.
ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
final_gdp_ppp <- read_csv("./processed_01/final_gdp_ppp.csv")
Rows: 6510 Columns: 5
── Column specification ────────────────────────────────────────────────────────
Delimiter: ","
chr (3): country_name, iso3c, country
dbl (2): year, GDP_PPP

ℹ Use `spec()` to retrieve the full column specification for this data.
ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
final_ghg_ex_LUCF <- read_csv("./processed_01/final_ghg_ex_LUCF.csv")
Rows: 4825 Columns: 6
── Column specification ────────────────────────────────────────────────────────
Delimiter: ","
chr (4): iso3c, country_name, Country/Region, unit
dbl (2): year, GHG_excl_LUCF

ℹ Use `spec()` to retrieve the full column specification for this data.
ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
final_ghg_in_LUCF <- read_csv("./processed_01/final_ghg_in_LUCF.csv")
Rows: 4825 Columns: 6
── Column specification ────────────────────────────────────────────────────────
Delimiter: ","
chr (4): country_name, Country/Region, iso3c, unit
dbl (2): year, GHG_incl_LUCF

ℹ Use `spec()` to retrieve the full column specification for this data.
ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
final_total_exports <- read_csv("./processed_01/final_total_exports.csv")
Rows: 2016 Columns: 10
── Column specification ────────────────────────────────────────────────────────
Delimiter: ","
chr (8): country_name, iso3c, country_or_region, indicator, industry, partne...
dbl (2): year, total_exports

ℹ Use `spec()` to retrieve the full column specification for this data.
ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
final_total_imports <- read_csv("./processed_01/final_total_imports.csv")
Rows: 2016 Columns: 10
── Column specification ────────────────────────────────────────────────────────
Delimiter: ","
chr (8): country_name, iso3c, country_or_region, indicator, industry, partne...
dbl (2): year, total_imports

ℹ Use `spec()` to retrieve the full column specification for this data.
ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
# joining sets
# excluding LUCF
data_excl_LUCF <- final_ghg_ex_LUCF %>% 
  inner_join(final_energy_imports, by = c("iso3c", "country_name", "year")) %>%   inner_join(final_total_exports, by = c("iso3c", "country_name", "year")) %>% 
  inner_join(final_total_imports, by = c("iso3c", "country_name", "year")) %>% 
  inner_join(final_gdp_ppp, by = c("iso3c", "country_name", "year")) %>% 
  select(!`Country/Region`) %>% 
  select(!country) %>% 
  select(!country_or_region.y) %>% 
  select(!country_or_region.x) %>% 
  select(!unit.x) %>% 
  select(!unit.x.x) %>% 
  select(!unit.y) %>% 
  select(!unit.y.y) 

write_csv(data_excl_LUCF, "./processed_02/data_excl_LUCF.csv")

#including LUCF
data_incl_LUCF <- final_ghg_in_LUCF %>% 
  inner_join(final_energy_imports, by = c("iso3c", "country_name", "year")) %>%   inner_join(final_total_exports, by = c("iso3c", "country_name", "year")) %>% 
  inner_join(final_total_imports, by = c("iso3c", "country_name", "year")) %>% 
  inner_join(final_gdp_ppp, by = c("iso3c", "country_name", "year")) %>% 
  select(!`Country/Region`) %>% 
  select(!country) %>% 
  select(!country_or_region.y) %>% 
  select(!country_or_region.x) %>% 
  select(!unit.x) %>% 
  select(!unit.x.x) %>% 
  select(!unit.y) %>% 
  select(!unit.y.y) 

write_csv(data_incl_LUCF, "./processed_02/data_incl_LUCF.csv")

Aspect 1: Countries that do not differentiate between LUCF inclusive and exclusive

These countries roughly fall into three categories: They are either in a conflict situation (like Libya, Syria), an oil producing desert state (like Saudi Arabia, Kuwait), or a very small Pacific Island Nation (like Kiribati, Tuvalu). States in conflict may simply not have the current capacity to report these values, for oil producing desert states there is probably not much forestry to add but the Small Pacific Island Nations likely are home to important biodiversity and some rain forest. While they all emit less than a million tonnes of CO2e, there emissions might well turn negative if they reported LUCF inclusive data. They could actually present a high risk/high possible return investment if they try to preserve unique forestry but have a high risk of completely vanishing due to rising sea levels. would like to look at their sovereign debt structure, see whether there is data on their LUFC and risk of vanishing

visualization idea: regional map Oceania with referenced islands

biodiversity bonds? context Gabon deal? Can PCAF help with climate mitigation?

# comparison LUCF
# How many countries differentiate between LUCF incl data and LUCF excl data?
LUCF_comparison <- final_ghg_ex_LUCF %>% 
  left_join(final_ghg_in_LUCF, by = c("iso3c", "country_name", "year", "Country/Region", "unit"))

no_difference <- LUCF_comparison %>% 
  filter (GHG_excl_LUCF == GHG_incl_LUCF) %>% 
  filter (year == 2019) %>% 
  mutate (class_ghg = ifelse (GHG_excl_LUCF < 1, "less_than_1_M", 
                              ifelse(1 < GHG_excl_LUCF & GHG_excl_LUCF< 100, "1_to_100 M", "> 100 M")))

  # distinct (country_name)

ggplot(no_difference, aes(x = class_ghg, y = GHG_excl_LUCF, size = GHG_excl_LUCF)) +
  geom_point()

ggplot(no_difference, aes(x = class_ghg, y = GHG_excl_LUCF))+
  geom_boxplot()

# map 
world_map_data <- rnaturalearth::ne_countries(returnclass = "sf")
world_map_data |> 
  left_join(no_difference, by = c("iso_a3" = "iso3c")) |> 
  filter(iso_a3 != "ATA") %>%
  ggplot(aes(fill = GHG_excl_LUCF)) +
  geom_sf() +
  scale_fill_viridis_c(option = "G", labels = scales::percent_format(scale = 1)) +
  theme(legend.position="bottom") +
  labs(
    title = "",
    fill = NULL,
    caption = str_wrap(paste("Source:"))
  )

# visualization ideas: regional map Middle East and regional map Pacific Island Nations showing that the large GHG emitters not reporting any LUCF are mostly located in desert states and the very small emitters are Small Pacific Island Nations which would probably have negative scores if their LUCF was recorded but lack capacity for recording? 
# if incorporated, might lead to climate adaptation investment and protecting these islands???

# more questions: How much LUCF do they have? What sort of Sovereign Debt Bonds do they offer? 

# problem: regional map always excludes Oceania, no matter which order
world_map_data |>
  left_join(no_difference, by = c("iso_a3" = "iso3c")) |> 
  # remove Antarctica. It takes up visual space, and isn't important to this analysis
  filter(iso_a3 != "ATA") %>% 
  #start your ggplot!
  ggplot(aes(fill = GHG_excl_LUCF)) +
  # this makes a map using the sf data.  So easy, right?
  geom_sf() +
  coord_sf(xlim = c(105, -125), ylim = c(-50, 20))

no_difference
# A tibble: 30 × 8
   iso3c country_name         Country/Regi…¹ unit   year GHG_e…² GHG_i…³ class…⁴
   <chr> <chr>                <chr>          <chr> <dbl>   <dbl>   <dbl> <chr>  
 1 SAU   Saudi Arabia         Saudi Arabia   MtCO…  2019   723.    723.  > 100 M
 2 ARE   United Arab Emirates United Arab E… MtCO…  2019   244.    244.  > 100 M
 3 TKM   Turkmenistan         Turkmenistan   MtCO…  2019   157.    157.  > 100 M
 4 KWT   Kuwait               Kuwait         MtCO…  2019   137.    137.  > 100 M
 5 LBY   Libya                Libya          MtCO…  2019   127.    127.  > 100 M
 6 QAT   Qatar                Qatar          MtCO…  2019   115.    115.  > 100 M
 7 BHR   Bahrain              Bahrain        MtCO…  2019    54.4    54.4 1_to_1…
 8 SYR   Syria                Syria          MtCO…  2019    48.5    48.5 1_to_1…
 9 JOR   Jordan               Jordan         MtCO…  2019    36.6    36.6 1_to_1…
10 YEM   Yemen                Yemen          MtCO…  2019    25.3    25.3 1_to_1…
# … with 20 more rows, and abbreviated variable names ¹​`Country/Region`,
#   ²​GHG_excl_LUCF, ³​GHG_incl_LUCF, ⁴​class_ghg

Aspect 2: For which states does the difference (LUCF inlcusive vs exclusive) really matter?

For China, Russia and the US GHG emissions are much less in absolute terms if included their LUCF data (several 100 Million tonnes). But for smaller developing countries the relative importance of accounting for LUCF or not is greater: Fiji’s GHG emissions are reduced by more than 90% if LUCF is included. These states thus tend to be the ones that would profit the most from coherent LUCF reporting.

Similarly, in absolute terms, countries with a lot of forest like Indonesia, Congo (COD), and Brazil have the highest increases in GHG when LUCF is included. For Indonesia, this means almost 1 billion tonnes of CO2e more in emissions. However, the relative change is most dramatic for the Solomon Islands (almost 5000% more GHG emissions, followed by Congo).

LUCF_difference <- LUCF_comparison %>% 
  filter (GHG_excl_LUCF != GHG_incl_LUCF) %>% 
  mutate (LUCF_diff_excl_minus_incl = GHG_excl_LUCF - abs(GHG_incl_LUCF)) %>% 
   mutate(percent_change = LUCF_diff_excl_minus_incl / GHG_excl_LUCF *100)

LUCF_difference_2019 <- LUCF_difference %>% 
  filter(year == 2019)

LUCF_difference_2019_max <- LUCF_difference %>% 
  filter (year == 2019) %>% 
  slice_max(order_by = LUCF_diff_excl_minus_incl, n = 10)

LUCF_difference_2019_max_perc <- LUCF_difference %>% 
  filter (year == 2019) %>% 
  slice_max(order_by = percent_change, n = 10)
  

LUCF_difference_2019_min <- LUCF_difference %>% 
  filter (year == 2019) %>% 
  slice_min(order_by = LUCF_diff_excl_minus_incl, n = 10)

LUCF_difference_2019_min_perc <- LUCF_difference %>% 
  filter (year == 2019) %>% 
  slice_min(order_by = percent_change, n = 10)

ggplot(LUCF_difference_2019, aes(x = LUCF_diff_excl_minus_incl))+
  geom_bar()

ggplot(LUCF_difference_2019, aes(x = GHG_excl_LUCF, y = GHG_incl_LUCF)) +
  geom_point() +
  geom_text_repel(aes(x = GHG_excl_LUCF, y = GHG_incl_LUCF, label = country_name)) +
  geom_abline(alpha = .5, intercept = 0, slope = 1, color = "darkgrey")
Warning: ggrepel: 156 unlabeled data points (too many overlaps). Consider
increasing max.overlaps

LUCF_difference_2019_max_perc
# A tibble: 10 × 9
   iso3c country_name Country/Regi…¹ unit   year GHG_e…² GHG_i…³ LUCF_…⁴ perce…⁵
   <chr> <chr>        <chr>          <chr> <dbl>   <dbl>   <dbl>   <dbl>   <dbl>
 1 FJI   Fiji         Fiji           MtCO…  2019    2.38   -0.16    2.22    93.3
 2 BTN   Bhutan       Bhutan         MtCO…  2019    1.68    0.36    1.32    78.6
 3 GHA   Ghana        Ghana          MtCO…  2019   37.6    12.8    24.9     66.1
 4 BGR   Bulgaria     Bulgaria       MtCO…  2019   51.3    17.5    33.8     65.9
 5 CHL   Chile        Chile          MtCO…  2019  113.     55.3    57.7     51.0
 6 CRI   Costa Rica   Costa Rica     MtCO…  2019   15.8     8.48    7.27    46.2
 7 NOR   Norway       Norway         MtCO…  2019   45.9    27.0    18.9     41.2
 8 SWE   Sweden       Sweden         MtCO…  2019   46.2    29.9    16.3     35.3
 9 BLR   Belarus      Belarus        MtCO…  2019   86.8    65.3    21.5     24.8
10 LVA   Latvia       Latvia         MtCO…  2019   11.7     8.93    2.77    23.7
# … with abbreviated variable names ¹​`Country/Region`, ²​GHG_excl_LUCF,
#   ³​GHG_incl_LUCF, ⁴​LUCF_diff_excl_minus_incl, ⁵​percent_change
LUCF_difference_2019_min_perc
# A tibble: 10 × 9
   iso3c country_name     Country/…¹ unit   year GHG_e…² GHG_i…³ LUCF_…⁴ perce…⁵
   <chr> <chr>            <chr>      <chr> <dbl>   <dbl>   <dbl>   <dbl>   <dbl>
 1 SLB   Solomon Islands  Solomon I… MtCO…  2019    0.94   46.4   -45.4   -4832.
 2 COD   Congo - Kinshasa Democrati… MtCO…  2019   55     680.   -625.    -1136.
 3 LBR   Liberia          Liberia    MtCO…  2019    2.22   15.9   -13.6    -615.
 4 BWA   Botswana         Botswana   MtCO…  2019   11      52.3   -41.3    -376.
 5 BLZ   Belize           Belize     MtCO…  2019    1.55    6.85   -5.3    -342.
 6 ZWE   Zimbabwe         Zimbabwe   MtCO…  2019   30.5   118.    -87.4    -286.
 7 GUY   Guyana           Guyana     MtCO…  2019    5.68   19.8   -14.1    -249.
 8 SUR   Suriname         Suriname   MtCO…  2019    4.46   13.8    -9.37   -210.
 9 MOZ   Mozambique       Mozambique MtCO…  2019   35.4   107.    -71.3    -202.
10 PNG   Papua New Guinea Papua New… MtCO…  2019   22.4    63.5   -41.1    -183.
# … with abbreviated variable names ¹​`Country/Region`, ²​GHG_excl_LUCF,
#   ³​GHG_incl_LUCF, ⁴​LUCF_diff_excl_minus_incl, ⁵​percent_change
LUCF_difference_2019_max
# A tibble: 10 × 9
   iso3c country_name  Country/Reg…¹ unit   year GHG_e…² GHG_i…³ LUCF_…⁴ perce…⁵
   <chr> <chr>         <chr>         <chr> <dbl>   <dbl>   <dbl>   <dbl>   <dbl>
 1 CHN   China         China         MtCO…  2019 12705.  12055.    650.    5.11 
 2 RUS   Russia        Russia        MtCO…  2019  2477.   1925.    552.   22.3  
 3 USA   United States United States MtCO…  2019  6001.   5771     230.    3.84 
 4 FRA   France        France        MtCO…  2019   414.    352.     61.9  15.0  
 5 CHL   Chile         Chile         MtCO…  2019   113.     55.3    57.7  51.0  
 6 KOR   South Korea   South Korea   MtCO…  2019   698.    653.     45.8   6.56 
 7 BGR   Bulgaria      Bulgaria      MtCO…  2019    51.3    17.5    33.8  65.9  
 8 POL   Poland        Poland        MtCO…  2019   353.    320.     32.9   9.32 
 9 JPN   Japan         Japan         MtCO…  2019  1167.   1134.     32.1   2.75 
10 IND   India         India         MtCO…  2019  3395.   3364.     31.3   0.921
# … with abbreviated variable names ¹​`Country/Region`, ²​GHG_excl_LUCF,
#   ³​GHG_incl_LUCF, ⁴​LUCF_diff_excl_minus_incl, ⁵​percent_change
LUCF_difference_2019_min
# A tibble: 10 × 9
   iso3c country_name     Country/…¹ unit   year GHG_e…² GHG_i…³ LUCF_…⁴ perce…⁵
   <chr> <chr>            <chr>      <chr> <dbl>   <dbl>   <dbl>   <dbl>   <dbl>
 1 IDN   Indonesia        Indonesia  MtCO…  2019  1002.    1960.  -957.    -95.5
 2 COD   Congo - Kinshasa Democrati… MtCO…  2019    55      680.  -625.  -1136. 
 3 BRA   Brazil           Brazil     MtCO…  2019  1057.    1452.  -394.    -37.3
 4 MMR   Myanmar (Burma)  Myanmar    MtCO…  2019   133.     243.  -110.    -82.3
 5 PER   Peru             Peru       MtCO…  2019   101.     191.   -89.9   -89.3
 6 ZWE   Zimbabwe         Zimbabwe   MtCO…  2019    30.5    118.   -87.4  -286. 
 7 COL   Colombia         Colombia   MtCO…  2019   187.     271.   -83.2   -44.4
 8 MYS   Malaysia         Malaysia   MtCO…  2019   313.     396.   -83.1   -26.5
 9 BOL   Bolivia          Bolivia    MtCO…  2019    60.8    139.   -77.9  -128. 
10 MOZ   Mozambique       Mozambique MtCO…  2019    35.4    107.   -71.3  -202. 
# … with abbreviated variable names ¹​`Country/Region`, ²​GHG_excl_LUCF,
#   ³​GHG_incl_LUCF, ⁴​LUCF_diff_excl_minus_incl, ⁵​percent_change
ggplot(LUCF_difference, aes(x = LUCF_diff_excl_minus_incl)) +
  geom_boxplot()

Aspect 3: Scope Emissions

# goal: datasets with scope 1,2,3 emissions for country-years, possibly LUFC inclusive and exclusive

# scope 1 emissions are the Climate Watch GHG emissions (LUCF excl.)
# scope 2 emissions are the D35 OECD data emissions (energy imports)
# scope 3 emissions are total imports - energy imports emissions, both OECD

scope_emissions <- data_excl_LUCF %>% 
  left_join(final_ghg_in_LUCF, by = c("iso3c", "country_name", "year")) %>% 
  rename(scope_1_excl = GHG_excl_LUCF, 
         scope_1_incl = GHG_incl_LUCF,
         scope_2 = energy_imports) %>% 
   mutate(scope_3 = total_imports - scope_2) %>% 
   select(iso3c, country_name, year, scope_1_excl, scope_1_incl, scope_2, scope_3, GDP_PPP)   %>% 
   group_by(country_name, year) %>% 
   mutate(total_scopes_excl = scope_1_excl + scope_2 + scope_3, 
        total_scopes_incl = scope_1_incl + scope_2 + scope_3) 
  

write_csv(scope_emissions, "./processed_02/scope_emissions.csv")

Exploring G7 dynamics and then for whom the different scope emissions increased the most (for scope 3 and scope 2 emissions: China, United States, India; China India and Saudi Arabia for scope 1 excluding and including LUCF)

g7_emissions <- scope_emissions %>% 
  filter(country_name %in% c("United States", "United Kingdom", "Canada", "Japan", "Germany", "France", "Italy"))

ggplot(g7_emissions, aes(x = year, y = total_scopes_excl)) +
  geom_point(aes(x = year, y = total_scopes_excl)) +
  geom_line(aes(x = year, y = scope_1_excl, color = "red")) +
  geom_line(aes(x = year, y = scope_2, color = "blue")) +
  geom_line(aes(x = year, y = scope_3, color = "green")) +
  facet_wrap(~ country_name)

# why does the legend associate blue with red?

# to explore: trend in scope 2 and 3 emissions? -> regression? nesting like in datacamp course
library(broom)
Warning: Paket 'broom' wurde unter R Version 4.2.2 erstellt
scope_emissions %>% 
  nest(-country_name) %>% 
  mutate(models = map(data, ~ lm(scope_2 ~ year, .))) %>% 
  mutate(tidied = map(models, tidy)) %>% 
  unnest(tidied)
Warning: Supplying `...` without names was deprecated in tidyr 1.0.0.
ℹ Please specify a name for each selection.
ℹ Did you want `data = -country_name`?
# A tibble: 128 × 8
# Groups:   country_name [64]
   country_name  data       models term        estimate std.e…¹ stati…²  p.value
   <chr>         <list>     <list> <chr>          <dbl>   <dbl>   <dbl>    <dbl>
 1 China         <gropd_df> <lm>   (Intercept) -1.78e+4 9.42e+2  -18.9  4.15e-15
 2 China         <gropd_df> <lm>   year         8.94e+0 4.69e-1   19.1  3.66e-15
 3 United States <gropd_df> <lm>   (Intercept) -1.17e+4 2.93e+3   -3.99 6.14e- 4
 4 United States <gropd_df> <lm>   year         5.98e+0 1.46e+0    4.10 4.76e- 4
 5 India         <gropd_df> <lm>   (Intercept) -6.93e+3 4.24e+2  -16.3  8.81e-14
 6 India         <gropd_df> <lm>   year         3.48e+0 2.12e-1   16.4  7.73e-14
 7 Russia        <gropd_df> <lm>   (Intercept) -3.26e+3 5.91e+2   -5.52 1.50e- 5
 8 Russia        <gropd_df> <lm>   year         1.64e+0 2.95e-1    5.58 1.31e- 5
 9 Japan         <gropd_df> <lm>   (Intercept) -1.09e+3 8.69e+2   -1.25 2.24e- 1
10 Japan         <gropd_df> <lm>   year         6.02e-1 4.33e-1    1.39 1.79e- 1
# … with 118 more rows, and abbreviated variable names ¹​std.error, ²​statistic
scope_2_coefficients <- scope_emissions %>% 
  nest(-country_name) %>% 
  mutate(models = map(data, ~ lm(scope_2 ~ year, .))) %>% 
  mutate(tidied = map(models, tidy)) %>% 
  unnest(tidied) %>% 
  filter(term == "year") %>% 
  filter(p.adjust(p.value) < .05)
Warning: Supplying `...` without names was deprecated in tidyr 1.0.0.
ℹ Please specify a name for each selection.
ℹ Did you want `data = -country_name`?
scope_2_coefficients %>% 
  arrange(desc(estimate))
# A tibble: 44 × 8
# Groups:   country_name [44]
   country_name  data       models term  estimate std.error statistic  p.value
   <chr>         <list>     <list> <chr>    <dbl>     <dbl>     <dbl>    <dbl>
 1 China         <gropd_df> <lm>   year      8.94     0.469     19.1  3.66e-15
 2 United States <gropd_df> <lm>   year      5.98     1.46       4.10 4.76e- 4
 3 India         <gropd_df> <lm>   year      3.48     0.212     16.4  7.73e-14
 4 Russia        <gropd_df> <lm>   year      1.64     0.295      5.58 1.31e- 5
 5 South Korea   <gropd_df> <lm>   year      1.50     0.223      6.74 8.96e- 7
 6 Australia     <gropd_df> <lm>   year      1.46     0.138     10.6  4.29e-10
 7 Saudi Arabia  <gropd_df> <lm>   year      1.32     0.123     10.7  3.24e-10
 8 Brazil        <gropd_df> <lm>   year      1.31     0.206      6.34 2.23e- 6
 9 Indonesia     <gropd_df> <lm>   year      1.27     0.114     11.1  1.81e-10
10 Mexico        <gropd_df> <lm>   year      1.09     0.143      7.59 1.40e- 7
# … with 34 more rows
scope_emissions %>% 
  nest(-country_name) %>% 
  mutate(models = map(data, ~ lm(scope_3 ~ year, .))) %>% 
  mutate(tidied = map(models, tidy)) %>% 
  unnest(tidied)
Warning: Supplying `...` without names was deprecated in tidyr 1.0.0.
ℹ Please specify a name for each selection.
ℹ Did you want `data = -country_name`?
# A tibble: 128 × 8
# Groups:   country_name [64]
   country_name  data       models term        estimate std.e…¹ stati…²  p.value
   <chr>         <list>     <list> <chr>          <dbl>   <dbl>   <dbl>    <dbl>
 1 China         <gropd_df> <lm>   (Intercept)  -4.86e4 2.43e+3  -20.0  1.32e-15
 2 China         <gropd_df> <lm>   year          2.44e1 1.21e+0   20.1  1.17e-15
 3 United States <gropd_df> <lm>   (Intercept)  -1.97e4 6.28e+3   -3.14 4.81e- 3
 4 United States <gropd_df> <lm>   year          1.02e1 3.13e+0    3.26 3.57e- 3
 5 India         <gropd_df> <lm>   (Intercept)  -1.98e4 1.12e+3  -17.7  1.74e-14
 6 India         <gropd_df> <lm>   year          9.93e0 5.58e-1   17.8  1.52e-14
 7 Russia        <gropd_df> <lm>   (Intercept)  -7.72e3 1.36e+3   -5.66 1.09e- 5
 8 Russia        <gropd_df> <lm>   year          3.89e0 6.80e-1    5.72 9.47e- 6
 9 Japan         <gropd_df> <lm>   (Intercept)   4.79e3 2.06e+3    2.33 2.94e- 2
10 Japan         <gropd_df> <lm>   year         -2.24e0 1.03e+0   -2.18 3.98e- 2
# … with 118 more rows, and abbreviated variable names ¹​std.error, ²​statistic
scope_3_coefficients <- scope_emissions %>% 
  nest(-country_name) %>% 
  mutate(models = map(data, ~ lm(scope_3 ~ year, .))) %>% 
  mutate(tidied = map(models, tidy)) %>% 
  unnest(tidied) %>% 
  filter(term == "year") %>% 
  filter(p.adjust(p.value) < .05)
Warning: Supplying `...` without names was deprecated in tidyr 1.0.0.
ℹ Please specify a name for each selection.
ℹ Did you want `data = -country_name`?
scope_3_coefficients %>% 
  arrange(desc(estimate))
# A tibble: 53 × 8
# Groups:   country_name [53]
   country_name  data       models term  estimate std.error statistic  p.value
   <chr>         <list>     <list> <chr>    <dbl>     <dbl>     <dbl>    <dbl>
 1 China         <gropd_df> <lm>   year     24.4      1.21      20.1  1.17e-15
 2 United States <gropd_df> <lm>   year     10.2      3.13       3.26 3.57e- 3
 3 India         <gropd_df> <lm>   year      9.93     0.558     17.8  1.52e-14
 4 Saudi Arabia  <gropd_df> <lm>   year      4.13     0.325     12.7  1.37e-11
 5 Russia        <gropd_df> <lm>   year      3.89     0.680      5.72 9.47e- 6
 6 Indonesia     <gropd_df> <lm>   year      2.88     0.294      9.78 1.80e- 9
 7 Brazil        <gropd_df> <lm>   year      2.79     0.493      5.65 1.10e- 5
 8 South Korea   <gropd_df> <lm>   year      2.73     0.522      5.23 3.01e- 5
 9 Australia     <gropd_df> <lm>   year      2.71     0.323      8.39 2.68e- 8
10 Turkey        <gropd_df> <lm>   year      2.44     0.262      9.31 4.35e- 9
# … with 43 more rows
scope_emissions %>% 
  nest(-country_name) %>% 
  mutate(models = map(data, ~ lm(scope_1_excl ~ year, .))) %>% 
  mutate(tidied = map(models, tidy)) %>% 
  unnest(tidied)
Warning: Supplying `...` without names was deprecated in tidyr 1.0.0.
ℹ Please specify a name for each selection.
ℹ Did you want `data = -country_name`?
# A tibble: 128 × 8
# Groups:   country_name [64]
   country_name  data       models term        estimate std.e…¹ stati…²  p.value
   <chr>         <list>     <list> <chr>          <dbl>   <dbl>   <dbl>    <dbl>
 1 China         <gropd_df> <lm>   (Intercept) -8.67e+5  4.10e4 -21.2   4.09e-16
 2 China         <gropd_df> <lm>   year         4.36e+2  2.04e1  21.4   3.36e-16
 3 United States <gropd_df> <lm>   (Intercept)  5.90e+4  1.37e4   4.31  2.81e- 4
 4 United States <gropd_df> <lm>   year        -2.62e+1  6.81e0  -3.84  8.83e- 4
 5 India         <gropd_df> <lm>   (Intercept) -1.74e+5  6.94e3 -25.0   1.19e-17
 6 India         <gropd_df> <lm>   year         8.76e+1  3.46e0  25.3   9.03e-18
 7 Russia        <gropd_df> <lm>   (Intercept) -1.54e+4  3.64e3  -4.24  3.37e- 4
 8 Russia        <gropd_df> <lm>   year         8.83e+0  1.82e0   4.86  7.43e- 5
 9 Japan         <gropd_df> <lm>   (Intercept)  2.00e+3  2.29e3   0.874 3.92e- 1
10 Japan         <gropd_df> <lm>   year        -3.65e-1  1.14e0  -0.319 7.53e- 1
# … with 118 more rows, and abbreviated variable names ¹​std.error, ²​statistic
scope_1_excl_coefficients <- scope_emissions %>% 
  nest(-country_name) %>% 
  mutate(models = map(data, ~ lm(scope_1_excl ~ year, .))) %>% 
  mutate(tidied = map(models, tidy)) %>% 
  unnest(tidied) %>% 
  filter(term == "year") %>% 
  filter(p.adjust(p.value) < .05)
Warning: Supplying `...` without names was deprecated in tidyr 1.0.0.
ℹ Please specify a name for each selection.
ℹ Did you want `data = -country_name`?
scope_1_excl_coefficients %>% 
  arrange(desc(estimate))
# A tibble: 53 × 8
# Groups:   country_name [53]
   country_name data       models term  estimate std.error statistic  p.value
   <chr>        <list>     <list> <chr>    <dbl>     <dbl>     <dbl>    <dbl>
 1 China        <gropd_df> <lm>   year    436.      20.4        21.4 3.36e-16
 2 India        <gropd_df> <lm>   year     87.6      3.46       25.3 9.03e-18
 3 Saudi Arabia <gropd_df> <lm>   year     22.0      0.870      25.3 9.37e-18
 4 Brazil       <gropd_df> <lm>   year     19.7      0.933      21.1 4.21e-16
 5 Indonesia    <gropd_df> <lm>   year     13.2      0.634      20.9 5.44e-16
 6 South Korea  <gropd_df> <lm>   year     13.0      0.598      21.7 2.49e-16
 7 Vietnam      <gropd_df> <lm>   year     11.9      0.458      26.1 4.86e-18
 8 Turkey       <gropd_df> <lm>   year     11.3      0.541      21.0 4.93e-16
 9 Mexico       <gropd_df> <lm>   year      9.86     0.651      15.2 4.01e-13
10 South Africa <gropd_df> <lm>   year      9.69     0.650      14.9 5.58e-13
# … with 43 more rows
scope_emissions %>% 
  nest(-country_name) %>% 
  mutate(models = map(data, ~ lm(scope_1_incl ~ year, .))) %>% 
  mutate(tidied = map(models, tidy)) %>% 
  unnest(tidied)
Warning: Supplying `...` without names was deprecated in tidyr 1.0.0.
ℹ Please specify a name for each selection.
ℹ Did you want `data = -country_name`?
# A tibble: 128 × 8
# Groups:   country_name [64]
   country_name  data       models term        estimate std.e…¹ stati…²  p.value
   <chr>         <list>     <list> <chr>          <dbl>   <dbl>   <dbl>    <dbl>
 1 China         <gropd_df> <lm>   (Intercept)  -8.31e5  3.87e4 -21.4   3.11e-16
 2 China         <gropd_df> <lm>   year          4.18e2  1.93e1  21.6   2.57e-16
 3 United States <gropd_df> <lm>   (Intercept)   4.87e4  1.35e4   3.61  1.56e- 3
 4 United States <gropd_df> <lm>   year         -2.13e1  6.73e0  -3.16  4.52e- 3
 5 India         <gropd_df> <lm>   (Intercept)  -1.89e5  3.76e3 -50.4   3.19e-24
 6 India         <gropd_df> <lm>   year          9.54e1  1.87e0  51.0   2.48e-24
 7 Russia        <gropd_df> <lm>   (Intercept)   5.50e3  8.92e3   0.616 5.44e- 1
 8 Russia        <gropd_df> <lm>   year         -1.92e0  4.45e0  -0.432 6.70e- 1
 9 Japan         <gropd_df> <lm>   (Intercept)  -2.32e3  2.79e3  -0.831 4.15e- 1
10 Japan         <gropd_df> <lm>   year          1.75e0  1.39e0   1.26  2.21e- 1
# … with 118 more rows, and abbreviated variable names ¹​std.error, ²​statistic
scope_1_incl_coefficients <- scope_emissions %>% 
  nest(-country_name) %>% 
  mutate(models = map(data, ~ lm(scope_1_incl ~ year, .))) %>% 
  mutate(tidied = map(models, tidy)) %>% 
  unnest(tidied) %>% 
  filter(term == "year") %>% 
  filter(p.adjust(p.value) < .05)
Warning: Supplying `...` without names was deprecated in tidyr 1.0.0.
ℹ Please specify a name for each selection.
ℹ Did you want `data = -country_name`?
scope_1_incl_coefficients %>% 
  arrange(desc(estimate))
# A tibble: 49 × 8
# Groups:   country_name [49]
   country_name data       models term  estimate std.error statistic  p.value
   <chr>        <list>     <list> <chr>    <dbl>     <dbl>     <dbl>    <dbl>
 1 China        <gropd_df> <lm>   year    418.      19.3       21.6  2.57e-16
 2 India        <gropd_df> <lm>   year     95.4      1.87      51.0  2.48e-24
 3 Saudi Arabia <gropd_df> <lm>   year     22.0      0.870     25.3  9.37e-18
 4 Vietnam      <gropd_df> <lm>   year     14.2      0.853     16.6  6.09e-14
 5 South Korea  <gropd_df> <lm>   year     12.8      0.637     20.1  1.21e-15
 6 Turkey       <gropd_df> <lm>   year     10.0      0.861     11.7  6.81e-11
 7 Mexico       <gropd_df> <lm>   year     10.0      1.11       9.01 7.80e- 9
 8 South Africa <gropd_df> <lm>   year      9.64     0.644     15.0  5.18e-13
 9 Thailand     <gropd_df> <lm>   year      8.18     0.725     11.3  1.28e-10
10 Kazakhstan   <gropd_df> <lm>   year      5.68     0.942      6.03 4.57e- 6
# … with 39 more rows