Senate prediction over time – by Rick in Miami

% Senate estimate 19 September 2012
% Copyright Sam Wang, Princeton University, sswang@princeton.edu
% GNU license – free use but retain this header.
%
% Modifications by reader Rick in Miami
% Notes:
%
% Before running, load the latest CSV data files from HuffPost. An alternate
% approach is to use the wget command below.
%
% If the vector T is started at 7/31, then the plot ends on 11/8 as intended.
% Right now, because the plot starts on 8/1 and marches in 7-day
% increments to election day, it terminates six days before election day.

bias=0; % this allows the future change to be biased in one direction or
% the other. bias>0 indicates toward Democrats
demsafe=43;
GOPsafe=43;
un=0;
numstates=100-demsafe-GOPsafe;
% polls newest to oldest from HuffPost.
% last three polls, going back to second half August at the latest
% Margin is + for Dem lead, – for Rep lead

% if there are more than three polls, take only the most recent three,
% or all the polls taken within the last week (whichever is larger)
if (length(t)>3)
q=find(t>=T(tind)-7);
if (length(q)>3)
t=t(q); marg=marg(q);
else
t=t(1:3); marg=marg(1:3);
end;
end;