Is coffee good or bad for you? If you follow the medical literature, you might think that the answer changes a few times a year. Different studies have found associations with various ailments, while others suggested that people who hit the java actually outlived their peers.

Now, a new study is out that not only finds that coffee has a positive effect, but may help explain why the earlier studies were so confused. As it turns out, coffee drinking is associated with a broad range of bad habits (most notably smoking), so if one adjusts the numbers to compensate for those, coffee drinking starts to look pretty good. Before you rush off for your latest hit, however, you should note the biggest limitation of this study: its population was recruited exclusively from the AARP. If you're not considering retirement, you might want to hold off until we see more from a study with a younger demographic.

AARP (American Association of Retired Persons) membership is open to anyone over 50, so the population at the start of the study was between 50 and 71. On the plus side, it was huge: over 400,000 individuals. And that was after the authors got rid of people who already had cancer, heart disease, and/or strokes. The initial survey included questions about coffee consumption along with a lot of other health and dietary habits. Once enrolled, the authors followed the participants for 12 years, or until Social Security records indicated they had died.

At first glance, things didn't look good for coffee, as those who partook seemed to have elevated risk of death. But as the authors worked through the numbers, it became clear that java ingestion was associated with some bad habits. Well, a lot of bad habits: "coffee drinkers were more likely to smoke cigarettes and consume more than three alcoholic drinks per day, and they consumed more red meat. Coffee drinkers also tended to have a lower level of education; were less likely to engage in vigorous physical activity; and reported lower levels of consumption of fruits, vegetables, and white meat."

The authors built a statistical model that could compensate for all of these factors and ran a series of tests to determine whether coffee intake had a significant effect on survival. In fact, once they divided up the population accurding the the degree of ingestion—five groups, ranging from less than a cup up to over six a day—they were running so many tests that they candidly admit that "Several differences (P<0.05) would be expected by chance alone."

But the pattern they saw suggests chance wasn't an issue. As coffee dose increased, the survival of both men and women went up. With intake of two or three cups daily, mortality had dropped by roughly 10 percent, and stayed there as consumption went up further (the effect was slightly more pronounced in women).

What's going on? Many studies that saw risk with coffee have suggested that its stimulant effect would have an impact on those specifically prone to heart disease. But the survey had registered preference for decaf or full strength, and it didn't make any difference. But a proposed mechanism for positive effects also failed to hold up. Coffeee is loaded with antioxidants, which have been suggested to reduce the sort of cellular damage that can lead to cancer. Out of the various causes of death the authors looked at, however, cancer was about the only one that didn't drop as coffee intake went up. And the authors looked at a variety of causes: "heart disease, respiratory disease, stroke, injuries and accidents, diabetes, and infections."

(Maybe the caffeine helps in the accidental deaths department?)

The fact that just about every possible cause of death sees an effect from coffee would be the primary reason to view this study skeptically. There are a a few others, mostly noted by the authors themselves: the coffee drinking (and other habits) were all self-reported, and were just checked at the start of the study. And, as always with studies of this sort, the authors controlled for all the obvious factors that are known to influence mortality, but they can't control for everything (in part because we don't know everything).

But there are also a few reasons to take this seriously. A number of other recent studies have seen a similar impact on mortality in coffee drinkers, and most of those have involved a substantially younger population, so the effect isn't simply limited to prolonging the lives of older individuals. In addition, the apparent dose-dependence argues that there is a real effect here.

Ultimately, what we'd really like to see to make sense of this is a mechanism that explains coffee's impact, but we may find out there isn't one—instead, there are probably a number, since it seems to influence many causes of death. In addition, as the authors of this study note, there are over 1,000 compounds in a typical brew of coffee, and figuring out which does what biologically will not be a simple thing.

In the meantime, though, you can probably drink up. Just make sure you don't have a cigarette and bacon cheeseburger with it so you can avoid undercutting any of the benefits seen in this study.

NEJM, 2012. DOI: 10.1056/NEJMoa1112010 (About DOIs).