Our setup code:
# install.packages('ggpubr','ggforce','ggalt')
library(tidyverse)
## -- Attaching packages --------------------------------------- tidyverse 1.3.0 --
## v ggplot2 3.3.3 v purrr 0.3.4
## v tibble 3.1.0 v dplyr 1.0.5
## v tidyr 1.1.3 v stringr 1.4.0
## v readr 1.4.0 v forcats 0.5.1
## -- Conflicts ------------------------------------------ tidyverse_conflicts() --
## x dplyr::filter() masks stats::filter()
## x 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'))
##
## -- Column specification --------------------------------------------------------
## cols(
## Date = col_date(format = ""),
## Google_Return = col_double(),
## SP500_Return = col_double()
## )
spend <- read_csv('https://vincentarelbundock.github.io/Rdatasets/csv/stevedata/gss_spending.csv')
## Warning: Missing column names filled in: 'X1' [1]
##
## -- Column specification --------------------------------------------------------
## cols(
## .default = col_double()
## )
## i Use `spec()` for the full column specifications.
#https://vincentarelbundock.github.io/Rdatasets/doc/stevedata/gss_spending.html
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?
## Warning: Missing column names filled in: 'X1' [1]
##
## -- Column specification --------------------------------------------------------
## cols(
## .default = col_double()
## )
## i Use `spec()` for the full column specifications.
| 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'))
no_ba <- spend %>%
slice(1:4) %>%
rename(no_ba_value = value)
ba <- spend %>%
slice(5:8) %>%
rename(ba_value = value)
df <- no_ba %>%
left_join(ba, by = 'name')