add some data from gallup, reorg

master
NunoSempere 1 month ago
parent 8b190e5d25
commit cd0546b3e8

@ -1,4 +1,4 @@
# Nuño's simple electoral college simulator
# Simple electoral college simulator
## About
@ -6,6 +6,8 @@ This is a simple model of the US electoral college. It aims to be conceptually s
Other projects, like [538](https://en.wikipedia.org/wiki/FiveThirtyEight), [Nate Silver's substack](https://www.natesilver.net/) or [Gelman's model](https://github.com/TheEconomist/us-potus-model) are to this project as a sportscar is to a walking stick. They are much more sophisticated, and probably more accurate. However, they are also more difficult to understand and to maintain.
Compare with: [Nuño's simple node version manager](https://github.com/NunoSempere/nsnvm), [squiggle.c](https://git.nunosempere.com/personal/squiggle.c), [Predict, Resolve & Tally](https://github.com/NunoSempere/PredictResolveTally)
## How to run
### Prerequisites
@ -142,7 +144,7 @@ Notes on 2020:
## Roadmap
It's not clear to me what I will do with this. As a result of writting down the model, I've realized that 80/20-ing a 538 would involve more effort than what I was expecting
It's not clear to me what I will do with this. As a result of writting down the model, I've realized that 80/20-ing a 538 would involve more effort than what I was expecting. I may just add the national drift + election day error + idiosyncratic error terms and then just call it a day.
### To do

@ -0,0 +1 @@
,nuno,calma,14.04.2024 19:03,file:///home/nuno/.config/libreoffice/4;

@ -0,0 +1,20 @@
year,midapril,nov,final
2008,43,40,47.1
2004,50,49,51
2000,41,48,48.4
1996,35,41,40.7
1992,44,37,37.5
1988,45,56,53
1984,54,59,59
1980,34,47,51
1976,49,49,48.0
1972,,62,62
1968,43,43,44
1964,,36,38.5
1960,44,49,49.55
1956,61,59,58
1952,59,51,55
1948,47,50,45.6
1944,42,48,45.9
1940,,48,44.8
1936,,44,36.5
1 year midapril nov final
2 2008 43 40 47.1
3 2004 50 49 51
4 2000 41 48 48.4
5 1996 35 41 40.7
6 1992 44 37 37.5
7 1988 45 56 53
8 1984 54 59 59
9 1980 34 47 51
10 1976 49 49 48.0
11 1972 62 62
12 1968 43 43 44
13 1964 36 38.5
14 1960 44 49 49.55
15 1956 61 59 58
16 1952 59 51 55
17 1948 47 50 45.6
18 1944 42 48 45.9
19 1940 48 44.8
20 1936 44 36.5

@ -0,0 +1,3 @@
https://news.gallup.com/poll/110548/gallup-presidential-election-trial-heat-trends.aspx
https://en.wikipedia.org/wiki/1996_United_States_presidential_election

@ -41,7 +41,7 @@ func readStates() ([]State, error) {
var states map[string]State = make(map[string]State)
/* Electoral college votes for the 2024 election*/
votes_file, err := os.Open("data/electoral-college-votes.csv")
votes_file, err := os.Open("data/num-electors/electoral-college-votes.csv")
// votes_file, err := os.Open("data/electoral-college-votes-2010-census.csv")
if err != nil {
return nil, fmt.Errorf("error opening the votes file: %v", err)
@ -70,17 +70,17 @@ func readStates() ([]State, error) {
/* Election results */
var years = []string{"2000", "2004", "2008", "2012", "2016", "2020"}
for _, year := range years {
results_filename := fmt.Sprintf("data/results/%s.csv", year)
results_file, err := os.Open(results_filename)
electoral_history_filename := fmt.Sprintf("data/electoral-history/%s.csv", year)
electoral_history_file, err := os.Open(electoral_history_filename)
if err != nil {
return nil, fmt.Errorf("error opening the results file for %s: %v", year, err)
return nil, fmt.Errorf("error opening the electoral_history file for %s: %v", year, err)
}
resultsReader := csv.NewReader(results_file)
if _, err := resultsReader.Read(); err != nil { // Skip header
return nil, fmt.Errorf("error reading results header for %s: %v", year, err)
electoral_history_reader := csv.NewReader(electoral_history_file)
if _, err := electoral_history_reader.Read(); err != nil { // Skip header
return nil, fmt.Errorf("error reading electoral_history header for %s: %v", year, err)
}
for {
record, err := resultsReader.Read()
record, err := electoral_history_reader.Read()
if err != nil {
break // EOF or an error
}
@ -94,7 +94,7 @@ func readStates() ([]State, error) {
states[state] = data
}
results_file.Close()
electoral_history_file.Close()
}
/* Read polls */

@ -0,0 +1,18 @@
- Uncertainty due to drift between now and the election
- Uncertainty due to difference between last election poll and final vote share
- Better prior by incorporating more past elections
- Think about how to:
- Inject error
- Inject correlated error
---
Not as good as gallup.
State uncertainty higher than national.
Should calculate republican error instead.
Final error:
National drift + state more uncertain than national + not as good as gallup error + idosyncratic state error
later: error correlated across states
Loading…
Cancel
Save