library(tidyverse)
library(knitr)
library(gtrendsR)
library(purrr)
# loading all the csv files together and combining
df <- list.files(pattern = ".csv") %>% 
  lapply(read_csv) %>% 
  bind_rows()
az <- df %>% filter(geo == "US-AZ")
nv <- df %>% filter(geo == "US-NV")
wi <- df %>% filter(geo == "US-WI")
nc <- df %>% filter(geo == "US-NC")
nh <- df %>% filter(geo == "US-NH")
pa <- df %>% filter(geo == "US-PA")
ga <- df %>% filter(geo == "US-GA")
oh <- df %>% filter(geo == "US-OH")
wa <- df %>% filter(geo == "US-WA")
ut <- df %>% filter(geo == "US-UT")
fl <- df %>% filter(geo == "US-FL")
ky <- df %>% filter(geo == "US-KY")

Conclusions

My Google Trends analysis successfully predicted 11/12 of the senate races.

What this analysis should be used for:

  • As a tool to be used alongside polling data to predict election outcomes
  • As a tool to be used to determine who might outperform their polling numbers
  • To analyze elections that garner enough Google search interest so that we have enough data to work with

What this analysis should NOT be used for:

  • Predicting elections by itself
  • Analyzing congressional races with low interest or little Google search data

Elections that garner very little search interest on Google could be because of several different reasons such as they are in a state with a lower population or because the race is expected to be a blowout and so doesn’t get much media attention and therefore less Google search hits.

Basically, this strategy works great if there is enough data from Google Trends for you to analyze.

Predicting Future Elections:

I believe that more data is needed to conclude with certainty that this tool can be used to accurately predict elections, but this analysis is a big step forward. It is certainly not perfect and definitely not a precise science. However, this strategy could indicate that a certain candidate might outperform their polling numbers and could even predict an election where the polls got it wrong, such as in the Oz-Fetterman and the Cortez Masto-Laxalt Senate races.