Documentation
¶
Index ¶
- Variables
- func AdjustRaceError(alpha, beta, days float64) (a, b float64)
- func CombinePolls(polling_data []map[string][]Poll) map[string][]Poll
- func CombineRatings(rating_data []map[string][2]float64, weights []float64) map[string][2]float64
- func GetBetasFromPVIs(pvis map[string]float64) map[string][2]float64
- func GetConcentrationParams(polls []Poll, parties map[string]string, electionDate time.Time) map[string]float64
- func GetPollWeights(polls []Poll, parties map[string]string, electionDate time.Time, divUsed bool) []float64
- func GetPollingRatings(polls map[string][]Poll, election_date time.Time) map[string][2]float64
- func LoadExperts(ftype string, E *RaceMapExperts) (error, time.Time)
- func LoadForecast(ftype string, F *Forecast) (error, time.Time)
- func LoadFundamentals(ftype string, F *RaceFundamentals) (error, time.Time)
- func LoadHistoricalData() (polls []map[string][]Poll, results []map[string][2]float64, ...)
- func LoadPolls(ftype string, P *RaceMapPolls) (error, time.Time)
- func LoadPollsWeightBias()
- func LoadPollsWeightBiasCustom()
- func MergePolls(A, B []Poll) []Poll
- func MergeRaces(races map[string]struct{}, unchallenged_races [2]map[string]struct{}, ...) (r map[string][2]float64, sources map[string]map[string][2]float64)
- func MergeRatings(rating_data []map[string][2]float64) map[string][2]float64
- func OptimizeHistorical()
- func OptimizeNationalShift()
- func OptimizePVIs()
- func OptimizePollShift()
- func OptimizeRaceShift()
- func OptimizeSources()
- func Prob(races map[string][2]float64, days, rw float64) ([]float64, map[string]RaceProbability)
- func SaveExperts(name string, experts RaceMapExperts)
- func SaveForecast(name string, forecast Forecast)
- func SaveFundamentals(name string, fundamentals RaceFundamentals)
- func SavePolls(name string, polls RaceMapPolls)
- type Expert
- type Experts
- type Forecast
- type Fundamental
- type Fundamentals
- type MapExperts
- type Polls
- type RaceFundamentals
- type RaceMapExperts
- type RaceMapPolls
- type RacePoll
- type RacePolls
- type RaceProbabilities
- type RaceProbability
- type SeatProbabilities
- type SeatProbability
- type ShortForecast
- type ShortRaceProbability
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // Pre-computed in historical_optimize.go INCUMBENT_ADVANTAGE_PVI = 0.017291230141716508 // Average margin advantage to incumbent over what PVI would expect FUNDRAISING_MULTIPLIER = 0.023715954257800112 // Gain to generic ballot per doubling of fundraising over your opponent PAST_PVI_WEIGHT = 0.25506964600999965 // Weight of previous PVI in PVI calculation OVERALL_PVI_WEIGHT = 0.270927780068467 // Weight of generic ballot average in PVI calculation FUNDAMENTALS_WEIGHT = 22.90325456831519 // Multiplier to beta/dirichlet params for fundamentals margin in forecast. Larger means more confident )
View Source
var ( // Pre-computed in historical_optimize.go RAND_POLL_SHIFT = 0.017280740746056285 // Base per-poll error DAILY_POLL_SHIFT = 0.0026921961074848465 // Per-day per-poll average drift POLLING_WEIGHT = 0.7995439702676344 // Multiplier to beta/dirichlet params for polling average in forecast. Larger means more confident )
View Source
var ( // Pre-computed in historical_optimize.go RAND_NATIONAL_SHIFT = 0.036811891821249415 // Base national error DAILY_NATIONAL_SHIFT = 1.0850935968504596e-05 // Per-day average national drift RAND_RACE_SHIFT = 0.028265923390389497 // Base per-race error DAILY_RACE_SHIFT = 1.2133332224145488e-05 // Per-day per-race average drift N = 1 << 22 // Number of race simulations. Can go lower without much loss of accuracy, or higher if you want. )
View Source
var Senate2016results = map[string][2]float64{
"AL": {748709, 1335104},
"AK": {36200, 138149},
"AZ": {1031245, 1359267},
"AR": {400602, 661984},
"CA": {7542753, 4701417},
"CO": {1370710, 1215318},
"CT": {1008714, 552621},
"FL": {4122088, 4835191},
"GA": {1599726, 2135806},
"HI": {306604, 92653},
"ID": {188249, 449017},
"IL": {3012940, 2184692},
"IN": {1158947, 1423991},
"IA": {549460, 926007},
"KS": {379740, 732376},
"KY": {813246, 1090177},
"LA": {578750, 984625},
"MD": {1659907, 972557},
"MO": {1300200, 1378458},
"NV": {521994, 495079},
"NH": {354649, 353632},
"NY": {5221945, 2009335},
"NC": {2128165, 2395376},
"ND": {58116, 268788},
"OH": {1996908, 3118567},
"OK": {355911, 980892},
"OR": {1105119, 651106},
"PA": {2865012, 2951702},
"SC": {757022, 1241609},
"SD": {104125, 265494},
"UT": {301860, 760241},
"VT": {192243, 103637},
"WA": {745421, 381004},
"WI": {1380335, 1479471},
}
Functions ¶
func AdjustRaceError ¶
func CombinePolls ¶
func CombineRatings ¶
func GetConcentrationParams ¶
func GetPollWeights ¶
func GetPollingRatings ¶
func LoadExperts ¶
func LoadExperts(ftype string, E *RaceMapExperts) (error, time.Time)
func LoadFundamentals ¶
func LoadFundamentals(ftype string, F *RaceFundamentals) (error, time.Time)
func LoadHistoricalData ¶
func LoadPollsWeightBias ¶
func LoadPollsWeightBias()
func MergePolls ¶
func MergePolls(A, B []Poll) []Poll
func MergeRaces ¶
func MergeRatings ¶
Same as CombineRatings but no weights
func OptimizeHistorical ¶
func OptimizeHistorical()
func OptimizeNationalShift ¶
func OptimizeNationalShift()
func OptimizePVIs ¶
func OptimizePVIs()
func OptimizePollShift ¶
func OptimizePollShift()
func OptimizeRaceShift ¶
func OptimizeRaceShift()
func OptimizeSources ¶
func OptimizeSources()
func SaveExperts ¶
func SaveExperts(name string, experts RaceMapExperts)
func SaveForecast ¶
func SaveFundamentals ¶
func SaveFundamentals(name string, fundamentals RaceFundamentals)
func SavePolls ¶
func SavePolls(name string, polls RaceMapPolls)
Types ¶
type Expert ¶
type Forecast ¶
type Forecast struct {
ShortForecast
DemSeatsLow int `json:"dem_seats_lo"`
DemSeatsHigh int `json:"dem_seats_hi"`
RaceProbabilities map[string]RaceProbability `json:"race_probabilities"`
SeatProbabilities []SeatProbability `json:"seat_probabilities"`
Past []ShortForecast `json:"past"`
}
func GenForecast ¶
type Fundamental ¶
type Fundamentals ¶
type Fundamentals []Fundamental
func (Fundamentals) GetText ¶
func (F Fundamentals) GetText(name string) []string
type MapExperts ¶
func (MapExperts) GetText ¶
func (E MapExperts) GetText(name string) []string
type RaceMapPolls ¶
type RaceMapPolls map[string][]Poll
func (RaceMapPolls) GetText ¶
func (P RaceMapPolls) GetText(name string) []string
type RaceProbabilities ¶
type RaceProbabilities []RaceProbability
func (RaceProbabilities) Len ¶
func (R RaceProbabilities) Len() int
func (RaceProbabilities) Less ¶
func (R RaceProbabilities) Less(i, j int) bool
func (RaceProbabilities) Swap ¶
func (R RaceProbabilities) Swap(i, j int)
type RaceProbability ¶
type RaceProbability struct {
ShortRaceProbability
Race string `json:"race"`
Sources map[string][2]float64 `json:"sources"`
Past []ShortRaceProbability `json:"past,omitempty"`
}
func (*RaceProbability) Fix ¶
func (R *RaceProbability) Fix(sources map[string][2]float64)
func (RaceProbability) GetText ¶
func (R RaceProbability) GetText(name string) []string
type SeatProbabilities ¶
type SeatProbabilities []SeatProbability
func (SeatProbabilities) Len ¶
func (S SeatProbabilities) Len() int
func (SeatProbabilities) Less ¶
func (S SeatProbabilities) Less(i, j int) bool
func (SeatProbabilities) Swap ¶
func (S SeatProbabilities) Swap(i, j int)
type SeatProbability ¶
type ShortForecast ¶
type ShortRaceProbability ¶
type ShortRaceProbability struct {
Date time.Time `json:"date"`
DemWinProbability float64 `json:"dem_win_prob"`
DemVoteExpected float64 `json:"dem_vote_exp"`
DemVoteLow float64 `json:"dem_vote_lo"`
DemVoteHigh float64 `json:"dem_vote_hi"`
ConcentrationParams map[string]float64 `json:"concentration_params"`
}
Click to show internal directories.
Click to hide internal directories.