diff --git a/_assets/img/models/AZ_jul_pre.png b/_assets/img/models/AZ_jul_pre.png new file mode 100644 index 0000000..8e9ef10 Binary files /dev/null and b/_assets/img/models/AZ_jul_pre.png differ diff --git a/_assets/objs/AZ_jul_p_sample.bson b/_assets/objs/AZ_jul_p_sample.bson new file mode 100644 index 0000000..1c68e58 Binary files /dev/null and b/_assets/objs/AZ_jul_p_sample.bson differ diff --git a/_assets/objs/jul_pre_polls.bson b/_assets/objs/jul_pre_polls.bson new file mode 100644 index 0000000..3e177ba Binary files /dev/null and b/_assets/objs/jul_pre_polls.bson differ diff --git a/_assets/objs/outcome.csv b/_assets/objs/outcome.csv index 96b538a..bd5fcb3 100644 --- a/_assets/objs/outcome.csv +++ b/_assets/objs/outcome.csv @@ -1,128 +1,128 @@ -combo,votes,biden,trump,result -NV,6,231,307,Trump -WI,10,235,303,Trump -AZ,11,236,302,Trump -MI,15,240,298,Trump -NV and WI,16,241,297,Trump -GA,16,241,297,Trump -NC,16,241,297,Trump -NV and AZ,17,242,296,Trump -PA,19,244,294,Trump -NV and MI,21,246,292,Trump -WI and AZ,21,246,292,Trump -NV and GA,22,247,291,Trump -NV and NC,22,247,291,Trump -NV and PA,25,250,288,Trump -WI and MI,25,250,288,Trump -WI and GA,26,251,287,Trump -WI and NC,26,251,287,Trump -AZ and MI,26,251,287,Trump -AZ and GA,27,252,286,Trump -AZ and NC,27,252,286,Trump -"NV, WI and AZ",27,252,286,Trump -WI and PA,29,254,284,Trump -AZ and PA,30,255,283,Trump -GA and MI,31,256,282,Trump -MI and NC,31,256,282,Trump -"NV, WI and MI",31,256,282,Trump -GA and NC,32,257,281,Trump -"NV, WI and GA",32,257,281,Trump -"NV, WI and NC",32,257,281,Trump -"NV, AZ and MI",32,257,281,Trump -"NV, AZ and GA",33,258,280,Trump -"NV, AZ and NC",33,258,280,Trump -MI and PA,34,259,279,Trump -GA and PA,35,260,278,Trump -PA and NC,35,260,278,Trump -"NV, WI and PA",35,260,278,Trump -"NV, AZ and PA",36,261,277,Trump -"WI, AZ and MI",36,261,277,Trump -"NV, GA and MI",37,262,276,Trump -"NV, MI and NC",37,262,276,Trump -"WI, AZ and GA",37,262,276,Trump -"WI, AZ and NC",37,262,276,Trump -"NV, GA and NC",38,263,275,Trump -"NV, MI and PA",40,265,273,Trump -"WI, AZ and PA",40,265,273,Trump -"NV, GA and PA",41,266,272,Trump -"NV, PA and NC",41,266,272,Trump -"WI, GA and MI",41,266,272,Trump -"WI, MI and NC",41,266,272,Trump -"NV, WI, AZ and MI",42,267,271,Trump -"WI, GA and NC",42,267,271,Trump -"AZ, GA and MI",42,267,271,Trump -"AZ, MI and NC",42,267,271,Trump -"NV, WI, AZ and GA",43,268,270,Trump -"NV, WI, AZ and NC",43,268,270,Trump -"AZ, GA and NC",43,268,270,Trump -"WI, MI and PA",44,269,269,Tie -"WI, GA and PA",45,270,268,Harris -"WI, PA and NC",45,270,268,Harris -"AZ, MI and PA",45,270,268,Harris -"NV, WI, AZ and PA",46,271,267,Harris -"AZ, GA and PA",46,271,267,Harris -"AZ, PA and NC",46,271,267,Harris -"NV, WI, GA and MI",47,272,266,Harris -"NV, WI, MI and NC",47,272,266,Harris -"GA, MI and NC",47,272,266,Harris -"NV, WI, GA and NC",48,273,265,Harris -"NV, AZ, GA and MI",48,273,265,Harris -"NV, AZ, MI and NC",48,273,265,Harris -"NV, AZ, GA and NC",49,274,264,Harris -"NV, WI, MI and PA",50,275,263,Harris -"GA, MI and PA",50,275,263,Harris -"MI, PA and NC",50,275,263,Harris -"NV, WI, GA and PA",51,276,262,Harris -"NV, WI, PA and NC",51,276,262,Harris -"NV, AZ, MI and PA",51,276,262,Harris -"GA, PA and NC",51,276,262,Harris -"NV, AZ, GA and PA",52,277,261,Harris -"NV, AZ, PA and NC",52,277,261,Harris -"WI, AZ, GA and MI",52,277,261,Harris -"WI, AZ, MI and NC",52,277,261,Harris -"NV, GA, MI and NC",53,278,260,Harris -"WI, AZ, GA and NC",53,278,260,Harris -"WI, AZ, MI and PA",55,280,258,Harris -"NV, GA, MI and PA",56,281,257,Harris -"NV, MI, PA and NC",56,281,257,Harris -"WI, AZ, GA and PA",56,281,257,Harris -"WI, AZ, PA and NC",56,281,257,Harris -"NV, GA, PA and NC",57,282,256,Harris -"WI, GA, MI and NC",57,282,256,Harris -"NV, WI, AZ, GA and MI",58,283,255,Harris -"NV, WI, AZ, MI and NC",58,283,255,Harris -"AZ, GA, MI and NC",58,283,255,Harris -"NV, WI, AZ, GA and NC",59,284,254,Harris -"WI, GA, MI and PA",60,285,253,Harris -"WI, MI, PA and NC",60,285,253,Harris -"NV, WI, AZ, MI and PA",61,286,252,Harris -"WI, GA, PA and NC",61,286,252,Harris -"AZ, GA, MI and PA",61,286,252,Harris -"AZ, MI, PA and NC",61,286,252,Harris -"NV, WI, AZ, GA and PA",62,287,251,Harris -"NV, WI, AZ, PA and NC",62,287,251,Harris -"AZ, GA, PA and NC",62,287,251,Harris -"NV, WI, GA, MI and NC",63,288,250,Harris -"NV, AZ, GA, MI and NC",64,289,249,Harris -"NV, WI, GA, MI and PA",66,291,247,Harris -"NV, WI, MI, PA and NC",66,291,247,Harris -"GA, MI, PA and NC",66,291,247,Harris -"NV, WI, GA, PA and NC",67,292,246,Harris -"NV, AZ, GA, MI and PA",67,292,246,Harris -"NV, AZ, MI, PA and NC",67,292,246,Harris -"NV, AZ, GA, PA and NC",68,293,245,Harris -"WI, AZ, GA, MI and NC",68,293,245,Harris -"WI, AZ, GA, MI and PA",71,296,242,Harris -"WI, AZ, MI, PA and NC",71,296,242,Harris -"NV, GA, MI, PA and NC",72,297,241,Harris -"WI, AZ, GA, PA and NC",72,297,241,Harris -"NV, WI, AZ, GA, MI and NC",74,299,239,Harris -"WI, GA, MI, PA and NC",76,301,237,Harris -"AZ, GA, MI, PA and NC",77,302,236,Harris -"NV, WI, AZ, GA, MI and PA",77,302,236,Harris -"NV, WI, AZ, MI, PA and NC",77,302,236,Harris -"NV, WI, AZ, GA, PA and NC",78,303,235,Harris -"NV, WI, GA, MI, PA and NC",82,307,231,Harris -"NV, AZ, GA, MI, PA and NC",83,308,230,Harris -"WI, AZ, GA, MI, PA and NC",87,312,226,Harris -"NV, WI, AZ, GA, MI, PA and NC",93,318,220,Harris +combo,votes,harris,trump,result +NV,6,232,306,Trump +WI,10,236,302,Trump +AZ,11,237,301,Trump +MI,15,241,297,Trump +NV and WI,16,242,296,Trump +GA,16,242,296,Trump +NC,16,242,296,Trump +NV and AZ,17,243,295,Trump +PA,19,245,293,Trump +NV and MI,21,247,291,Trump +WI and AZ,21,247,291,Trump +NV and GA,22,248,290,Trump +NV and NC,22,248,290,Trump +NV and PA,25,251,287,Trump +WI and MI,25,251,287,Trump +WI and GA,26,252,286,Trump +WI and NC,26,252,286,Trump +AZ and MI,26,252,286,Trump +AZ and GA,27,253,285,Trump +AZ and NC,27,253,285,Trump +"NV, WI and AZ",27,253,285,Trump +WI and PA,29,255,283,Trump +AZ and PA,30,256,282,Trump +GA and MI,31,257,281,Trump +MI and NC,31,257,281,Trump +"NV, WI and MI",31,257,281,Trump +GA and NC,32,258,280,Trump +"NV, WI and GA",32,258,280,Trump +"NV, WI and NC",32,258,280,Trump +"NV, AZ and MI",32,258,280,Trump +"NV, AZ and GA",33,259,279,Trump +"NV, AZ and NC",33,259,279,Trump +MI and PA,34,260,278,Trump +GA and PA,35,261,277,Trump +PA and NC,35,261,277,Trump +"NV, WI and PA",35,261,277,Trump +"NV, AZ and PA",36,262,276,Trump +"WI, AZ and MI",36,262,276,Trump +"NV, GA and MI",37,263,275,Trump +"NV, MI and NC",37,263,275,Trump +"WI, AZ and GA",37,263,275,Trump +"WI, AZ and NC",37,263,275,Trump +"NV, GA and NC",38,264,274,Trump +"NV, MI and PA",40,266,272,Trump +"WI, AZ and PA",40,266,272,Trump +"NV, GA and PA",41,267,271,Trump +"NV, PA and NC",41,267,271,Trump +"WI, GA and MI",41,267,271,Trump +"WI, MI and NC",41,267,271,Trump +"NV, WI, AZ and MI",42,268,270,Trump +"WI, GA and NC",42,268,270,Trump +"AZ, GA and MI",42,268,270,Trump +"AZ, MI and NC",42,268,270,Trump +"NV, WI, AZ and GA",43,269,269,Tie +"NV, WI, AZ and NC",43,269,269,Tie +"AZ, GA and NC",43,269,269,Tie +"WI, MI and PA",44,270,268,Harris +"WI, GA and PA",45,271,267,Harris +"WI, PA and NC",45,271,267,Harris +"AZ, MI and PA",45,271,267,Harris +"NV, WI, AZ and PA",46,272,266,Harris +"AZ, GA and PA",46,272,266,Harris +"AZ, PA and NC",46,272,266,Harris +"NV, WI, GA and MI",47,273,265,Harris +"NV, WI, MI and NC",47,273,265,Harris +"GA, MI and NC",47,273,265,Harris +"NV, WI, GA and NC",48,274,264,Harris +"NV, AZ, GA and MI",48,274,264,Harris +"NV, AZ, MI and NC",48,274,264,Harris +"NV, AZ, GA and NC",49,275,263,Harris +"NV, WI, MI and PA",50,276,262,Harris +"GA, MI and PA",50,276,262,Harris +"MI, PA and NC",50,276,262,Harris +"NV, WI, GA and PA",51,277,261,Harris +"NV, WI, PA and NC",51,277,261,Harris +"NV, AZ, MI and PA",51,277,261,Harris +"GA, PA and NC",51,277,261,Harris +"NV, AZ, GA and PA",52,278,260,Harris +"NV, AZ, PA and NC",52,278,260,Harris +"WI, AZ, GA and MI",52,278,260,Harris +"WI, AZ, MI and NC",52,278,260,Harris +"NV, GA, MI and NC",53,279,259,Harris +"WI, AZ, GA and NC",53,279,259,Harris +"WI, AZ, MI and PA",55,281,257,Harris +"NV, GA, MI and PA",56,282,256,Harris +"NV, MI, PA and NC",56,282,256,Harris +"WI, AZ, GA and PA",56,282,256,Harris +"WI, AZ, PA and NC",56,282,256,Harris +"NV, GA, PA and NC",57,283,255,Harris +"WI, GA, MI and NC",57,283,255,Harris +"NV, WI, AZ, GA and MI",58,284,254,Harris +"NV, WI, AZ, MI and NC",58,284,254,Harris +"AZ, GA, MI and NC",58,284,254,Harris +"NV, WI, AZ, GA and NC",59,285,253,Harris +"WI, GA, MI and PA",60,286,252,Harris +"WI, MI, PA and NC",60,286,252,Harris +"NV, WI, AZ, MI and PA",61,287,251,Harris +"WI, GA, PA and NC",61,287,251,Harris +"AZ, GA, MI and PA",61,287,251,Harris +"AZ, MI, PA and NC",61,287,251,Harris +"NV, WI, AZ, GA and PA",62,288,250,Harris +"NV, WI, AZ, PA and NC",62,288,250,Harris +"AZ, GA, PA and NC",62,288,250,Harris +"NV, WI, GA, MI and NC",63,289,249,Harris +"NV, AZ, GA, MI and NC",64,290,248,Harris +"NV, WI, GA, MI and PA",66,292,246,Harris +"NV, WI, MI, PA and NC",66,292,246,Harris +"GA, MI, PA and NC",66,292,246,Harris +"NV, WI, GA, PA and NC",67,293,245,Harris +"NV, AZ, GA, MI and PA",67,293,245,Harris +"NV, AZ, MI, PA and NC",67,293,245,Harris +"NV, AZ, GA, PA and NC",68,294,244,Harris +"WI, AZ, GA, MI and NC",68,294,244,Harris +"WI, AZ, GA, MI and PA",71,297,241,Harris +"WI, AZ, MI, PA and NC",71,297,241,Harris +"NV, GA, MI, PA and NC",72,298,240,Harris +"WI, AZ, GA, PA and NC",72,298,240,Harris +"NV, WI, AZ, GA, MI and NC",74,300,238,Harris +"WI, GA, MI, PA and NC",76,302,236,Harris +"AZ, GA, MI, PA and NC",77,303,235,Harris +"NV, WI, AZ, GA, MI and PA",77,303,235,Harris +"NV, WI, AZ, MI, PA and NC",77,303,235,Harris +"NV, WI, AZ, GA, PA and NC",78,304,234,Harris +"NV, WI, GA, MI, PA and NC",82,308,230,Harris +"NV, AZ, GA, MI, PA and NC",83,309,229,Harris +"WI, AZ, GA, MI, PA and NC",87,313,225,Harris +"NV, WI, AZ, GA, MI, PA and NC",93,319,219,Harris diff --git a/_assets/scripts/CreateOutcomes.jl b/_assets/scripts/CreateOutcomes.jl index e5a388d..5f9211a 100644 --- a/_assets/scripts/CreateOutcomes.jl +++ b/_assets/scripts/CreateOutcomes.jl @@ -15,14 +15,15 @@ include("utils.jl") # see college_table.jl for production of 2024vote.csv base = CSV.read("/Users/ro/projects/swingwatch/_assets/objs/2024vote.csv",DataFrame) -# base.vote = base.biden_col .+ base.trump_col -# base.pop = base.biden_pop .+ base.trump_pop -# base.pct = base.biden_pop ./ base.pop +# base.vote = base.harris_col .+ base.trump_col +# base.pop = base.harris_pop .+ base.trump_pop +# base.pct = base.harris_pop ./ base.pop # base = base[:,[1,4,5,6,7,8,9]] -# new_names = ["st","biden","trump","margin","vote","pop","pct"] +# new_names = ["st","harris","trump","margin","vote","pop","pct"] # rename!(base, Symbol.(new_names)) - -base.vote = base.biden_col + base.trump_col +rename!(base,:biden_pop => "harris_pop") +rename!(base,:biden_col => "harris_col") +base.vote = base.harris_col + base.trump_col # create an iterable votes = Dict(state => base[findfirst(isequal(state), base.st), :vote][1] for state in STATES) @@ -41,8 +42,8 @@ for n in 1:7 combos[n] = collect(combinations_n) end -# biden won 6 of the 7 swing states -blues = sum(base.biden_col) - sum(collect(values(votes))) + votes["NC"] +# harris won 6 of the 7 swing states +blues = sum(base.harris_col) - sum(collect(values(votes))) + votes["NC"] # trump won NC reds = sum(base.trump_col) - votes["NC"] @@ -54,9 +55,9 @@ outcome = DataFrame( votes = [sum(votes[state] for state in combo) for combos_list in values(combos) for combo in combos_list] ) -outcome.biden = outcome.votes .+ blues -outcome.trump = COLLEGE .- outcome.biden -outcome.total = outcome.biden .+ outcome.trump +outcome.harris = outcome.votes .+ blues +outcome.trump = COLLEGE .- outcome.harris +outcome.total = outcome.harris .+ outcome.trump outcome.check = outcome.total .- COLLEGE sort!(outcome,:votes) all(outcome.check .== 0) @@ -67,8 +68,8 @@ outcome = outcome[:,1:4] # create variable to show results outcome.result = Vector{String}(undef, size(outcome, 1)) -outcome.result[outcome[:,:biden] .< TIE] .= "Trump" -outcome.result[outcome[:,:biden] .== TIE] .= "Tie" -outcome.result[outcome[:,:biden] .> TIE] .= "Harris" +outcome.result[outcome[:,:harris] .< TIE] .= "Trump" +outcome.result[outcome[:,:harris] .== TIE] .= "Tie" +outcome.result[outcome[:,:harris] .> TIE] .= "Harris" -# CSV.write(""/Users/ro/projects/swingwatch/_assets/objs/outcome.csv",outcome) +#CSV.write("/Users/ro/projects/swingwatch/_assets/objs/outcome.csv",outcome) diff --git a/_assets/scripts/constants.jl b/_assets/scripts/constants.jl index 0910c80..67d73ad 100644 --- a/_assets/scripts/constants.jl +++ b/_assets/scripts/constants.jl @@ -46,7 +46,7 @@ const TIE = 269 # biden won 6 of the 7 swing states # trump won NC const BLUE = 226 -const RED = 220 +const RED = 219 # Create a color scale with discrete colors for each value diff --git a/_assets/scripts/insert_jul.jl b/_assets/scripts/insert_jul.jl new file mode 100644 index 0000000..3a5962f --- /dev/null +++ b/_assets/scripts/insert_jul.jl @@ -0,0 +1,114 @@ +using BSON: @save, @load +using LinearAlgebra +using PrettyTables +using Printf +using Serialization +using Statistics +using StatsPlots +using Turing + +# const DESIGN_ERROR = . + +@enum Month mar apr may jul jul aug sep oct nov + +@enum Pollster begin + ag + aj + am + bi + bi + bl + bl + cb + cb + cn + cn + ea + ec + ec + ep + eu + fm + fm + fo + fo + hi + hi + hp + ia + ma + ma + mi + mi + mq + mr + mr + ns + pp + ny + qi + qi + rr + si + si + sp + sp + su + su + tr + wa + wa + ws + wsl + wss + yg +end + +@enum State PA GA NC MI AZ WI NV + +struct Poll + biden_support::Float + trump_support::Float + sample_size::Int +end + + +@load "../objs/jun_polls.bson" months + +months[jul][AZ][bl] = [Poll(45,48,781)] +months[jul][AZ][ec] = [Poll(40,50,1000)] +months[jul][AZ][ia] = [Poll(44,49,800)] +months[jul][AZ][pp] = [Poll(43,51,596)] +months[jul][AZ][yg] = [Poll(37,44,900)] +months[jul][GA][bl] = [Poll(41,43,790)] +months[jul][GA][ec] = [Poll(48,41,1000)] +months[jul][GA][ia] = [Poll(42/,48,800)] +months[jul][GA][yg] = [Poll(40,44,1000)] +months[jul][MI][bl] = [Poll(45,39,694)] +months[jul][MI][ec] = [Poll(42,45,1000)] +months[jul][MI][ep] = [Poll(36,42,600)] +months[jul][MI][tr] = [Poll(43,45,1059)] +months[jul][MI][yg] = [Poll(40,42,1000)] +months[jul][NC][bl] = [Poll(42,40,696)] +months[jul][NC][ec] = [Poll(41,48,1000)] +months[jul][NC][yg] = [Poll(40,44,1000)] +months[jul][NV][bl] = [Poll(39,45,452)] +months[jul][NV][ec] = [Poll(40,56,1000)] +months[jul][NV][ia] = [Poll(42,49,800)] +months[jul][NV][yg] = [Poll(42,46,800)] +months[jul][PA][bl] = [Poll(44,51,794)] +months[jul][PA][ia] = [Poll(45,49,800)] +months[jul][PA][yg] = [Poll(40,43,1000)] +months[jul][PA][ec] = [Poll(43,48,1000)] +months[jul][PA][ny] = [Poll(43,47,1000)] +months[jul][WI][bl] = [Poll(47,44,695)] +months[jul][WI][ec] = [Poll(43,48,1000)] +months[jul][WI][ia] = [Poll(47,47,546)] +months[jul][WI][ns] = [Poll(44,46,600)] +months[jul][WI][yg] = [Poll(39,43,900)] + + +# needs to be done manually rather than with include() +#@save "../objs/jul_polls.bson" months + + diff --git a/_assets/scripts/insert_jul_pre.jl b/_assets/scripts/insert_jul_pre.jl new file mode 100644 index 0000000..3f67e32 --- /dev/null +++ b/_assets/scripts/insert_jul_pre.jl @@ -0,0 +1,114 @@ +using BSON: @save, @load +using LinearAlgebra +using PrettyTables +using Printf +using Serialization +using Statistics +using StatsPlots +using Turing + +# const DESIGN_ERROR = . + +@enum Month mar apr may jun jul aug sep oct nov + +@enum Pollster begin + ag + aj + am + bi2 + bi3 + bl2 + bl3 + cb2 + cb3 + cn2 + cn3 + ea + ec2 + ec3 + ep + eu + fm2 + fm3 + fo2 + fo3 + hi2 + hi3 + hp + ia + ma2 + ma3 + mi2 + mi3 + mq + mr2 + mr3 + ns + pp + ny + qi2 + qi3 + rr + si2 + si3 + sp2 + sp3 + su2 + su3 + tr + wa2 + wa3 + ws + wsl + wss + yg +end + +@enum State PA GA NC MI AZ WI NV + +struct Poll + biden_support::Float64 + trump_support::Float64 + sample_size::Int64 +end + + +@load "../objs/jun_polls.bson" months + +months[jul][AZ][bl2] = [Poll(45,48,781)] +months[jul][AZ][ec2] = [Poll(40,50,1000)] +months[jul][AZ][ia] = [Poll(44,49,800)] +months[jul][AZ][pp] = [Poll(43,51,596)] +months[jul][AZ][yg] = [Poll(37,44,900)] +months[jul][GA][bl2] = [Poll(41,43,790)] +months[jul][GA][ec2] = [Poll(48,41,1000)] +months[jul][GA][ia] = [Poll(42,48,800)] +months[jul][GA][yg] = [Poll(40,44,1000)] +months[jul][MI][bl3] = [Poll(45,39,694)] +months[jul][MI][ec3] = [Poll(42,45,1000)] +months[jul][MI][ep] = [Poll(36,42,600)] +months[jul][MI][tr] = [Poll(43,45,1059)] +months[jul][MI][yg] = [Poll(40,42,1000)] +months[jul][NC][bl3] = [Poll(42,40,696)] +months[jul][NC][ec3] = [Poll(41,48,1000)] +months[jul][NC][yg] = [Poll(40,44,1000)] +months[jul][NV][bl3] = [Poll(39,45,452)] +months[jul][NV][ec3] = [Poll(40,56,1000)] +months[jul][NV][ia] = [Poll(42,49,800)] +months[jul][NV][yg] = [Poll(42,46,800)] +months[jul][PA][bl2] = [Poll(44,51,794)] +months[jul][PA][ia] = [Poll(45,49,800)] +months[jul][PA][yg] = [Poll(40,43,1000)] +months[jul][PA][ec2] = [Poll(43,48,1000)] +months[jul][PA][ny] = [Poll(43,47,1000)] +months[jul][WI][bl2] = [Poll(47,44,695)] +months[jul][WI][ec2] = [Poll(43,48,1000)] +months[jul][WI][ia] = [Poll(47,47,546)] +months[jul][WI][ns] = [Poll(44,46,600)] +months[jul][WI][yg] = [Poll(39,43,900)] + + +# needs to be done manually rather than with include() +#@save "../objs/jul_pre_polls.bson" months + + diff --git a/_assets/scripts/polls.jl b/_assets/scripts/polls.jl index 581ab7d..98b3f7e 100644 --- a/_assets/scripts/polls.jl +++ b/_assets/scripts/polls.jl @@ -3,16 +3,16 @@ STATE = State -prior_month = "may" -mon = jun -MON = "jun" -Mon = "jun" -st = "NV" -ST = NV +prior_month = "jun" +mon = jul +MON = "jul" +Mon = "jul" +st = "AZ" +ST = AZ include("polls_head.jl") prior_poll = BSON.load("../objs/"*"$st"*"_"*"$prior_month"*"_p_sample.bson") -@load "../objs/"*"$MON"*"_Polls.bson" months +@load "../objs/"*"$MON"*"_pre_polls.bson" months current_month = remove_empties(months[mon]) diff --git a/_assets/scripts/polls_head.jl b/_assets/scripts/polls_head.jl index adb16b9..9130205 100644 --- a/_assets/scripts/polls_head.jl +++ b/_assets/scripts/polls_head.jl @@ -26,6 +26,9 @@ using Turing # @enum State PA GA NC MI AZ WI NV # STATE = State @enum Pollster begin + ag + aj + am bi2 bi3 bl2 @@ -34,33 +37,45 @@ using Turing cb3 cn2 cn3 + ea ec2 ec3 + ep + eu fm2 fm3 fo2 fo3 hi2 hi3 + hp + ia ma2 ma3 mi2 mi3 + mq mr2 mr3 + ns + pp + ny qi2 qi3 + rr si2 si3 sp2 sp3 su2 su3 + tr wa2 wa3 - ws2 - ws3l - ws3s + ws + wsl + wss + yg end #------------------------------------------------------------------ const states = ["NV", "WI", "AZ", "GA", "MI", "PA", "NC"] @@ -86,6 +101,7 @@ Month_names = Dict( "apr" => "April", "may" => "May", "jun" => "June", + "jul" => "July", "aug" => "August", "sep" => "September", "oct" => "October") diff --git a/az.md b/az.md index 582ee06..5960436 100644 --- a/az.md +++ b/az.md @@ -2,6 +2,7 @@ title = "Arizona" +++ +* [July assessment through end of Biden campaign](#July-assessment-through-end-of-Biden-xcampaign) * [June assessment](#June-assessment) * [May assessment](#may-assessment) * [April assessment](#april-assessment) @@ -17,15 +18,50 @@ title = "Arizona" In the 2020 election President Biden won 50.16% (0.5016) of the votes cast for Biden or Trump in Arizona. This leaves out votes for third-party candidates. Taking the actual result as a starting point, the model introduces some uncertainty into the result to create a range of outcomes for that election from 50.10% to 50.21%. Next, the results of each month's polling are factored in on a rolling basis. +Beginning with polls conducted from July 23 - July 31, 2024, the model that used results through July 22, 2024 plus an allowance for the uncertainty introduced by the entry of Vice President Harris in place of President Biden will be used as the starting point, to be updated fortnightly by later poll results. + Assessments are based on three criteria. -* **Stringent**—Harris wins if all of the values in the credible interval (analogous to the confidence interval) are equal to or greater than his 2020 margin. +* **Stringent**—Harris (after July 22, 2024) or Biden (before July 23, 2024) wins if all of the values in the credible interval (analogous to the confidence interval) are equal to or greater than the 2020 margin of Biden over Trump. * **Historical**—fewer than 2.5% of the values in the credible interval are less than 2020 margin. * **Relaxed**—fewer than 2.5% of the values in the credible interval are less than 50.01% of the two candidate vote. +## July assessment through end of Biden campaign + +Biden wins under the *Relaxed* criterion. + +~~~ + + + + + + + + + + + + + + + + + + + + + + + +
medianmeanmodeq025q975mcserhat
0.50130.50130.50150.50080.50180.01.0
+ + +~~~ + ## June assessment -Harris wins under the *Relaxed* criterion. +Biden wins under the *Relaxed* criterion. ~~~ @@ -58,7 +94,7 @@ Harris wins under the *Relaxed* criterion. ## May assessment -Harris wins under the *Relaxed* criterion. +Biden wins under the *Relaxed* criterion. ~~~
@@ -90,7 +126,7 @@ Harris wins under the *Relaxed* criterion. ~~~ ## April assessment -Harris wins under the *Relaxed* criterion. +Biden wins under the *Relaxed* criterion. ~~~
@@ -120,7 +156,7 @@ Harris wins under the *Relaxed* criterion. ~~~ ## March assessment -Harris wins under the *Relaxed* criterion. +Biden wins under the *Relaxed* criterion. ~~~ @@ -502,7 +538,7 @@ The scenario tables below show the possible outcomes that involve Arizona. Arizo - + @@ -677,9 +713,9 @@ The scenario tables below show the possible outcomes that involve Arizona. Arizo
States won by Harris Electoral VotesHarris VotesBiden Votes Trump Votes Result
- + - + @@ -690,196 +726,196 @@ The scenario tables below show the possible outcomes that involve Arizona. Arizo - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - +
States won by Harris States won by Biden Electoral VotesHarris VotesBiden Votes Trump Votes Result
45 270 268HarrisBiden
WI, PA and NC 45 270 268HarrisBiden
NV, WI, GA and MI 47 272 266HarrisBiden
NV, WI, MI and NC 47 272 266HarrisBiden
GA, MI and NC 47 272 266HarrisBiden
NV, WI, GA and NC 48 273 265HarrisBiden
NV, WI, MI and PA 50 275 263HarrisBiden
GA, MI and PA 50 275 263HarrisBiden
MI, PA and NC 50 275 263HarrisBiden
NV, WI, GA and PA 51 276 262HarrisBiden
NV, WI, PA and NC 51 276 262HarrisBiden
GA, PA and NC 51 276 262HarrisBiden
NV, GA, MI and NC 53 278 260HarrisBiden
NV, GA, MI and PA 56 281 257HarrisBiden
NV, MI, PA and NC 56 281 257HarrisBiden
NV, GA, PA and NC 57 282 256HarrisBiden
WI, GA, MI and NC 57 282 256HarrisBiden
WI, GA, MI and PA 60 285 253HarrisBiden
WI, MI, PA and NC 60 285 253HarrisBiden
WI, GA, PA and NC 61 286 252HarrisBiden
NV, WI, GA, MI and NC 63 288 250HarrisBiden
NV, WI, GA, MI and PA 66 291 247HarrisBiden
NV, WI, MI, PA and NC 66 291 247HarrisBiden
GA, MI, PA and NC 66 291 247HarrisBiden
NV, WI, GA, PA and NC 67 292 246HarrisBiden
NV, GA, MI, PA and NC 72 297 241HarrisBiden
WI, GA, MI, PA and NC 76 301 237HarrisBiden
NV, WI, GA, MI, PA and NC 82 307 231HarrisBiden
@@ -2307,7 +2343,7 @@ The scenario tables below show the possible outcomes that involve Arizona. Arizo ## Terms - **Median**: Half of the random samples have probabilities greater than and half less than the median. -- **Mean**: The average of the 10,000 random samples constructed. It coincides with the Harris Proportion in the table above. +- **Mean**: The average of the 10,000 random samples constructed. It coincides with the Biden Proportion in the table above. - **Mode**: The probability that occurs most often. - **q025**: The value below which 2.5% of the probabilities occur. - **q975**: The value below which 97.5% of the probabilities occur. diff --git a/why7.md b/why7.md index 5170f98..a2045c8 100644 --- a/why7.md +++ b/why7.md @@ -2,8 +2,6 @@ title = "Seven Swing States" +++ - - ~~~
News and estimates about the seven 2024 presidential election swing states

@@ -12,9 +10,15 @@ title = "Seven Swing States" ~~~ -In the 2020 election, there were 49 states (including the District of Columnia and the sub-state districts in each of Maine and Nebraska) won by a margin of greater than 3.2%. Only **seven states** were decided by a margin of less than 3.2%. *Assuming* that each candidate retains all states won in the 2020 election except for the swing states, Vicr President Harris begins with the 226 electoral votes won by President Biden, excluding the swing states, and former President Trump begins with 221 electoral votes[^1] using the 2024 Electoral College allocation. The scenario table following shows the result of a Harris win of each of the possible combinations of outcomes in those states. + +**NOTE:** *The rest of this site is under revision to reflect the replacement of President Biden with Vice President Harris.* + +In the 2020 election, there were 49 states (including the District of Columnia and the sub-state districts in each of Maine and Nebraska) won by a margin of greater than 3%. Only **seven states** were decided by a margin of less than 1.5%. Texas had a margin of 2.8% but is not being talked of as a potential swing state. Florida had a margin of only 1.7% but is also not considered a swing state. + +*Assuming* that each party retains all jurisdictions won in the 2020 election except for the swing states, Vice President Harris begins with the 226 electoral votes won by President Biden, excluding the swing states, and former President Trump begins with 219 electoral votes[^1] excluding North Carolina, using the 2024 Electoral College allocation. The scenario table following shows the result of a Harris win of each of the possible combinations of outcomes in those states. These are the states that are widely discussed as swing states for 2024. + * **PA** 19 votes (down from 20 in the 2020 election) * **GA** 16 votes * **NC** 16 votes (up from 15) @@ -25,9 +29,9 @@ These are the states that are widely discussed as swing states for 2024. President Biden won all of the swing states in 2020 except for North Carolina. -Assuming that the remaining states and districts will be non-competitive and have the same electoral outcome, the starting point is 28 red states and districts with 220 electoral votes and 28 blue states and districts with 226 electoral votes. **Vice President Harris begins with an advantage of six electoral votes.** +Assuming that the remaining states and districts will be non-competitive and have the same electoral outcome, the starting point is 28 red states and districts with 219 electoral votes and 28 blue states and districts with 226 electoral votes. **Vice President Harris begins with an advantage of seven electoral votes.** -The seven swing states have **93 votes** among them. Depending on the outcomes of their elections either President Harris or former President Trump could have more than 269 electoral votes **with 45 or more of the 93 electoral votes in the swing states.** Or they could each have 269 electoral votes, which puts the decision to the House of Representatives, voting by state delegation. +The seven swing states have **93 votes** among them. Depending on the outcomes of their elections Vice President Harris can win **with 44 or more of the 93 electoral votes in the swing states.** Former President Trump needs 51 electoral votes from the swing states. Or they could each have 269 electoral votes, which puts the decision to the House of Representatives, voting by state delegation. ~~~
@@ -35,967 +39,920 @@ The seven swing states have **93 votes** among them. Depending on the outcomes o
~~~ -### Rest of page under revision - -* Former President **Trump wins in 57** of the possible outcomes -* Vice President **Harris wins in 70** of the possible outcomes -* There is **one possible tie** (if Harris wins only WI, MI and PA) +* Former President **Trump wins in 53** of the possible outcomes +* Vice President **Harris wins in 72** of the possible outcomes +* There are **three possible ties** -Without Harris wins in both North Carolina and Pennsylvania there are only **four** winning outcomes and no tie would occur. +All the possible outcomes except for Harris taking none of the swing states is shown below. The State column identifies combinations of states won by Harris. ~~~ - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
ScenarioState Electoral VotesHarris TotalTrump TotalResult
NV, WI, GA and MI47272266Harris
NV, AZ, GA and MI48273265Harris
WI, AZ, GA and MI52277261Harris
NV, WI, AZ, GA and MI58283255Harris
-~~~ - -All the possible outcomes (the scenario in which Harris wins none of the swing states is not shown.) -~~~ - - - - - - - - + + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - - + + + - - - + + + - - - + + + - - - + + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + +
States won by HarrisSwing electoral votesHarris totalTrump totalResultHarrisTrumpWinner
NV 6231307232306 Trump
WI 10235303236302 Trump
AZ 11236302237301 Trump
MI 15240298241297 Trump
NV and WI 16241297242296 Trump
GA 16241297242296 Trump
NC 16241297242296 Trump
NV and AZ 17242296243295 Trump
PA 19244294245293 Trump
NV and MI 21246292247291 Trump
WI and AZ 21246292247291 Trump
NV and GA 22247291248290 Trump
NV and NC 22247291248290 Trump
NV and PA 25250288251287 Trump
WI and MI 25250288251287 Trump
WI and GA 26251287252286 Trump
WI and NC 26251287252286 Trump
AZ and MI 26251287252286 Trump
AZ and GA 27252286253285 Trump
AZ and NC 27252286253285 Trump
NV, WI and AZ 27252286253285 Trump
WI and PA 29254284255283 Trump
AZ and PA 30255283256282 Trump
GA and MI 31256282257281 Trump
MI and NC 31256282257281 Trump
NV, WI and MI 31256282257281 Trump
GA and NC 32257281258280 Trump
NV, WI and GA 32257281258280 Trump
NV, WI and NC 32257281258280 Trump
NV, AZ and MI 32257281258280 Trump
NV, AZ and GA 33258280259279 Trump
NV, AZ and NC 33258280259279 Trump
MI and PA 34259279260278 Trump
GA and PA 35260278261277 Trump
PA and NC 35260278261277 Trump
NV, WI and PA 35260278261277 Trump
NV, AZ and PA 36261277262276 Trump
WI, AZ and MI 36261277262276 Trump
NV, GA and MI 37262276263275 Trump
NV, MI and NC 37262276263275 Trump
WI, AZ and GA 37262276263275 Trump
WI, AZ and NC 37262276263275 Trump
NV, GA and NC 38263275264274 Trump
NV, MI and PA 40265273266272 Trump
WI, AZ and PA 40265273266272 Trump
NV, GA and PA 41266272267271 Trump
NV, PA and NC 41266272267271 Trump
WI, GA and MI 41266272267271 Trump
WI, MI and NC 41266272267271 Trump
NV, WI, AZ and MI 42267271268270 Trump
WI, GA and NC 42267271268270 Trump
AZ, GA and MI 42267271268270 Trump
AZ, MI and NC 42267271268270 Trump
NV, WI, AZ and GA 43268270Trump269269Tie
NV, WI, AZ and NC 43268270Trump269269Tie
AZ, GA and NC 43268270Trump269269Tie
WI, MI and PA 44269269Tie270268Harris
WI, GA and PA 45270268271267 Harris
WI, PA and NC 45270268271267 Harris
AZ, MI and PA 45270268271267 Harris
NV, WI, AZ and PA 46271267272266 Harris
AZ, GA and PA 46271267272266 Harris
AZ, PA and NC 46271267272266 Harris
NV, WI, GA and MI 47272266273265 Harris
NV, WI, MI and NC 47272266273265 Harris
GA, MI and NC 47272266273265 Harris
NV, WI, GA and NC 48273265274264 Harris
NV, AZ, GA and MI 48273265274264 Harris
NV, AZ, MI and NC 48273265274264 Harris
NV, AZ, GA and NC 49274264275263 Harris
NV, WI, MI and PA 50275263276262 Harris
GA, MI and PA 50275263276262 Harris
MI, PA and NC 50275263276262 Harris
NV, WI, GA and PA 51276262277261 Harris
NV, WI, PA and NC 51276262277261 Harris
NV, AZ, MI and PA 51276262277261 Harris
GA, PA and NC 51276262277261 Harris
NV, AZ, GA and PA 52277261278260 Harris
NV, AZ, PA and NC 52277261278260 Harris
WI, AZ, GA and MI 52277261278260 Harris
WI, AZ, MI and NC 52277261278260 Harris
NV, GA, MI and NC 53278260279259 Harris
WI, AZ, GA and NC 53278260279259 Harris
WI, AZ, MI and PA 55280258281257 Harris
NV, GA, MI and PA 56281257282256 Harris
NV, MI, PA and NC 56281257282256 Harris
WI, AZ, GA and PA 56281257282256 Harris
WI, AZ, PA and NC 56281257282256 Harris
NV, GA, PA and NC 57282256283255 Harris
WI, GA, MI and NC 57282256283255 Harris
NV, WI, AZ, GA and MI 58283255284254 Harris
NV, WI, AZ, MI and NC 58283255284254 Harris
AZ, GA, MI and NC 58283255284254 Harris
NV, WI, AZ, GA and NC 59284254285253 Harris
WI, GA, MI and PA 60285253286252 Harris
WI, MI, PA and NC 60285253286252 Harris
NV, WI, AZ, MI and PA 61286252287251 Harris
WI, GA, PA and NC 61286252287251 Harris
AZ, GA, MI and PA 61286252287251 Harris
AZ, MI, PA and NC 61286252287251 Harris
NV, WI, AZ, GA and PA 62287251288250 Harris
NV, WI, AZ, PA and NC 62287251288250 Harris
AZ, GA, PA and NC 62287251288250 Harris
NV, WI, GA, MI and NC 63288250289249 Harris
NV, AZ, GA, MI and NC 64289249290248 Harris
NV, WI, GA, MI and PA 66291247292246 Harris
NV, WI, MI, PA and NC 66291247292246 Harris
GA, MI, PA and NC 66291247292246 Harris
NV, WI, GA, PA and NC 67292246293245 Harris
NV, AZ, GA, MI and PA 67292246293245 Harris
NV, AZ, MI, PA and NC 67292246293245 Harris
NV, AZ, GA, PA and NC 68293245294244 Harris
WI, AZ, GA, MI and NC 68293245294244 Harris
WI, AZ, GA, MI and PA 71296242297241 Harris
WI, AZ, MI, PA and NC 71296242297241 Harris
NV, GA, MI, PA and NC 72297241298240 Harris
WI, AZ, GA, PA and NC 72297241298240 Harris
NV, WI, AZ, GA, MI and NC 74299239300238 Harris
WI, GA, MI, PA and NC 76301237302236 Harris
AZ, GA, MI, PA and NC 77302236303235 Harris
NV, WI, AZ, GA, MI and PA 77302236303235 Harris
NV, WI, AZ, MI, PA and NC 77302236303235 Harris
NV, WI, AZ, GA, PA and NC 78303235304234 Harris
NV, WI, GA, MI, PA and NC 82307231308230 Harris
NV, AZ, GA, MI, PA and NC 83308230309229 Harris
WI, AZ, GA, MI, PA and NC 87312226313225 Harris
NV, WI, AZ, GA, MI, PA and NC 93318220319219 Harris
~~~ -As the general election progresses there will be an accompanying newstream of political polls. Many of those polls report national polling results without state level detail. Because **elections are not decided on the national popular vote**, those provide little insight. +As the general election progresses there will be an accompanying new stream of political polls. Many of those polls report national polling results without state level detail. Because **elections are not decided on the national popular vote**, those provide little insight. -The state level polls of interest are of limited interest outside of the swing states. The most prominent possible exception is **Florida**, which had a 2020 margin of 3.4% and may have [possibly very high turnout](../watch) in 2024. +The state level polls of interest are of limited interest outside of the swing states. The most prominent possible exception is **Florida**, which had a 2020 margin of only 1.7% and may have [possibly very high turnout](../watch) in 2024. The purpose of [Swing Watch](swingwatch.org) is to track the polls reporting on the swing states and to score the outcome based on a consistent methodology under a stated set of assumptions with fully-disclosed caclulations.