leo-senate-model

April 22, 2014 · View on GitHub

Leo combines polls with other information to predict how many Senate races Democrats and Republicans will win in 2014.

Leo uses:

Historical results from the Open Elections project, CQ Press Voting and Elections Collection, Dave Leip’s Atlas of U.S. Presidential Elections, and the Federal Election Commission.

Fund-raising data from the Federal Election Commission. Biographical data from Project Vote Smart and candidate websites.

Polls aggregated by Pollster, the Roper Center for Public Opinion Research, the U.S. Officials’ Job Approval Ratings project, Polling Report, Gallup, Talking Points Memo, The Argo Journal, Real Clear Politics and FiveThirtyEight.

Brief instructions

  • Please make sure the following R packages have been installed: gam, gtools, lubridate, maps, RJSONIO, gdata, plotrix, zoo

  • Change directory to the top-level working directory of this Git repository.

  • Run: Rscript master-public.R

  • Prediction output can then be found in the data-publisher/public/_big_assets/ subdirectory.

Sample output data in /data-publisher/public/_big_assets

histogram.tsv
demchance
440
450
460
470.05
480.25
490.15
500.3
510.15
matchups.tsv
statePostalsecondaryprobabilitymeanscaleofficedemrep
AK0.067599253664328513.33710422223126.37706218633251ak-senate-class-ii-2014mark-begichjoe-miller
AK0.672480368777626-0.3693301479231646.40862522137136ak-senate-class-ii-2014mark-begichdaniel-s-sullivan
AK0.259920377558046-1.428649652628536.43282051331378ak-senate-class-ii-2014mark-begichmead-treadwell
AL1-92.258624281734413.0668255800746al-senate-class-ii-2014NAjeff-sessions
AR1-0.5883498289099895.43497477566511ar-senate-class-ii-2014mark-pryorthomas-cotton-1
CO12.751301377389095.32999951709124co-senate-class-ii-2014mark-udallcory-gardner
DE0.048558616862686722.122699509198512.2918575405219de-senate-class-ii-2014christopher-a-coonstom-kovach
DE0.95144138313731324.46229997441812.2976359697371de-senate-class-ii-2014christopher-a-coonschristine-o'donnell
nyt-ratings-today.json
{
  "date": "2014-04-22T13:19:49-0400",
  "data": [
    {
      "dem-pct": 49.428,
      "state": "AK",
      "office": "ak-senate-class-ii-2014",
      "fips": "2",
      "nyt-rating": 4
    },
    {
      "dem-pct": 4.1438E-10,
      "state": "AL",
      "office": "al-senate-class-ii-2014",
      "fips": "1",
      "nyt-rating": 7
    },
    {
      "dem-pct": 45.693,
      "state": "AR",
      "office": "ar-senate-class-ii-2014",
      "fips": "5",
      "nyt-rating": 4
    }
  ]
}
parameters.json
{
  "continuingSeats": {
    "dem": 34,
    "rep": 30
  },
  "nationalErrorScale": 0.40797,
  "upsetProb": 40,
  "houseEffect": 3.5,
  "mt": 85,
  "mtNum": "17",
  "mtDenom": "20",
  "aan": "an"
}
senate-likelihood-all.tsv
officedatedem
ak-senate-class-ii-20141-Jan-14
ak-senate-class-ii-201425-Feb-1451.4921956208518
ak-senate-class-ii-201422-Apr-1449.4276015976854
al-senate-class-ii-20141-Jan-14
al-senate-class-ii-201425-Feb-149.22057393777991e-10
al-senate-class-ii-201422-Apr-144.14383203099536e-10
senate-likelihood.tsv
datedem
1-Jan-1450
25-Feb-1435
22-Apr-1455
slug-lookup.tsv
slugname
mark-begichMarkBegich
william-brykWilliamBryk
john-jaramilloJohnJaramillo
joe-millerJoeMiller
sarah-palinSarahPalin
daniel-s-sullivanDanSullivan
kathleen-tonnKathleenTonn
mead-treadwellMeadTreadwell