https://github.com/corymccartan/election-night-2020
A set of tools and visualizations for election night 2020.
https://github.com/corymccartan/election-night-2020
Last synced: 4 months ago
JSON representation
A set of tools and visualizations for election night 2020.
- Host: GitHub
- URL: https://github.com/corymccartan/election-night-2020
- Owner: CoryMcCartan
- Created: 2020-11-02T02:20:28.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2020-11-03T05:18:04.000Z (over 4 years ago)
- Last Synced: 2025-01-10T23:35:24.954Z (5 months ago)
- Language: HTML
- Homepage: https://corymccartan.github.io/election-2020/
- Size: 1.03 MB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## [Run your own forecasts on election night, no code required »](https://corymccartan.github.io/2020/11/election-night)
# Live Election-night Projections
This repository contains a series of tools and visualizations for election night.
## Files
* `R/election_night.R`: main election night script. Run to produce regular projections.
* `R/new_model.R`: fits a conjugate Bayesian linear model to predict the remaining vote
in states with partial results, using informative priors, previous election results,
and demographics.
* `R/pull_returns.R`: scrapers to get the election returns from state websites &
news outlets.
* `R/forecast_update.R`: loads and filters model posterior draws.
* `R/forecast_update_senate.R`: loads and filters model posterior draws for the Senate.
* `data/`: county presidential returns 2000-16, senate returns 2012-16, and
2016 county demographics. State EV data.
* `app.Rmd`: a Shiny app to do conditional forecasts, using posterior draws from
[my](https://corymccartan.github.io/projects/president-20/) and the
[Economist's](https://projects.economist.com/us-2020-forecast/president)
election models. Also uses `styles_app.css`, `map.js`, and `usa.js`.
* `viz/`: a dynamic R Markdown file to output the visualize from the scripts.
* `viz_old/`: the old version.
* `scripts/`: helper scripts; currently unused.
* `R/model1.R`: old live projection model.## Getting Started
1. Run `Rscript R/pull_returns.R`, which will download returns for key states and
save them to `data/pulled/returns.rdata`
2. Run `R/election_night.R`, which will use the downloaded returns to make calls
and create the visualization.You can edit the last line of `R/election_night.R` to output visualizations using
either model (state calls are made using both).