Our setup code:

# install.packages('ggpubr','ggforce','ggalt')

library(tidyverse)
## ── Attaching packages ─────────────────────────────────────── tidyverse 1.3.1 ──
## ✔ ggplot2 3.3.6     ✔ purrr   0.3.4
## ✔ tibble  3.1.7     ✔ dplyr   1.0.9
## ✔ tidyr   1.2.0     ✔ stringr 1.4.0
## ✔ readr   2.1.2     ✔ forcats 0.5.1
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag()    masks stats::lag()
library(ggpubr)
library(ggforce)
library(ggalt)
## Registered S3 methods overwritten by 'ggalt':
##   method                  from   
##   grid.draw.absoluteGrob  ggplot2
##   grobHeight.absoluteGrob ggplot2
##   grobWidth.absoluteGrob  ggplot2
##   grobX.absoluteGrob      ggplot2
##   grobY.absoluteGrob      ggplot2
google <- read_csv('https://github.com/NickCH-K/causalbook/raw/main/EventStudies/google_stock_data.csv') %>%
  pivot_longer(cols = c('Google_Return','SP500_Return'))
## Rows: 84 Columns: 3
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## dbl  (2): Google_Return, SP500_Return
## date (1): Date
## 
## ℹ 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.
spend <- read_csv('https://vincentarelbundock.github.io/Rdatasets/csv/stevedata/gss_spending.csv')
## New names:
## Rows: 2348 Columns: 34
## ── Column specification
## ──────────────────────────────────────────────────────── Delimiter: "," dbl
## (34): ...1, year, id, age, sex, educ, degree, race, rincom16, partyid, p...
## ℹ 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.
## • `` -> `...1`
#https://vincentarelbundock.github.io/Rdatasets/doc/stevedata/gss_spending.html

Google’s Alphabet Announcement

On August 10, 2015, Google announced that they were reorganizing the company to fit underneath Alphabet, a new umbrella company. The GOOG stock would now be stock in Alphabet. Did this announcement affect the Google stock price?

Life by Education

spend <- read_csv('https://vincentarelbundock.github.io/Rdatasets/csv/stevedata/gss_spending.csv')
## New names:
## Rows: 2348 Columns: 34
## ── Column specification
## ──────────────────────────────────────────────────────── Delimiter: "," dbl
## (34): ...1, year, id, age, sex, educ, degree, race, rincom16, partyid, p...
## ℹ 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.
## • `` -> `...1`
#https://vincentarelbundock.github.io/Rdatasets/doc/stevedata/gss_spending.html

spend <- spend %>%
  dplyr::filter(!is.na(degree)) %>%
  transmute(BA = degree >= 3,
         income_above_median = rincom16 >= median(rincom16, na.rm = TRUE),
         conservative = polviews >= 5,
         news_reader = news %in% 1:2,
         full_time = wrkstat == 1) %>%
  group_by(BA) %>%
  summarize(across(.fns = function(x) mean(x, na.rm = TRUE)))

vtable::vtable(spend, labels = c('Has Bachelor or Grad Degree',
                                 'Income above median',
                                 '5-7 on political views scale',
                                 'Reads news at least a few times a week or daily',
                                 'Works full-time'))
spend
Name Class Label Values
BA logical Has Bachelor or Grad Degree TRUE FALSE
income_above_median numeric Income above median Num: 0.413 to 0.761
conservative numeric 5-7 on political views scale Num: 0.315 to 0.333
news_reader numeric Reads news at least a few times a week or daily Num: 0.164 to 0.305
full_time numeric Works full-time Num: 0.439 to 0.586
BA income_above_median conservative news_reader full_time
FALSE 0.4126984 0.3333333 0.1644254 0.4388005
TRUE 0.7609148 0.3147353 0.3047753 0.5856742
spend <- spend %>%
  pivot_longer(cols = c('income_above_median','conservative','news_reader','full_time'))
 spend <- spend %>%
  pivot_wider(id_cols = name, names_from = BA) %>%
   rename(ba_value = `TRUE`, no_ba_value = `FALSE`)