Monday, 25 April 2016

A paragraph I am thinking about


Explorers Elisha Kane and Isaac Hayes wintered with the Polar Inuit in 1853 and 1861, respectively, and reported that the Polar Inuit lacked kayaks, leisters, and bows and arrows and that their snow houses did not have the long heat-saving entryways that were seen among other Inuit populations. They could not hunt caribou, could only hunt seals during part of the year, and were unable to harvest arctic char efficiently, although char were plentiful in local streams (28). Apparently the population was struck by an epidemic in the 1820s that carried away the older, knowledgeable members of the group, and according to custom, their possessions had to be buried with them (29). The Polar Inuit lived without these tools until about 1862, when they were visited by a group of Inuit who migrated to Greenland from Baffin Island (28, 29). There is every reason to believe that these tools would have been useful between 1820 and 1862. The Polar Inuit population declined during this period, and the tools were immediately adopted once they were reintroduced. After their introduction, population size increased. It is also telling that the kayaks used by the Polar Inuit around the turn of the century closely resemble the large, beamy kayaks used by Baffin Island Inuit and not the small sleek kayaks of the West Greenland Inuit. Over the next half century the Polar Inuit kayak design converged back to the West Greenland
design (30). If this inference is correct it means that for 40 years (nearly two generations) the Polar Inuit could have benefitted from the lost knowledge. Moreover, they collectively remembered kayaks, leisters, and bows and arrows, but did not know how to make them and could not recreate that knowledge.

Boyd and Richerson PNAS 2011. Ungated copy of original article.




Thursday, 21 April 2016

R tip: run commands without brackets

Using R, I often want to type quick commands in. But R commands always have brackets. Typing brackets (e.g. ls()) is a big hassle. I find myself missing the unix command line where you can just type ls.

So, here’s a quick hack to do just that. Put the following in your .Rprofile file in your home directory.


print.command <- function (x) {
  default.args <- attr(x, "default.args")
  if (! length(default.args)) default.args <- list()
  res <- do.call(x, default.args, envir=parent.frame(2))
  if (attr(x, "print_result")) print(res)
  invisible(NULL)
}

make_command <- function(x, ..., print = TRUE) {
  class(x) <- c("command", class(x))
  attr(x, "default.args") <- list(...)
  attr(x, "print_result") <- print
  x
}


Now, just add the following for any command that you’d like to type without brackets. For example, for ls:

ls <- make_command(ls)

From now on, typing the command will run it.

If you want to include default arguments, add them as arguments to make_command, and if you don’t want to print the result, add the argument print = false. So, for a quick way to turn debugging on, I use:

oer <- make_command(options, error = recover, print = FALSE)

Typing oer at the command line now runs options(error = recover). All without undue stress on my little finger and the Shift key.

Thursday, 10 March 2016

I corrected for multiple testing and lived


So I decided to match words with actions, and correct for multiple testing in the honesty paper. The experience left me feeling a bit ambivalent. Here's what I learned, and some conclusions.

  • There are many ways to "correct" for multiple testing, and the P values mean different things.
A standard P value means: "suppose the null hypothesis holds. What would the chance be of getting a result like this?" where like this typically means "at least as different from the null". Misunderstanding of P values is widespread, and even the statement above isn't quite right. But, in standard setups, most of us have some intuition what a P value is telling us: a measure of how far the mean of the data is from the null, in terms of the variance of the data and the sample size, all squished into one figure, so we know how (un)likely this result is under the null.

Suppose now you have 20 P values for 20 null hypotheses. If all the nulls are true, you will probably get a P < 0.05 just by the luck of the draw. But how do you want to correct for that?

One question is: "what's the chance of rejecting even one null hypothesis, if all the nulls are true?" So, if you reject a hypothesis when its P value is less than 0.05, you need to adjust those P values upwards somehow, so that, if your nulls are all true, there is no more than a 5% chance of getting any single value below 0.05.

The simplest way to do this is the Bonferroni correction: multiply your P values by 20. This works because, for any events:

Prob(A or B happens) ≤ Prob(A happens) + Prob(B happens)        (*)

Applying this:

Prob(any P value < 0.05 under null) ≤ Prob(first P value < 0.05 under null) + ... + Prob(20th P value < 0.05)

So now, if we multiply our P values by 20 on the right, and reject if any corrected P value is less than 0.05, we will be rejecting if any uncorrected P value is less than 0.0025. And assuming that the basic tests are correct, i.e. that the chance of the first P value being  0.0025 or less is indeed 0.0025 under the null:

Prob(any P value < 0.05) ≤ 0.0025 + 0.0025 + ... + 0.0025 = 0.05

OK? Fine. But, two problems.

First, this test is very conservative. It is using that inequality marked (*) above. That inequality only holds with equality if the two events are mutually exclusive. For example, the probability, when rolling a die, of getting an even number or a roll of 4 or more is 4 in 6; the probability of either event on its own is 1 in 2. So, the Bonferroni correction only gives you exact P values if it is impossible to get more than one P value less than 0.05 under the null.

Take an extreme case. Suppose you run the same test twice. Obviously you get the same P value. The chance of getting either P value below 0.05 is just 0.05. If you Bonferroni correct, you are arbitrarily doubling your P values and your chance of getting a corrected P value < 0.05 is 0.025.

Of course you wouldn't do that, but if you run two similar tests - say, tests on the same sample that might have the same kind of error - then you will have the same issue.

The second problem is that it doesn't always make sense to worry about making a single type I error. If I compare 15 countries on some score, I can make 105 possible pairwise comparisons. Do I really want to have less than a 5% chance of getting any star anywhere?

That suggests an alternative way of correcting for P values: to control the "false discovery rate". Correcting this way means: if you reject null hypotheses when they have a corrected P value of less than x%, then on average, no more than x% of your rejected nulls will be true.

But this has problems too. Standard corrections are still conservative. And while significance stars indicating, say, P<0.05, make some sense, it is hard to make much sense out of a specific P values. For example, a P value of 0.03 would mean "of all the P values in this set, not more than 3% would have P < 0.03 under the null". OK, but what do I know about this hypothesis?

As a result of these problems,

  • Corrected P values are often hard to interpret.
Most scientists can translate roughly between P values and t statistics in their head, and get a sense of what the data looks like. Now imagine a P value corrected for false discovery rate. And bear in mind that the P value is an upper bound. Do you know what it means in terms of the data? I would struggle.

P values are confusing already. Corrected ones can add a new layer of confusion. They need to be explained carefully.

  • It might be more important to correct for 2 tests than for 20.
When a naive researcher presents a table of 20 results and some significance stars, I know the whole audience is thinking "yeah, right! One out of 20! Big deal!" We know how to deal with that.

The problem is the papers which do just 2 or 3 tests, each presented on its own, and get one or two significant results. But that's already enough to seriously screw up p values. Suppose these tests are independent: the chance of getting at least p<0.05 result in 2 is almost 10%. In 3, 14%. See this famous and funny paper. 

  • Authors need to think about what tests go together. 
My paper includes: 2 dependent variables (alternative measures of the same concept). Some tests of whether those two variables correlate at individual level, and if they correlate with self-reports of ethically dubious behaviour (they do) and of own ethical standards (they don't). Some tests for differences between 15 countries. A footnote with tests just for the first eight countries I looked at. (So I can't be accused of collecting data till I got significance, which is another problem!) Some more tests of the differences, adding individual-level controls. A quick check of whether dishonesty correlated with distance from Britain (to check if anti-UK preferences might be driving the result; there was a correlation for one dependent variable only). A bunch of country-level correlations with GDP, trust and corruption. Then, a whole section on beliefs about dishonesty, with some more regressions....

These different tests are doing different things. Some are my key hypotheses. Some are more like robustness checks. Others are put in because a reviewer wanted them. How many tests am I running? Offhand, I don't know, and I'm sure my readers won't either. So, just reporting corrected P values for the whole paper makes no sense. Who cares what proportion of my results would be significant under the null? Or whether any one of them would be significant? What matters is, for each group of key hypotheses – things I really want to claim – how strong is the evidence for that. So, you don't want to correct for everything in your paper together. Group things that belong together as conceptually "a single hypothesis". I mostly did this, doing several different corrections for multiple testing.

  • Bootstrapping has promise but can be hard to implement.
The List paper I cited last time is an example of a nice method for multiple hypothesis testing which allows your tests to be non-independent (see the example above). A very rough idea is: in your data, reassign treatment/control groups (or dependent variable values) so that the null hypothesis is true. (Like a permutation test.) Run your analyses and look at the p values you get. Do this many times. You will get an idea of the distribution of p values under the null - in particular, how often the lowest p value is less than 0.05. From this you can create a map from "observed p value" to real p value.

This is cute, and potentially gives non-conservative p values, but it clearly requires a lot of work to do, especially if you haven't thought about it from the start. Which brings me to the last point:

  • Write your analysis with multiple testing in mind.
If you have sense, you're already using something like knitr to get your statistics into your paper. But if you then want to go back and correct your p values, you need to collect all the p values in one place and then correct them. Doing this could entail a lot of rewriting of your code. Bear this in mind at the start of the analysis, so that you produce your p values in one place.  

Apologies for the length of this post. I'll try to be shorter in future (and write about more enjoyable topics....)

Thursday, 7 January 2016

Sunday, 3 January 2016

How cynical!

An anecdote from a teacher friend


(Paraphrased.)

“I caught a pupil of mine cheating on his history coursework, he’d copied it wholesale. So I told him he couldn’t take his A level. First my boss comes in and asks me to reconsider. I say no. So then my boss comes back with the boy and asks me to reconsider. I say no. Then my boss’s boss comes in with the parents, and ask me to reconsider. You see, the school’s results will look bad if we don’t let him take the exam I say no. Finally, my boss’s boss’s boss comes in. I still say no. I like the kid as a person, but he shouldn’t have cheated."

What lessons can we draw from this? First, obviously, misused incentives are as toxic in the education system as elsewhere. Second, it is an example of how difficult (but crucial!) honesty can be. It involves the drawing of clear lines in a story full of shades of grey. I’m sure the kid was nice, I’m sure his parents thought up excellent reasons why his future shouldn’t be harmed by this one mistake, and that the head teacher made the same eloquent arguments, I bet nobody was crass enough to say “we can’t make our exam results look bad”. I equally bet that nobody pointed out the consequence - which is, after all, highly diffuse, distant and uncertain - that if we turn a blind eye to large-scale cheating, our education system will cease to do its job.

More abstractly, I think this anecdote shows that the theory of repeated games is very misleading as a guide to the social science of ethical behaviour.

Let’s recap: numerous “folk theorems" show that if a situation is repeated often enough among the same group of actors, they can achieve almost any outcome, including efficient outcomes (roughly, those which are best for everyone), by punishing bad behaviour in future rounds of play. This has often been taken as a parable for real world. If only people can interact often enough in stable communities, then they will force each other to do the right thing. So, for instance, Coleman (1988): “Social capital in the creation of human capital”. Or Elinor Ostrom passim. Or Ellickson, Order without law, about midWestern ranchers.

Unfortunately, no. Look at the story. Everyone around my teacher friend is persuading him to do the wrong thing. People in the relevant community have interests that are misaligned with that of the wider society. The pressure they bring to bear is making outcomes worse, not better, and only my friend’s strong personality bears up against them. This will be typical in any social system larger than Hillary Clinton’s proverbial village. To function well, large societies need internalized moral rules, not just social pressure.

Thursday, 24 December 2015

Linkage

Failure to replicate Spolaore and Wacziarg's well-known paper on genetic distance. Well, not failure to replicate but failure to be robust to be different controls. Perhaps this is just the old problem of "what to do with cross-country correlations?": it is hard to make claims about causality from such regressions, and yet we want to know something about the differences between countries. A tricky problem which I cannot solve, and that is one reason I try to work at the micro level! Spolaore and Wacziarg reply beneath the article.

Thursday, 26 November 2015

Linkage


The Private Finance Initiative does not look like good value for money. Sigh.
Private finance provides a short-term cash flow benefit for a department. However, over the long term it will not have an advantage as it will have to spend its future budget (over a 25- to 30-year period) to repay the capital and interest of the debt and a return on the investors’ equity to compensate the private sector for their participation in the project....

The Office of Budgetary Responsibility estimates that official government debt levels would be 2% of GDP higher if public rather than private finance had been used in government private finance deals. 
In [two previously mentioned] cases the decision to use private finance was made at a time of low private finance costs relative to gilts but by the time these deals were closed the spread above gilts had increased significantly but the ability to use public financing was no longer available to the department....
Note that the NAO's method of calculating private vs. public borrowing costs looks rather back-of-the-envelope (divide total payments this year by total debt held this year).

Wednesday, 25 November 2015

Why not inflate?

John Cochrane and Noah Smith debate whether a bit of inflation would be a good idea for Japan.

As an observer with a poor grasp of macro, my suspicion is that inflation sometimes happens because it is a socially optimal (read: least painful) way to deal with past debts. I suspect it will happen to the Eurozone at some point too. But an awful lot of institutional and ideological scaffolding will first have to be dismantled. Interesting.

One question I'm unsure about is whether expected inflation does the job of deflating debts. I assume it does for e.g. social security transfers, but not for inflation-proofed debt or short-term debt which has to be rolled over. I don't know how much this vitiates the argument for inflation as a "soft default".

Linkage

A Westboro baptist church member who changed her mind. This is not just about the good side of social media. It is a story about the process of conversion:
I once was lost, but now am found
Was blind, but now I see.
More on messy science, from a journal editor in psychology. I wonder if economics (including experimental economics) should be playing catch-up.

Just for the record

I believe the Paris attacks clearly have implications for Europe's refugee policy. Three of the attackers arrived in France from Syria via Greece. In other words the current system's lax controls, and the mass movements engendered by Germany's open door policy, threaten the security of EU citizens. Not surprisingly, and rightly, those citizens don't like it. Manuel Valls is right, whatever people on Twitter may think.

Thursday, 19 November 2015

Wednesday, 18 November 2015

Friday, 13 November 2015