I am working on a project in political analytics looking back on the recent US presidential election. I have built a simple simulation model that works in the following way:

  • For each state:
    • Aggregate all polls for that state in order to calculate 'true' polling numbers for the 2 candidates. For example, Hillary 46.7% | Drumpf 46.0% in Florida.
    • Calculate state win probability from the 'true' polling numbers. For example, Hillary 46.7% | Drumpf 46.0% --> Hillary 62% chance to win Florida, Drumpf 38% chance to win Florida.
    • Simulate a random uniform 'z' between 0 and 1. If z < Hillary's chance of winning a state, Hillary wins the state in the simulation.
  • Add up electoral votes for each state won by each candidate, to see who won simulation.

Although I am coding my simulation model in R, here is a spreadsheet example of how the simulator above works, roughly speaking, for a few example states.

Model .

The difficulty now lies in accounting for correlations between states in this model. As we learned in November, Drumpf winning Michigan meant his changes of winning Wisconsin were also much higher. To begin modeling this, I have built a correlation matrix, a subset of which looks like this:

state correlations

Thus my question is as follows - how can i include these state to state correlations in my simulation of the election, that is statistically accurate. Thanks!

EDIT - I realized this whole question could be mostly summarized as followed: "how can I simulate 50 correlated random variables if I have the 50x50 correlation matrix"

  • 1
    $\begingroup$ It depends on the distribution of the underlying random variables you're simulating. In your case, it looks like you want to simulate correlated Bernoulli random variables? There are several question/answers around stackexchange on how to do that. $\endgroup$ Apr 18, 2017 at 4:21
  • $\begingroup$ great point, yes thanks. will follow up here if i find a solution on this. $\endgroup$
    – Canovice
    Apr 18, 2017 at 4:46

1 Answer 1


You could do a random effects logistic regression model such as this one (for $Y_i$ = win state $i$): $$\log \text{E} Y_i = u_i + \beta x_i + \ldots,$$ where $\beta$ is a coefficient for the polling numbers for the state $x_i$, $u_i$ is a multivariate normally distributed random effect with a $50 \times 50$ unstructured covariance matrix and the $\ldots$ stands for other things you might want to have in the model. Extra effects in the model might be particularly important, if you were to look across elections - otherwise it's pretty hard to model the correlation (on the other hand, you would have to watch out for major changes througout time, e.g. changes of democratic support in the South before and after 1964, presumably slightly boosted support in the home states of each candidate etc.). Alternatively, you could actually try to get the correlation from the polling numbers, after all, one would assume those to be similarily correlated and doing some explicit modeling for them may help with issues of changing polls throughout the campaign. If you do this in a Bayesian way, you then get posterior samples and can then use these as input into the election model. I believe that is what some of the more serious prediction models do (e.g. the one of fivethirtyeight).

Regarding the covariance matrix, you could use some simplifying structure, e.g. a-priori considering everything on certain regions such as "East Coast" equally correlated or as having some simple sub-structure or just have a "Region" effect. It depends a bit on what your software can handle and what you consider reasonable. I assume that e.g. Stan could handle a pretty large covariance matrix.

Alternatively, I never looked at whether the guys at fivethirtyeight make the details of what they do public to the level of detail you are interested in, but from their top-level descriptions, I believe they are somehow doing something like that. If it's not public, they might be willing to tell you (or perhaps it's one of their business secrets, who knows).


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.