Posts written by Thomas Lumley (2645)

avatar

Thomas Lumley (@tslumley) is Professor of Biostatistics at the University of Auckland. His research interests include semiparametric models, survey sampling, statistical computing, foundations of statistics, and whatever methodological problems his medical collaborators come up with. He also blogs at Biased and Inefficient

September 17, 2017

Polls that aren’t any use

bogus-pie

From last week in the Herald: 73.6 per cent of landlords plan rent rises if Labour wins. It’s been a while since I noticed a bogus-poll headline, but they keep coming back.

This time there are two independent reasons this number is meaningless.  First, it’s a self-selected survey — a bogus poll.  You can think of self-selected surveys as a type of petition: they don’t tell you anything useful about the people who didn’t respond, so the results are only interesting if the absolute number responding in a particular category is surprisingly high.  In this case, it’s 73.6% of 816 landlords. According to an OIA request in 2015,  there are more than 120,000 landlords in NZ, so we’re looking at a ‘yes’ response from less than half a percent of them.

Second, there’s an important distinction in polling questions to worry about.  If a nice pollster calls you up one evening and asks who you’re voting for, there’s no particular reason to say anything other than the truth.  The truth is the strongest possible signal of your political affiliation.  If a survey asks “will you raise rents if Labour gets in and raises costs?”,  it’s fairly natural to say “yes” as a sign that you don’t support Labour, whether it’s true or not. There’s no cost to saying “yes”, but if you’re currently setting rents at what you think is the right level, there is a cost to raising them.

Those of you who do arithmetic compulsively will have noticed another, more minor, problem with the headline.  There is no number of votes out of 816 that rounds correctly to 73.6%:  600/816 is 73.52941%, ie, 73.5% and 601/816 is 73.65196, ie, 73.7%.  And, of course, headlining the results of any poll, even a good one, to the nearest tenth of a percentage point is silly.

September 13, 2017

Thresholds and discards, again

There are competing explanations out there about what happens to votes for a party that doesn’t reach the 5%/1 electorate threshold.  This post is about why I don’t like one of them.

People will say (such as on NZ Morning Report this morning) that your votes are reallocated to other parties.  In some voting systems, such as the STV we use for local government elections, reallocating votes is a thing. Your voting paper literally (or virtually) starts off in one party’s pile and is moved to a different party’s pile.

That’s not what happens with the party votes for Parliament.  If the Greens don’t make 5%, party votes for the Greens are not used in allocating List seats.  It’s exactly as if those voters hadn’t cast a party vote, which I think is a simple enough explanation to use.

Now, in the vast majority of cases the result will be the same as if the votes had been reallocated in proportion — unless something weird like a tie happens at some stage in the counting — but one of the explanations is what happens and the other one isn’t.

If you think the two explanations convey the same meaning, you shouldn’t object to using the one that’s actually correct. And if you think they convey different meanings, you definitely shouldn’t object to using the one that’s actually correct.

 

September 10, 2017

Should there be an app for that?

As you may have heard, researchers at Stanford have tried to train a neural network to predict sexual orientation from photos. Here’s the Guardian‘s story.

Artificial intelligence can accurately guess whether people are gay or straight based on photos of their faces, according to new research that suggests machines can have significantly better “gaydar” than humans.

There are a few questions this should raise.  Is it really better? Compared to whose gaydar? And WTF would think this was a good idea?

As one comment on the study says

Finally, the predictability of sexual orientation could have serious and even life-threatening implications to gay men and women and the society asa whole. In some cultures, gay men and women still suffer physical and psychological abuse at the hands of governments, neighbors, and even their own families.

No, I lied. That’s actually a quote from the research paper (here). The researchers say this sort of research is ethical and important because people don’t worry enough about their privacy. Which is a point of view.

So, you might wonder about the details.

The data came from a dating website, using self-identified gender for the photo combined with the gender they were interested in dating to work out sexual orientation. That’s going to be pretty accurate (at least if you don’t care how bisexual people are classified, which they don’t seem to). It’s also pretty obvious that the pictures weren’t put up for the purpose of AI research.

The Guardian story says

 a computer algorithm could correctly distinguish between gay and straight men 81% of the time, and 74% for women

which is true, but is a fairly misleading summary of accuracy.  Presented with a pair of faces, one of which was gay and one wasn’t, that’s how accurate the computer was.  In terms of overall error rate, you can do better that 81% or 74% just by assuming everyone is straight, and the increase in prediction accuracy in random people over the human judgment is pretty small.

More importantly, these are photos from dating profiles. You’d expect dating profile photos to give more hints about sexual orientation than, say, passport photos, or CCTV stills.  That’s what they’re for.  The researchers tried to get around this, but they were limited by the mysterious absence of large databases of non-dating photos classified by sexual orientation.

The other question you might have is about the less-accurate human ratings.  These were done using Amazon’s Mechanical Turk.  So, a typical Mechanical Turk worker, presented only with a single pair of still photos, does do a bit worse than a neural network.  That’s basically what you’d expect with the current levels of still image classification: algorithms can do better than people who aren’t particularly good and who don’t get any particular training.  But anyone who thinks that’s evidence of significantly better gaydar than humans in a meaningful sense must have pretty limited experience of social interaction cues. Or have some reason to want the accuracy of their predictions overstated.

The research paper concludes

The postprivacy world will be a much safer and hospitable place if inhabited by well-educated, tolerant people who are dedicated to equal rights.

That’s hard to argue with. It’s less clear that normalising the automated invasion of privacy and use of personal information without consent is the best way to achieve this goal.

Why you can’t predict Epsom from polls

The Herald’s poll aggregator had a bit of a breakdown over the Epsom electorate yesterday, suggesting that Labour had a chance of winning.

Polling data (and this isn’t something a statistician likes saying) is essentially useless when it comes to Epsom, because neither side benefits from getting their own supporters’ votes. National supporters are a clear majority in the electorate. If they do their tactical voting thing properly and vote for ACT’s David Seymour, he will win.  If they do the tactical voting thing badly enough, and the Labour and Green voters do it much better, National’s Paul Goldsmith will win.

Opinion polls over the whole country don’t tell you about tactical voting strategies in Epsom. Even opinion polls in Epsom would have to be carefully worded, and you’d have to be less confident in the results.

There isn’t anywhere else quite like Epsom. There are other electorates that matter and are hard to predict — such as Te Tai Tokerau, where polling information on Hone Harawira’s popularity is sparse — but in those electorates the polls are at least asking the right question.

Peter Ellis’s poll aggregator just punts on this question: the probability of ACT winning Epsom is set at an arbitrary 80%, and he gives you an app that lets you play with the settings. I think that’s the right approach.

September 6, 2017

Threshold and discards

There have been a few discussions on Twitter about what happens to votes for parties who don’t make the threshold of 5% or one electorate. I’m going to try to make it clearer than is feasible in 140 characters, but without mentioning quotients.

If you voted for a party that gets less than 5% of the party vote and does not win any electorate, your party vote is not used in determining the list seats.  It doesn’t get reassigned, reweighted, or re-anything. It just isn’t used — exactly as if those people hadn’t cast a Party vote. (Electoral Act, section 191 (4)). Last time, about 150,000 votes were set aside at this point.

The votes for the parties that are left (2.3 million, last time) are now used to allocate 120 seats.  Complicated procedures are used to work out a number of votes per seat, call it N.  The total for each party is divided by N, and rounded to the nearest whole  number, so you need at least ½N to get one seat, 1½N to get two seats and so on. (That’s not how the Electoral Act describes it; this is the equivalent ‘Webster’ method rather than the ‘Sainte-Laguë’ method).

So what are the implications?

I don’t like the term ‘wasted’ vote — if you’re voting for, say, Ban 1080 or Aotearoa Legalise Cannabis, it’s presumably not in the expectation of getting representation in Parliament, but more as a way of making your views known.  However, if your intent is to increase representation in Parliament of people whose views you support, this is the basic guideline

  • If the opinion polls show a party is nowhere near the 5%/one electorate threshold, the expected impact of increased votes for that party  on the composition of Parliament is very small (compared to a major party)
  • If the opinion polls show a party is close to the 5% threshold (in either direction) and isn’t certain to get an electorate, the expected impact of increased votes for that party  on the composition of Parliament is relatively large (compared to a major party)
  • If a party is reasonably certain to get an electorate or to get over the 5% threshold, he expected impact of increased votes for that party  on the composition of Parliament is about the same as for a major party.
September 4, 2017

Before and after

We’re in the interesting situation this election where it looks like political preferences are actually changing quite rapidly (though some of this could be changes in non-response that don’t show up in actual voting).

On Thursday, One News released a poll by Colmar Brunton that found Labour ahead of National by 43% to 41% for the first time in years.  Yesterday, NewsHub released a Reid Research poll with Labour back behind National 39% to 43%.

“Released” is important here. The Colmar Brunton poll was taken over August 26-30. The Reid Research poll was taken over August 22-30. That is, despite being released  later, the Reid Research poll was (on average) taken earlier. Comments (and even analysis) of polls often ignore the interview time and focus on the release date, but here we can see why the code of conduct for pollers requires the interview period to be described.

A difference of 4 percentage points in Labour’s support is quite large for two polls of this size (though not out of the question just from sampling error). If the polls were really discrete events four days apart, it would be plausible to argue they showed Labour’s support had stopped increasing — that the Ardern effect had reached its limit. If the two polls were taken over exactly the same period, the most plausible conclusion would be that the true support was in between and that we knew nothing more about Labour’s trajectory. With the Sunday poll actually taken slightly earlier, the difference is still likely to mostly be noise, but to the (very limited) extent that it says anything about trajectory, the story is positive for Labour.

August 29, 2017

FDA doesn’t make vaccine approvals impossible

There’s a trial of a herpes vaccine being conducted on the Caribbean island of St Kitts, because it can be done there without any ethical or regulatory oversight.  This is not a good precedent.

One of the investors involved a well-known NZ not-precisely-immigrant, Peter Thiel. He has said in the past  “you would not be able to invent the polio vaccine today.” Perhaps he should talk to the people who think there are far too many new vaccines nowadays.  They’re both wrong.

Because this is the sort of factoid that gets passed around, I thought a list of some recently approved vaccines  might be helpful.  They’re taken from this list:

20-30 years ago: Hepatitis A vaccine (PDF). Hemophilus influenzae Type B vaccine (PDF)

10-20 years ago: Intranasal quadrivalent flu vaccine (PDF).  Meningococcal Group A, C, Y, W (PDF). Shingles (PDF)

less than 10 years ago: Human papilloma virus (PDF). Injected quadrivalent flu vaccine (PDF). Japanese encephalitis vaccine (PDF) Live-bacteria cholera vaccine (PDF). Meningococcal Group B (PDF). Rotavirus (PDF)

 

And, polio vaccine? If you look at the consultation procedures used in designing the polio vaccine trial, back when randomised trials were new and controversial, you’d be glad to just deal with an ethics committee and an FDA advisory panel.

August 27, 2017

Overselling research

Three examples that have come across my Twitter feed recently:

A genetic “crystal ball” can predict whether certain people will respond effectively to the flu vaccine. Science News

This is actually really interesting research looking at why some people get high levels of antibodies and others don’t.  However, the ‘crystal ball’ is cloudy. If people are divided into ‘low’, ‘medium’ and ‘high’ responders, and you take one ‘low’ responder and one ‘high’ responder, the test has about a 75% chance of working out which is which.

Is Swiss cheese a superfood?, asks Food & Wine.

According to metro.co.uk, researchers at the University of Korea have found that Swiss cheese has a whole lot of health benefits. It contains a probiotic called—you ready for this?—propionibacterium freudenreichii, which reduces inflammation. Among other things, reducing inflammation can reduce the risk of getting a number of diseases and slow the aging process. Propionibacterium freudenreichii also boosts immune system functions.

The research was carried out in microscopic nematodes, and didn’t involve Swiss cheese. The nematodes eat bacteria, and these ones were given a diet of  Propionibacterium freudenreichii instead of their normal E. coli. While the live bacteria are present in Swiss cheese, the recipes linked from the story would make sure no live bacteria reached your gut.

 

From the Guardian

Dating from 1,000 years before Pythagoras’s theorem, the Babylonian clay tablet is a trigonometric table more accurate than any today, say researchers.

It’s pretty clear that this has to be bullshit. It’s harder to find what’s actually being claimed.  Popular Science has a more balanced view: the conjecture is that the Babylonians worked with triangles where the ratios of side lengths were simple fractions rather than where the angles were simple fractions of a circle.  Like we do in measuring slopes of roads or railways.  If that’s true, it’s an interesting idea and if they knew about trignometric relationships then it pushes back the discovery quite a bit.  It’s still not ‘more accurate than any today’; the rounding-off just happens in a different place.

 

August 26, 2017

Successive approximations to understanding MMP

The MMP voting system and its implications are relatively complicated. I’m going to try to give simple approximations and then corrections to them. If you want more definitive details, here’s the Electoral Commission and the Electoral Act.

Two votes: You have an electorate vote, which only affects who your local MP is, and doesn’t affect the composition of Parliament. You also have a party vote that affects the composition of Parliament, but not who your local MP is. The number of seats a party gets in Parliament is proportional to the number of party votes it gets.

This isn’t true, but it’s actually a pretty good working approximation for most of us.

There are two obvious flaws. First, if your local MP belongs to a party that doesn’t get enough votes to have any seats in Parliament, they still get to be an MP. Peter Dunne in Ōhariu was an example of this in the 2014 election. Second, when working out the number of seats a party is entitled to in Parliament, parties with less than 5% of the vote are excluded unless they won some electorate.  In the 2014 election, the Conservative Party got 3.97% of the vote, but no seats.

The Māori Party was an example of both exceptions: they did get enough votes in proportional terms for two seats, but not enough to make the 5% cutoff, but they didn’t have to because Te Ururoa Flavell won the Waiāriki electorate seat for them.

Proportionality: There are 120 seats, so a party needs 1/120th, or about 0.83%, of the vote for each one.

That’s not quite true because of the 5% threshold, both because some parties miss out and because the relevant percentages are of the votes remaining after parties have been excluded by the threshold.

It’s also not true because of rounding.  We elect whole MPs, not fractional ones, so we need a rounding rule. Roughly speaking, half -seats round up. More accurately, suppose there is some number N of votes available per seat (which will be worked out later). If you have at least 0.5×N votes you get one seat, 1.5×N gets you two seats, 13.5×N gets you fourteen seats.  So what’s N? It’s roughly 1/121th (0.83%) of the votes; it’s exactly whatever number you need to allocate exactly as many seats as you have available. (The Electoral Commission actually uses a procedure that’s identical in effect to this one and easier to compute, but (I think) harder to explain).

In 2014, the Māori Party got 1.32% of the vote, which is a bit more than 1.5×0.83%, and were entitled to two seats. ACT got less than 0.83% but more than 0.5×0.83% and were entitled to one seat.

Finally, if a party gets more seats from electorate candidates than it is due by proportionality those seats are extra, above the 120-seat ideal size of Parliament — except that seats won by a party or individual not contesting the party vote do come out of the 120-seat total.  So, in 2014, ACT got enough party votes to be due one of the 120 seats, but United Future didn’t. United Future did contest the party vote so Peter Dunne’s seat did not come out of the 120-seat total — he was an ‘overhang’ 121st MP. I’m guessing the reason overhangs by parties contesting the party vote are extra is that you don’t know how many there will be until you’ve done the calculation, so you’d have to go back to the start and recalculate if you counted them in the 120 (which might change the number of over-allocated seats and force another recalculation and so on).

Māori Roll: People of Māori descent can choose, every five years, to be on a Māori electoral roll rather than the general roll. If enough of them do, Māori electorates are created with the same number of people as the general electorates. There are currently seven Māori electorates, representing just over half of the people of Māori descent.  As with any electorate, you don’t have to be enrolled there to stand there; anyone eligible to be an MP can stand. 

The main way this is oversimplified is because of the people of Māori descent who aren’t on either roll, because they’re too young or just not enrolled yet. You can’t tell whether they would be on the general roll or the Māori roll, so there are procedures for StatsNZ to split the non-enrolled Māori-descent population up to calculate electorate populations.

August 25, 2017

Pretty average

Q: Does the Herald really know “The amount of sex you should be having according to your age group”

A: No.

Q: Can they really tell you “ if the regularity of your sex life is “normal”.

A: No.

Q: Is that even a thing?

A: No.

Q: If it was, would a survey of people in the US be especially relevant to NZ?

A: It was from the US? The story didn’t say that.

Today’s episode of simple answers to complex questions is brought to you by the letters F and F and S.