# Articles by Wesley

### R Code for Election Posterior Distribution From a Random Sample

January 4, 2015 |

I wrote a summary article a couple of years ago discussing some probability aspects of the 2012 Presidential general election with a particular focus on exit polling. I’ve had a few people email me asking for the code I used in some if the examples. I have used this code ... [Read more...]

### Recent Articles

August 19, 2014 |

I have uploaded a few papers I have written and presented at some national conferences over the past several years.  Currently, all the articles relate to election research. [Read more...]

### The Birthday Simulation

May 21, 2014 |

Nothing novel or unique about this problem.  This just extends the problem to measure the probability to three or more people sharing the same birthday using simulation approaches. For two people it’s fairly straight forward and with a group of about 22 people the probability that two people share the ... [Read more...]

### Connecting TOAD For MySQL, MySQL Workbench, and R to Amazon AWS EC2 Using SSH Tunneling

January 7, 2014 |

I often use Amazon EC2 to store and retrieve data when I need either additional storage or higher computing capacity.  In this tutorial I’ll share how to connect to a MySQL database so that one can retrieve the data and do the analysis.  I tend to use either TOAD ... [Read more...]

### Probabilities and P-Values

December 2, 2013 |

P-values seem to be the bane of a statistician’s existence.  I’ve seen situations where entire narratives are written without p-values and only provide the effects. It can also be used as a data reduction tool but ultimately it reduces the world into a binary system: yes/no, accept/... [Read more...]

### Some Options for Testing Tables

November 18, 2013 |

Contingency tables are a very good way to summarize discrete data.  They are quite easy to construct and reasonably easy to understand. However, there are many nuances with tables and care should be taken when making conclusions related to the data. Here are just a few thoughts on the topic. ... [Read more...]

### Spatial Clustering With Equal Sizes

November 4, 2013 |

This is a problem I have encountered many times where the goal is to take a sample of spatial locations and apply constraints to the algorithm.  In addition to providing a pre-determined number of K clusters a fixed size of elements needs to be held constant within each cluster. An ... [Read more...]

### Tracking the 2013 Hurricane Season

October 21, 2013 |

With it being the end of hurricane season it’s only appropriate to do a brief summary of the activity this year.   It’s been a surprisingly low-key season as far as hurricanes are concerned.  There have been only a few hurricanes and the barometric pressure of any hurricane this ... [Read more...]

### Beta Distribution and the NJ U.S. Senate Election

October 14, 2013 |

The beta distribution is highly flexible distribution and applies to many situations and environments. The beta distribution applies well when there are percentages. The upcoming New Jersey U.S. Senate election on Wednesday fits that criterion quite well. So here I applied the beta distribution to some pre-election polls where ... [Read more...]

### Random Sequence of Heads and Tails: For R Users

October 10, 2013 |

Rick Wicklin on the SAS blog made a post today on how to tell if a sequence of coin flips were random.  I figured it was only fair to port the SAS IML code over to R.  Just like Rick Wicklin did in his example this is the Wald-Wolfowitz test ... [Read more...]

### That’s Smooth

October 10, 2013 |

I had someone ask me the other day how to take a scatterplot and draw something other than a straight line through the graph using Excel.  Yes, it can be done in Excel and it’s really quite simple, but there are some limitations when using the stock Excel dialog ... [Read more...]

### The Uncertainty of Predictions

October 2, 2013 |

There are many kinds of intervals in statistics.  To name a few of the common intervals: confidence intervals, prediction intervals, credible intervals, and tolerance intervals. Each are useful and serve their own purpose. I’ve been recently working on a couple of projects that involve making predictions from a regression ... [Read more...]

### Waiting in One Line or Multiple Lines

September 23, 2013 |

Whenever I go to the grocery store it always seems to be a lesson in statistics. I go get the things I need to buy and then  I try to select the checkout register that will decrease the amount of time I have to wait. Inevitably, I select the one ... [Read more...]

### Profile Likelihood for New Jersey U.S. Senate Special Election

September 16, 2013 |

As it stands right now Cory Booker has a very good chance of winning the New Jersey Special U.S. Senate election on October 16 to replace Frank Lautenberg and fill the remainder of his term for the next 15 months.  So with the election only about a month away I took ... [Read more...]

### A Monty Simulation

September 10, 2013 |

I was listening to Science Friday from Sep 6th. and one of the discussions by Ira Flatow was on the well known Monty Hall Problem.  This problem has been hashed out many times and in fact I was first introduced to the probability aspects of the problem while taking my ... [Read more...]

### The Eve of the NYC Democratic Mayoral Primary Election

September 9, 2013 |

It is the eve of the New York City Democratic mayoral primary election.  This is a simple follow-up on my post from last Friday as I was curious how the final pre-Election Day polling was going to fall.  It’s fairly clear who is going to get the most votes.  ... [Read more...]

### Probability of Avoiding a Run-off in the NYC 2013 Democratic Primary Election

September 6, 2013 |

The New York City mayoral Democratic primary election is taking place this coming Tuesday (Sep. 10th) and there are several candidates in the running. Bill de Blasio is the front runner and is expected to win. However, there is a catch. Even if he takes the plurality of the vote ... [Read more...]

### The Beta Prior, Likelihood, and Posterior

September 4, 2013 |

The Beta distribution (and more generally the Dirichlet) are probably my favorite distributions.  However, sometimes only limited information is available when trying set up the distribution.  For example maybe you only know the lowest likely value, the highest likely value and the median, as a measure of center.  That information ... [Read more...]

### Passing-Bablok Regression: R code for SAS users

September 2, 2013 |

While at the Joint Statistical Meeting a few weeks ago I was talking to a friend about various aspects to clinical trials. He indicated that no current R package was able to perfectly reproduce Passing-Bablok (PB) regression so that it exactly matched SAS. He ultimately wrote a couple of functions ... [Read more...]

### When Discussing Confidence Level With Others…

August 13, 2013 |

This post spawned from a discussion I had the other day. Confidence intervals are notoriously a difficult topic for those unfamiliar with statistics. I can’t really think of another statistical topic that is so widely published in newspaper articles, television, and elsewhere that so few people really understand. It’... [Read more...]
1 2 3 4