Permalink
Browse files

Final predictions, and comparison of 2004/2008 forecasts with results

  • Loading branch information...
1 parent 84bbcf2 commit 1dcfaa9834ac4b57d3717feb67d496666ffaf257 @chris-taylor committed Nov 5, 2012
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@@ -0,0 +1,29 @@
+function data = compareForecast(year)
+
+ forecast = loadForecast(year);
+ result = loadResults(year);
+
+ nCorrect = 0;
+ right = {};
+ wrong = {};
+
+ for ii = 1:length(result.state)
+
+ idx = strmatch(result.state{ii},forecast.state,'exact');
+
+ prediction = forecast.result{idx};
+
+ if strcmp(prediction,result.result{ii})
+ nCorrect = nCorrect + 1;
+ right{end+1} = result.state{ii};
+ else
+ wrong{end+1} = result.state{ii};
+ end
+
+ end
+
+ data.nCorrect = nCorrect;
+ data.right = right;
+ data.wrong = wrong;
+
+end
View
@@ -1,52 +1,52 @@
-State,EV,Kerry,Bush,Result
-Alabama,9,37,63,REP
-Alaska,3,34,62,REP
-Arizona,10,44,55,REP
-Arkansas,6,45,54,REP
-California,55,54,45,DEM
-Colorado,9,46,53,REP
-Connecticut,7,54,44,DEM
-Delaware,3,53,46,DEM
-District of Columbia,3,90,9,DEM
-Florida,27,47,52,REP
-Georgia,15,41,59,REP
-Hawaii,4,55,44,DEM
-Idaho,4,29,69,REP
-Illinois,21,55,44,DEM
-Indiana,11,39,60,REP
-Iowa,7,49,50,REP
-Kansas,6,36,63,REP
-Kentucky,8,40,60,REP
-Louisiana,9,42,57,REP
-Maine,4,53,45,DEM
-Maryland,10,56,43,DEM
-Massachusetts,12,62,37,DEM
-Michigan,17,51,48,DEM
-Minnesota,10,52,47,DEM
-Mississippi,6,40,60,REP
-Missouri,11,46,54,REP
-Montana,3,39,59,REP
-Nebraska,5,32,67,REP
-Nevada,5,48,51,REP
-New Hampshire,4,50,49,DEM
-New Jersey,15,53,46,DEM
-New Mexico,5,49,50,REP
-New York,31,58,40,DEM
-North Carolina,15,43,57,REP
-North Dakota,3,36,63,REP
-Ohio,20,49,51,REP
-Oklahoma,7,34,66,REP
-Oregon,7,53,47,DEM
-Pennsylvania,21,51,49,DEM
-Rhode Island,4,60,39,DEM
-South Carolina,8,41,58,REP
-South Dakota,3,38,61,REP
-Tennessee,11,43,57,REP
-Texas,34,38,61,REP
-Utah,5,26,72,REP
-Vermont,3,59,39,DEM
-Virginia,13,46,54,REP
-Washington,11,53,46,DEM
-West Virginia,5,43,56,REP
-Wisconsin,10,50,49,DEM
-Wyoming,3,29,69,REP
+State,Kerry,Bush,Result
+Alabama,37,63,REP
+Alaska,34,62,REP
+Arizona,44,55,REP
+Arkansas,45,54,REP
+California,54,45,DEM
+Colorado,46,53,REP
+Connecticut,54,44,DEM
+Delaware,53,46,DEM
+District of Columbia,90,9,DEM
+Florida,47,52,REP
+Georgia,41,59,REP
+Hawaii,55,44,DEM
+Idaho,29,69,REP
+Illinois,55,44,DEM
+Indiana,39,60,REP
+Iowa,49,50,REP
+Kansas,36,63,REP
+Kentucky,40,60,REP
+Louisiana,42,57,REP
+Maine,53,45,DEM
+Maryland,56,43,DEM
+Massachusetts,62,37,DEM
+Michigan,51,48,DEM
+Minnesota,52,47,DEM
+Mississippi,40,60,REP
+Missouri,46,54,REP
+Montana,39,59,REP
+Nebraska,32,67,REP
+Nevada,48,51,REP
+New Hampshire,50,49,DEM
+New Jersey,53,46,DEM
+New Mexico,49,50,REP
+New York,58,40,DEM
+North Carolina,43,57,REP
+North Dakota,36,63,REP
+Ohio,49,51,REP
+Oklahoma,34,66,REP
+Oregon,53,47,DEM
+Pennsylvania,51,49,DEM
+Rhode Island,60,39,DEM
+South Carolina,41,58,REP
+South Dakota,38,61,REP
+Tennessee,43,57,REP
+Texas,38,61,REP
+Utah,26,72,REP
+Vermont,59,39,DEM
+Virginia,46,54,REP
+Washington,53,46,DEM
+West Virginia,43,56,REP
+Wisconsin,50,49,DEM
+Wyoming,29,69,REP
View
@@ -50,4 +50,3 @@ Washington,57.65,40.48,DEM
West Virginia,42.59,55.71,REP
Wisconsin,56.22,42.31,DEM
Wyoming,32.54,64.78,REP
-U.S. Total,,,
@@ -2,51 +2,51 @@ State,Winner,Confidence
Alabama,REP,100%
Alaska,REP,100%
Arizona,REP,100%
-Arkansas,REP,90%
-California,DEM,100%
-Colorado,REP,96%
+Arkansas,REP,95%
+California,DEM,99%
+Colorado,REP,99%
Connecticut,DEM,90%
-D.C.,DEM,100%
Delaware,DEM,85%
-Florida,REP,68%
+District of Columbia,DEM,100%
+Florida,REP,50%
Georgia,REP,100%
Hawaii,REP,54%
Idaho,REP,100%
Illinois,DEM,97%
Indiana,REP,100%
-Iowa,REP,63%
+Iowa,REP,50%
Kansas,REP,100%
Kentucky,REP,100%
Louisiana,REP,100%
-Maine,DEM,97%
+Maine,DEM,96%
Maryland,DEM,100%
Massachusetts,DEM,98%
Michigan,DEM,90%
-Minnesota,DEM,97%
+Minnesota,DEM,98%
Mississippi,REP,88%
-Missouri,REP,95%
+Missouri,REP,96%
Montana,REP,100%
Nebraska,REP,100%
-Nevada,REP,98%
-New Hampshire,DEM,86%
+Nevada,REP,97%
+New Hampshire,DEM,67%
New Jersey,DEM,99%
-New Mexico,REP,54%
+New Mexico,REP,65%
New York,DEM,100%
North Carolina,REP,99%
North Dakota,REP,100%
-Ohio,DEM,62%
+Ohio,REP,61%
Oklahoma,REP,100%
-Oregon,DEM,98%
-Pennsylvania,DEM,98%
+Oregon,DEM,99%
+Pennsylvania,DEM,97%
Rhode Island,DEM,100%
South Carolina,REP,100%
South Dakota,REP,100%
Tennessee,REP,100%
Texas,REP,100%
Utah,REP,100%
Vermont,DEM,96%
-Virginia,REP,99%
-Washington,DEM,97%
-West Virginia,REP,89%
-Wisconsin,REP,53%
+Virginia,REP,96%
+Washington,DEM,96%
+West Virginia,REP,87%
+Wisconsin,REP,50%
Wyoming,REP,100%
@@ -1,38 +1,38 @@
State,Winner,Confidence
Alabama,REP,100%
Alaska,REP,100%
-Arizona,REP,94%
+Arizona,REP,92%
Arkansas,REP,99%
California,DEM,100%
Colorado,DEM,100%
Connecticut,DEM,100%
-D.C.,DEM,100%
Delaware,DEM,100%
-Florida,DEM,98%
+District of Columbia,DEM,100%
+Florida,DEM,99%
Georgia,REP,98%
Hawaii,DEM,100%
Idaho,REP,100%
Illinois,DEM,100%
-Indiana,REP,69%
+Indiana,REP,81%
Iowa,DEM,100%
Kansas,REP,100%
Kentucky,REP,100%
-Louisiana,REP,99%
+Louisiana,REP,100%
Maine,DEM,100%
Maryland,DEM,100%
Massachusetts,DEM,100%
Michigan,DEM,100%
Minnesota,DEM,100%
Mississippi,REP,100%
-Missouri,DEM,70%
-Montana,REP,75%
+Missouri,REP,50%
+Montana,REP,87%
Nebraska,REP,99%
-Nevada,DEM,99%
+Nevada,DEM,98%
New Hampshire,DEM,100%
New Jersey,DEM,100%
New Mexico,DEM,99%
New York,DEM,100%
-North Carolina,DEM,77%
+North Carolina,DEM,73%
North Dakota,DEM,61%
Ohio,DEM,100%
Oklahoma,REP,100%
@@ -42,11 +42,11 @@ Rhode Island,DEM,100%
South Carolina,REP,100%
South Dakota,REP,93%
Tennessee,REP,94%
-Texas,REP,100%
+Texas,REP,99%
Utah,REP,100%
Vermont,DEM,100%
Virginia,DEM,100%
Washington,DEM,100%
-West Virginia,REP,95%
+West Virginia,REP,99%
Wisconsin,DEM,100%
Wyoming,REP,100%
@@ -4,39 +4,39 @@ Alaska,REP,100%
Arizona,REP,70%
Arkansas,REP,100%
California,DEM,100%
-Colorado,DEM,56%
+Colorado,DEM,60%
Connecticut,DEM,100%
-D.C.,DEM,100%
Delaware,DEM,100%
-Florida,REP,74%
+District of Columbia,DEM,100%
+Florida,REP,63%
Georgia,REP,93%
Hawaii,DEM,100%
Idaho,REP,100%
Illinois,DEM,100%
Indiana,REP,100%
-Iowa,DEM,85%
+Iowa,DEM,81%
Kansas,REP,97%
Kentucky,REP,97%
Louisiana,REP,97%
Maine,DEM,97%
Maryland,DEM,100%
Massachusetts,DEM,100%
-Michigan,DEM,100%
-Minnesota,DEM,99%
+Michigan,DEM,99%
+Minnesota,DEM,100%
Mississippi,REP,95%
Missouri,REP,99%
Montana,REP,99%
Nebraska,REP,100%
-Nevada,DEM,88%
-New Hampshire,DEM,77%
+Nevada,DEM,91%
+New Hampshire,DEM,59%
New Jersey,DEM,100%
-New Mexico,DEM,99%
+New Mexico,DEM,100%
New York,DEM,100%
-North Carolina,REP,81%
+North Carolina,REP,73%
North Dakota,REP,100%
-Ohio,DEM,98%
+Ohio,DEM,99%
Oklahoma,REP,100%
-Oregon,DEM,93%
+Oregon,DEM,92%
Pennsylvania,DEM,99%
Rhode Island,DEM,100%
South Carolina,REP,80%
@@ -45,8 +45,8 @@ Tennessee,REP,100%
Texas,REP,98%
Utah,REP,100%
Vermont,DEM,100%
-Virginia,DEM,73%
+Virginia,DEM,74%
Washington,DEM,100%
West Virginia,REP,97%
-Wisconsin,DEM,97%
+Wisconsin,DEM,95%
Wyoming,REP,100%
View
@@ -0,0 +1,13 @@
+function data = loadForecast(year)
+
+ filename = sprintf('forecast/USElectionForecast%s.csv',num2str(year));
+ fid = fopen(filename);
+ fmt = '%s %s %f%%';
+
+ csv = textscan(fid,fmt,'headerlines',1,'delimiter',',');
+
+ data.state = csv{1};
+ data.result = csv{2};
+ data.conf = csv{3};
+
+end
View
@@ -0,0 +1,14 @@
+function data = loadResults(year)
+
+ filename = sprintf('data/%s-results.csv',num2str(year));
+ fid = fopen(filename);
+ fmt = '%s %f %f %s';
+
+ csv = textscan(fid,fmt,'headerlines',1,'delimiter',',');
+
+ data.state = csv{1};
+ data.dem = csv{2};
+ data.gop = csv{3};
+ data.result = csv{4};
+
+end
Oops, something went wrong.

0 comments on commit 1dcfaa9

Please sign in to comment.