add some data from gallup, reorg
This commit is contained in:
		
							parent
							
								
									8b190e5d25
								
							
						
					
					
						commit
						cd0546b3e8
					
				|  | @ -1,4 +1,4 @@ | ||||||
| # Nuño's simple electoral college simulator | # Simple electoral college simulator | ||||||
| 
 | 
 | ||||||
| ## About | ## 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. | 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 | ## How to run | ||||||
| 
 | 
 | ||||||
| ### Prerequisites | ### Prerequisites | ||||||
|  | @ -142,7 +144,7 @@ Notes on 2020: | ||||||
| 
 | 
 | ||||||
| ## Roadmap | ## 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 | ### To do | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
							
								
								
									
										1
									
								
								data/poll-errors/.~lock.gallup-republicans.ods#
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								data/poll-errors/.~lock.gallup-republicans.ods#
									
									
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1 @@ | ||||||
|  | ,nuno,calma,14.04.2024 19:03,file:///home/nuno/.config/libreoffice/4; | ||||||
							
								
								
									
										20
									
								
								data/poll-errors/gallup-republicans.csv
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										20
									
								
								data/poll-errors/gallup-republicans.csv
									
									
									
									
									
										Normal file
									
								
							|  | @ -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 | ||||||
| 
 | 
							
								
								
									
										
											BIN
										
									
								
								data/poll-errors/gallup-republicans.ods
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								data/poll-errors/gallup-republicans.ods
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								data/poll-errors/gallup-winners.ods
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								data/poll-errors/gallup-winners.ods
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								data/poll-errors/gallup-winners.ods.~1~
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								data/poll-errors/gallup-winners.ods.~1~
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										3
									
								
								data/poll-errors/source.txt
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										3
									
								
								data/poll-errors/source.txt
									
									
									
									
									
										Normal file
									
								
							|  | @ -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 | ||||||
							
								
								
									
										18
									
								
								main.go
									
									
									
									
									
								
							
							
						
						
									
										18
									
								
								main.go
									
									
									
									
									
								
							|  | @ -41,7 +41,7 @@ func readStates() ([]State, error) { | ||||||
| 	var states map[string]State = make(map[string]State) | 	var states map[string]State = make(map[string]State) | ||||||
| 
 | 
 | ||||||
| 	/* Electoral college votes for the 2024 election*/ | 	/* 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")
 | 	// votes_file, err := os.Open("data/electoral-college-votes-2010-census.csv")
 | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		return nil, fmt.Errorf("error opening the votes file: %v", err) | 		return nil, fmt.Errorf("error opening the votes file: %v", err) | ||||||
|  | @ -70,17 +70,17 @@ func readStates() ([]State, error) { | ||||||
| 	/* Election results */ | 	/* Election results */ | ||||||
| 	var years = []string{"2000", "2004", "2008", "2012", "2016", "2020"} | 	var years = []string{"2000", "2004", "2008", "2012", "2016", "2020"} | ||||||
| 	for _, year := range years { | 	for _, year := range years { | ||||||
| 		results_filename := fmt.Sprintf("data/results/%s.csv", year) | 		electoral_history_filename := fmt.Sprintf("data/electoral-history/%s.csv", year) | ||||||
| 		results_file, err := os.Open(results_filename) | 		electoral_history_file, err := os.Open(electoral_history_filename) | ||||||
| 		if err != nil { | 		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) | 		electoral_history_reader := csv.NewReader(electoral_history_file) | ||||||
| 		if _, err := resultsReader.Read(); err != nil { // Skip header
 | 		if _, err := electoral_history_reader.Read(); err != nil { // Skip header
 | ||||||
| 			return nil, fmt.Errorf("error reading results header for %s: %v", year, err) | 			return nil, fmt.Errorf("error reading electoral_history header for %s: %v", year, err) | ||||||
| 		} | 		} | ||||||
| 		for { | 		for { | ||||||
| 			record, err := resultsReader.Read() | 			record, err := electoral_history_reader.Read() | ||||||
| 			if err != nil { | 			if err != nil { | ||||||
| 				break // EOF or an error
 | 				break // EOF or an error
 | ||||||
| 			} | 			} | ||||||
|  | @ -94,7 +94,7 @@ func readStates() ([]State, error) { | ||||||
| 			states[state] = data | 			states[state] = data | ||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
| 		results_file.Close() | 		electoral_history_file.Close() | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	/* Read polls */ | 	/* Read polls */ | ||||||
|  |  | ||||||
							
								
								
									
										18
									
								
								scratchpad.txt
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										18
									
								
								scratchpad.txt
									
									
									
									
									
										Normal file
									
								
							|  | @ -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…
	
		Reference in New Issue
	
	Block a user