gain clarity about next steps & print polling errors

This commit is contained in:
NunoSempere 2024-04-14 18:16:07 -04:00
parent dc9630b96f
commit 8b190e5d25
2 changed files with 23 additions and 8 deletions

View File

@ -142,12 +142,20 @@ 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
### To do
General:
- [ ] Think about next steps
- [ ] Share with Samotsvety
- [ ] Implement possible next steps:
- 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
- [ ] Think about whether I want to monetize this
- Maybe with Vox?
- Otherwise: add MIT license & publish
@ -160,7 +168,6 @@ Steps to make this more accurate:
- How?
- [ ] Consider conditional probabilities
- See how other models account for the correlation
- [ ] Inspect polling stderrs
- [ ] Add more years
- [ ] Polling company errors
- [ ] Make polling errors wider?
@ -186,12 +193,15 @@ Consider polls:
- [x] Another extreme: Aggregate very naïvely, add up all samples together?
- [x] Aggregate polls?
- [x] Exclude polls older than one month?
- [x] Inspect polling stderrs
General
- [x] Work on README
- [x] Print states & polls separately
- [x] Histogram distributions of electoral college votes
- [x] Think about next steps
- [x] Get clarity on next steps
### Discarded

17
main.go
View File

@ -224,7 +224,7 @@ func getChanceCandidateWinsFromPollShare(candidate_p float64, poll_sample_size f
return getProbabilityAboveX(0.5, candidate_p, std)
}
func getChanceRepublicanWinFromPoll(poll Poll) float64 {
func getChanceRepublicanWinFromPoll(poll Poll, pretty_print bool) float64 {
biden_percentage, biden_exists := poll.PollResults["Biden"]
trump_percentage, trump_exists := poll.PollResults["Trump"]
@ -241,6 +241,13 @@ func getChanceRepublicanWinFromPoll(poll Poll) float64 {
std_error_poll_mean := math.Sqrt((normalized_trump_share * normalized_biden_share) / joint_trump_biden_sample_size)
p_republican_win := getProbabilityAboveX(0.5, normalized_trump_share, std_error_poll_mean)
if pretty_print {
fmt.Printf("\n\t\tSample size: %f", joint_trump_biden_sample_size)
fmt.Printf("\n\t\tMean R: %f", 100.0*normalized_trump_share)
fmt.Printf("\n\t\tStd of mean R: %f", 100*std_error_poll_mean)
fmt.Printf("\n\t\tPoll says chance of R win: %f", p_republican_win)
}
return p_republican_win
}
@ -262,9 +269,8 @@ func printStates(states []State) {
// Individual poll
for _, poll := range state.Polls {
p_republican_win_poll := getChanceRepublicanWinFromPoll(poll)
fmt.Printf("\n\tPoll: %+v", poll)
fmt.Printf("\n\t\tPoll says chance of R win: %f", p_republican_win_poll)
_ = getChanceRepublicanWinFromPoll(poll, true)
}
// Aggregate poll
@ -285,9 +291,8 @@ func printStates(states []State) {
aggregate_poll.PollResults["Biden"] = 100.0 * num_biden_votes / aggregate_sample_size
aggregate_poll.PollResults["Trump"] = 100.0 * num_trump_votes / aggregate_sample_size
p_republican_win_aggregate_polls := getChanceRepublicanWinFromPoll(aggregate_poll)
fmt.Printf("\n\tAggregate poll: %+v", aggregate_poll)
fmt.Printf("\n\t\tAggregate Poll says chance of R win: %f", p_republican_win_aggregate_polls)
_ = getChanceRepublicanWinFromPoll(aggregate_poll, true)
}
}
@ -359,7 +364,7 @@ func sampleFromState(state State) VotesForEachParty {
var aggregate_poll = Poll{SampleSize: int(aggregate_sample_size), PollResults: make(map[string]float64)}
aggregate_poll.PollResults["Biden"] = 100.0 * num_biden_votes / aggregate_sample_size
aggregate_poll.PollResults["Trump"] = 100.0 * num_trump_votes / aggregate_sample_size
p_republican_win_aggregate_polls := getChanceRepublicanWinFromPoll(aggregate_poll)
p_republican_win_aggregate_polls := getChanceRepublicanWinFromPoll(aggregate_poll, false)
weight_polls := 0.5
p_republican = weight_polls*p_republican_win_aggregate_polls + (1.0-weight_polls)*p_baserate_republican
}