# Loading in all datasets used for replication

# Dataset downloaded from Google Trends 2024
google_trends_2024 <- read.csv("data/from_google_trends_2024/google_trend_search.csv", header = FALSE, col.names = c("ym", "report", "crime", "welfare"))

google_trends_2024 <- google_trends_2024[-c(1, 2), ] %>%  mutate(ym = ym(ym), report = as.numeric(report), crime = as.numeric(crime), welfare = as.numeric(welfare)) %>% filter(ym < ym("2020-01"))

google_trends_2024 <- google_trends_2024 %>% mutate( president = case_when(
  ym < ym("2009-01") ~ "Bush" ,
  ym < ym("2017-01") ~ "Obama" ,
  .default = "Trump"))


# Original dataset used in the paper
original_crime <- read.csv("data/from_replication_files/google_trends_crime.csv", col.names = c("year", "month", "crime")) %>%
  unite(date,c(year, month), sep = "-")
original_report <- read.csv("data/from_replication_files/google_trends_report.csv" , col.names = c("year", "month", "report")) %>%
unite(date,c(year, month), sep = "-")
original_welfare <- read.csv("data/from_replication_files/google_trends_welfare.csv", col.names = c("year", "month", "welfare")) %>%
                         unite(date,c(year, month), sep = "-")

trends_original <- left_join(original_crime, original_report, by = join_by(date)) %>%
  left_join(original_welfare, by = join_by(date)) %>% 
  mutate(date = ym(date))

trends_original <- trends_original %>% mutate( president = case_when(
  date < ym("2009-01") ~ "Bush" ,
  date < ym("2017-01") ~ "Obama" ,
  .default = "Trump"))


# Import the topic model
library(stm)
load("data/topic_model_lite.RData")

# Import Daily Google Trends dataset
daily_report <- read.csv(("data/from_replication_files/gt_report_daily.csv")) %>% 
  mutate(ymd = ymd(date)) %>% 
  select(ymd, search, search_adj)

Figure 4 Replication: Google Trend data split by Presidential Term

Replication of Figure 4 using the Original Dataset

#plotting reporting
trends_original  %>%  
  ggplot(aes(x = date, y = report, color =  president), group_by = president) +
  geom_point() + geom_smooth(method = "lm", se = FALSE) +
  ylab("Google Trends")  + 
  xlab("") +
  ggtitle("Reporting Trends")

#plotting crime
trends_original  %>% 
  ggplot(aes(x = date, y = crime, color =  president), group_by = president) +
  geom_point() + geom_smooth(method = "lm", se = FALSE) +
  ylab("Google Trends") + xlab("") +
  scale_y_continuous(limits = c(0, 100)) +
  ggtitle("Crime Trends")

#plotting welfare
trends_original  %>% 
  ggplot(aes(x = date, y = welfare, color =  president), group_by = president) +
  geom_point() + geom_smooth(method = "lm", se = FALSE) +
  ylab("Google Trends") + xlab("") + scale_y_continuous(limits = c(0, 100)) +
  ggtitle("Welfare Trends")

Figure 4 Report:

When replicating Figure 4 using the orignal dataset, we got near identical results. However, when replicating with the 2024 Google Trends data, we noticed a lot of zero values that weren’t present in the original dataset for the paper. This resulted in slightly skewed regression lines for the Bush administration. We suspect that maybe Google Trends dropped the data for those specific days.

Figure 2-3 Replication: News Coverage data by News Channel, split by Trump’s Campaign Period

Replication of Figure 2 using the Original Topic Model

document_topics %>% 
  mutate( ym = ym(format(ymd(date), "%Y-%m"))) %>%
  group_by(channel, ym, post_election, post_trump, time ) %>% 
  summarize( total_duration = sum(duration)) %>%
  ggplot(aes(x = ym, y = total_duration, color = channel, group = interaction(channel, time))) +
  geom_point() + 
  geom_smooth( se = F) + 
  geom_vline(xintercept = c(ym("2015-06"), ym("2017-01")), linetype = "dashed") +
  ggtitle("Figure 2") +
  ylab("Num Monthly Immigration Segs") +
  xlab("")

Replication of Figure 3 using the Original Topic Model

document_topics %>% 
  select(Topic1, Topic3, channel, date, duration, post_election, post_trump, time) %>%  
  mutate(Topic  = Topic1 +  Topic3)%>% 
  mutate( ym = ym(format(ymd(date), "%Y-%m"))) %>%
  group_by(channel, ym, post_election, post_trump, time ) %>% 
  summarize( total_duration = sum(Topic)) %>%
  ggplot(aes(x = ym, y = total_duration, color = channel, group = interaction(channel, time))) +
  geom_point() + 
  geom_smooth( se = F) + 
  geom_vline(xintercept = c(ym("2015-06"), ym("2017-01")), linetype = "dashed") +
  ylab("Immigr + Crime \n News Coverage") +
  xlab("") +
  ggtitle("Figure 3")

document_topics %>% 
  select(Topic13, channel, date, duration, post_election, post_trump, time) %>%
  mutate( ym = ym(format(ymd(date), "%Y-%m"))) %>%
  group_by(channel, ym, post_election, post_trump, time ) %>% 
  summarize( total_duration = sum(Topic13)) %>%
  ggplot(aes(x = ym, y = total_duration, color = channel, group = interaction(channel, time))) +
  geom_point() + 
  geom_smooth( se = F) + 
  geom_vline(xintercept = c(ym("2015-06"), ym("2017-01")), linetype = "dashed")+
  ylab("Immigr + Welfare \n News Coverage") +
  xlab("") +
  ggtitle("Figure 3")

Figure 2-3 Report:

Using the topic model data used by the research paper, we were able to make near identical graphs.

Extension:

Question 1:

The paper uses “Trump’s Presidential Term” as an indicator for “government support for deportation.” The analysis from this decision supports Hypothesis 1 of this paper: “People will have more interest in reporting immigrants when they believe the government supports deportation.” However, perhaps a better metric to use would be the passage of specific immigration based policies. By identifying positive and negative key immigration policies passed and the exact day of passage, we can explore the reaction of the “reporting”, “welfare”, and “crime” search data.

Question 2:

Investigating further for Hypothesis 1: “H1: People will have more interest in reporting immigrants when they believe the government supports deportation.” Table 5 supported H1 by stating that “Regarding Trump’s campaign cues, the regressions did not show a significant positive effect of Trump’s immigration coverage on anti-immigrant searches during the campaign. However, the cues about Trump’s presidential immigration policy positively and significantly affected reporting searches. Both of these findings provide further support for Hypothesis 1.”

But we thought that not just because of government supports, there is an increase in interest in reporting immigrants, but also it is because there is more news activity during Trump presidential. Therefore we thought it is worth to explore further by adjusting report search by the total number of news streamed. (#time interval we chose “monthly adjustment”)

Replication of Table 5 using Original Topic Model and Original Dataset

#Importing Trump segments and monthly adjustment
trump_segs <- document_topics %>% 
  select(date, trump) %>%
  mutate( ymd = ymd(format(ymd(date), "%Y-%m-%d"))) %>%
  group_by(ymd) %>% 
  summarize( trump = sum(trump), count = n()) %>% mutate(ym = format(ymd, "%Y-%m")) %>% group_by(ym) %>%  mutate( max = cumsum(count), max = max(max))
table_5 <- inner_join(table_4, trump_segs) %>% mutate(news_adjust = search_adj / max)
## [1] "Replicating Table 5"
## 
## Call:
## lm(formula = search_adj ~ segment + trump + Trump_admin + Trump_admin * 
##     trump + crime + welfare + ymd + weekday + month, data = table_5)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -49.145 -11.762  -2.061   8.958 139.752 
## 
## Coefficients:
##                         Estimate Std. Error t value Pr(>|t|)    
## (Intercept)           91.1603546 24.8416056   3.670 0.000249 ***
## segment                0.0008597  0.0322341   0.027 0.978725    
## trump                 -0.0286036  0.0555613  -0.515 0.606742    
## Trump_adminTRUE       15.9952046  1.8499136   8.646  < 2e-16 ***
## crime                  0.8680465  0.2674561   3.246 0.001191 ** 
## welfare                2.0377912  0.6873738   2.965 0.003066 ** 
## ymd                   -0.0033704  0.0014955  -2.254 0.024324 *  
## weekdayMonday          0.5685343  1.5607108   0.364 0.715688    
## weekdaySaturday       -3.9442121  1.5625361  -2.524 0.011672 *  
## weekdaySunday         -5.4298245  1.5569654  -3.487 0.000498 ***
## weekdayThursday        2.6148097  1.5561924   1.680 0.093062 .  
## weekdayTuesday        -1.3198180  1.5547484  -0.849 0.396041    
## weekdayWednesday       3.0430072  1.5535500   1.959 0.050281 .  
## monthAugust            1.4808775  2.0179881   0.734 0.463133    
## monthDecember          2.1738161  2.1136517   1.028 0.303855    
## monthFebruary         11.2646437  2.0277062   5.555 3.14e-08 ***
## monthJanuary          10.4765642  2.0037581   5.228 1.89e-07 ***
## monthJuly              1.9820603  2.0088748   0.987 0.323932    
## monthJune              3.9985449  2.0168297   1.983 0.047550 *  
## monthMarch             3.2650911  2.0011768   1.632 0.102924    
## monthMay               0.6076047  1.9984211   0.304 0.761127    
## monthNovember          2.1050647  2.1148171   0.995 0.319667    
## monthOctober          -1.1940365  2.0935285  -0.570 0.568507    
## monthSeptember         0.2375459  2.0712677   0.115 0.908705    
## trump:Trump_adminTRUE  0.2655726  0.0618434   4.294 1.84e-05 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 18.74 on 2005 degrees of freedom
## Multiple R-squared:  0.2659, Adjusted R-squared:  0.2571 
## F-statistic: 30.26 on 24 and 2005 DF,  p-value: < 2.2e-16
## [1] "Adjusted Report Data by total number of segmens in a month"
## 
## Call:
## lm(formula = news_adjust ~ segment + trump + Trump_admin + Trump_admin * 
##     trump + crime + welfare + ymd + weekday + month, data = table_5)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -0.13917 -0.03848 -0.00955  0.02350  0.36383 
## 
## Coefficients:
##                         Estimate Std. Error t value Pr(>|t|)    
## (Intercept)            1.495e+00  7.882e-02  18.962  < 2e-16 ***
## segment               -5.257e-04  1.023e-04  -5.140 3.01e-07 ***
## trump                  2.116e-04  1.763e-04   1.201  0.23007    
## Trump_adminTRUE        5.544e-02  5.870e-03   9.445  < 2e-16 ***
## crime                  4.918e-04  8.486e-04   0.580  0.56226    
## welfare                2.773e-03  2.181e-03   1.271  0.20379    
## ymd                   -8.287e-05  4.745e-06 -17.464  < 2e-16 ***
## weekdayMonday          2.784e-03  4.952e-03   0.562  0.57406    
## weekdaySaturday       -8.386e-03  4.958e-03  -1.692  0.09088 .  
## weekdaySunday         -9.050e-03  4.940e-03  -1.832  0.06710 .  
## weekdayThursday        5.514e-03  4.938e-03   1.117  0.26425    
## weekdayTuesday         2.611e-03  4.933e-03   0.529  0.59664    
## weekdayWednesday       8.408e-03  4.929e-03   1.706  0.08823 .  
## monthAugust           -3.671e-02  6.403e-03  -5.733 1.14e-08 ***
## monthDecember         -2.001e-02  6.706e-03  -2.983  0.00289 ** 
## monthFebruary         -3.008e-02  6.434e-03  -4.676 3.12e-06 ***
## monthJanuary          -2.981e-02  6.358e-03  -4.688 2.94e-06 ***
## monthJuly             -3.942e-02  6.374e-03  -6.184 7.55e-10 ***
## monthJune             -2.574e-02  6.399e-03  -4.022 5.99e-05 ***
## monthMarch             1.257e-02  6.350e-03   1.980  0.04780 *  
## monthMay               1.593e-02  6.341e-03   2.513  0.01206 *  
## monthNovember         -3.963e-02  6.710e-03  -5.905 4.12e-09 ***
## monthOctober           1.911e-03  6.643e-03   0.288  0.77362    
## monthSeptember         9.896e-03  6.572e-03   1.506  0.13227    
## trump:Trump_adminTRUE  3.864e-04  1.962e-04   1.969  0.04907 *  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.05946 on 2005 degrees of freedom
## Multiple R-squared:  0.3066, Adjusted R-squared:  0.2983 
## F-statistic: 36.93 on 24 and 2005 DF,  p-value: < 2.2e-16

Report:

After adjusted search of report by total numbers of news in a month, we observed that p value for interaction of Trump News and Trump Admin increased to 0.01. However, it shows different result that mentioned in the notes of Table 5 : ” The interaction between Trump News and Trump Admin, while significant,does not weaken the relationship between the crime/welfare news coverage and anti-immigrant searches.” After adjustment, the interaction between Trump News and Trump Admin that does weaken the relationship between the crime/welfare news coverage and anti-immigrant searches. (Comparing regression results for welfare and crime variable that represent crime and welfare news coverage)