Imagine: You're driving a car, and the driver ahead of you is behaving erratically. He can't stay in a lane. He puts on his left turn signal but doesn't turn. He slows to a near stop for no apparent reason, then surges forward. Finally, he makes a right turn from the left lane. You mutter to yourself, "This city has the worst (expletive) drivers."

What city are you envisioning?

Everyone who has ever set foot on an accelerator thinks they know where the worst drivers live, but they can't all be right. I set out to determine which city's drivers most deserve our steering-wheel slamming, bird-flipping frustration.

First, a caveat. There hasn't yet been a convincing ranking of cities with the worst drivers, because reliable data is hard to come by. There's no clearinghouse for statistics on bad driving based on uniform methodology for every city. This effort will involve compromises and educated guesses, along with a healthy dose of personal opinion.

Our first stop is the annual "America's Best Drivers Report," published by Allstate Insurance Company. Allstate uses claims data to determine how often drivers in the largest 200 U.S. cities get into accidents. The report is meant to celebrate the cities with the fewest crashes, but reporters get far more joy flipping the table upside down to find out which cities fared the worst. In 2012, the unofficial "worst drivers" title went to Washington, D.C., followed by Baltimore, Providence, R.I., Hialeah, and Glendale, Calif.

The report has several limitations. Allstate insures only about 10 percent of U.S. drivers and doesn't cover anyone in Massachusetts. (In informal surveys, Bostonians are leading candidates for worst-driver honors.) Insurance claims are also only one indicator of inferior driving. The Allstate report doesn't consider fatalities, drunk driving or other forms of vehicular mayhem. Finally, the survey fails to take into account the number of miles that each insured driver covers in a year. Less mileage means fewer accidents, even if you're a terrible driver.

Still, the Allstate report is both a useful indicator and a good way to winnow down the candidates. We can safely assume that the city with the worst drivers is somewhere in Allstate's bottom 50. Phoenix, Indianapolis and Denver, therefore, are off the hook, along with a raft of others. One notable escapee is San Diego, the city with the most drunk driving arrests. Let's also ignore cities with populations below 150,000, because data on those places is limited. Plus, few people have ever said, "Hayward, California has the worst drivers!" We'll add Boston back into the mix, based on opinion surveys. (You're not getting off that easy, Boston.) That leaves 39 candidates.

The first task is to consider mileage. The Center for Neighborhood Technology's Housing and Transportation Affordability Index estimates the number of miles that members of an average household travel by car in a year, broken down by city. Among our candidates, the average is 14,433 miles. (Garland, Texas, tops our list at 19,234 miles, while New York City is at the bottom with 9,375). We'll incorporate this information into the data by creating a multiplier based on how many miles a city's residents drive relative to the average. The Allstate rankings, for example, are based on the number of years between accidents. San Franciscans average 6.5 years between crashes, but they drive 74 percent as many miles as the average for cities in our survey, so we lower their years-between-accidents to 4.8 to account for how rarely they drive.

Adjusting the Allstate rankings for mileage this way has significant effects. Washington, D.C., remains the worst driving city using the insurance claims data, but Philadelphia surges to second worst. Hialeah drops seven places, from fourth to 11th.

Next we consider additional indicators. Car crashes are bad, but some accidents are worse than others. In July 2012, the Centers for Disease Control and Prevention published automobile fatality data for major cities and metropolitan statistical areas from the year 2009. It's useful for our purposes, but it comes with a couple of caveats. The researchers didn't publish data for some of the smaller cities on our list. In those cases, we'll use data from the larger metropolitan area. In addition, three cities (Boston, Newark, N.J., and Providence) had fewer than 20 fatalities, but the precise number is unpublished. We'll assume that each of these cities had 10 fatalities, so we have a number to enter into the calculations.

Drunk drivers are bad drivers, and some cities have far more of them than others. Not all locales publish reliable data on drunk driving fatalities, so we'll turn to the Century Council, an association of distillers organized to combat drunk driving. The group published the number of fatalities from alcohol-related car accidents in 2011. The data are, unfortunately, broken down by state rather than city. So, for our purposes, the sins of the state will be visited upon the cities. (New York City has reliable data, so we can use city-specific data in that instance.) We can't adjust the statewide data for mileage, because our mileage numbers relate only to cities themselves. So DWI fatalities will have to be computed per capita, unadjusted for how many miles residents of a city drive.

Pedestrian strikes are another key metric. For this indicator we turn to the CDC's WONDER, a searchable database of morbidity and mortality statistics. It's a priceless epidemiological tool as well as a bottomless source of trivia. The most granular data on pedestrian injuries and deaths is by county.

You might object to the use of pedestrian injuries as a metric of driver incompetence, because some cities have far more pedestrians than others. That's a fair point, but consider New York City. It is, by far, the most walked city in the United States. Two-thirds of New Yorkers either walk or use public transit to get to work. According to the website WalkScore.com, only 2 percent of New Yorkers live in neighborhoods where cars are necessary. While every pedestrian strike is a tragedy, there are fewer in New York than you might expect. Miami-Dade County, a significantly less walked city, had 20 percent more pedestrian strikes per mile driven between 2006 and 2010 than New York.

A note on traffic tickets, which we won't include in our rankings. There are all kinds of driving misdeeds that don't show up in accident and fatality statistics, and some of them are frustrating to other drivers - failure to keep left, following too closely, failure to signal, etc. Unfortunately, traffic ticket data is hard to find. New York publishes ticket data by county, and Washington, D.C., is occasionally forced to release information through FOIA requests. But for the most part, cities don't want citizens to know how many tickets they give out, because fluctuations will be viewed as cynical coffer-filling rather than safety initiatives.

Ticket statistics aren't reliable indicators of driving habits, anyway, because they have more to do with policing than with the real rate of infractions. Consider drunk driving. In 2011, Oregon made 387 arrests for driving under the influence per 100,000 residents in the state, nearly triple the 132 per 100,000 made in Louisiana the same year. But the Bayou state lost about twice as many residents per capita as Oregon in car accidents in which alcohol was involved. Unless Oregonians are simply better drunk drivers than Louisianans, the data suggest that arrests do not correlate with the incidence of drunk driving. There's no reason to believe that running red lights or speeding would be any different. (For what it's worth, the National Motorists Association collected data on Google queries from people around the country to guess which states issued the most tickets in 2010. Florida, Georgia, Nevada, and Texas topped the list. Montana came in last.)

So we're left with four indicators: No. 1, years between traffic accidents; No. 2, automotive fatalities; No. 3, alcohol-related driving deaths; and No. 4, pedestrian strikes. We'll rank the cities in each category and then combine those into a single ranking. The first three categories will each account for 27 percent of the total, while pedestrian strikes will count for only 19 percent, due to low data quality and variation in pedestrian density.

Is that weighting arbitrary? A little bit. Is the data sketchy in places? Undoubtedly. Could you think of other metrics? Sure. But this isn't a policy document. It's a parlor game.

And now, America, on to the cities with your worst drivers.

No. 5: Baltimore. Baltimoreans just can't keep from running into each other. They were outside the top 10 in fatalities, DWI deaths and pedestrian strikes, but their rate of collision couldn't keep them out of the top five overall.

No. 4: Tampa, Fla. Tampa doesn't do any single thing terribly, but it is consistently poor: 18th worst in years between accidents, fifth in traffic fatalities, tied for 11th in DWI fatalities, and 10th in pedestrian strikes. If the city had managed to get outside the bottom half in any individual category, Tampa residents might have avoided this distinction.

No. 3: Hialeah. The drivers of Hialeah get into a middling number of accidents, ranking 11th among the 39 candidates. But when they hit someone, they really mean it. The city finished third for fatalities. They also have a terrifying tendency to hit pedestrians.

No. 2: Philadelphia. Drivers in the city of brotherly love enjoy a good love tap behind the wheel. Second-places finishes in collisions and pedestrian strikes overwhelm their semi-respectable 16th-place ranking in DWI deaths.

No. 1: Miami. And it's not even close. First in automotive fatalities, first in pedestrian strikes, first in the obscenity-laced tirades of their fellow drivers.

A couple of other noteworthy findings: Californians did reasonably well. Although the Golden State had seven cities among our 39 candidates, only Glendale finished in the top half of the table. Louisiana's two entries, Baton Rouge and New Orleans, finished 6th and 15th, owing to the state's terrible record of drunk driving fatalities. Washington, D.C., the whipping boy of the Allstate rankings, dropped to 16th, owing to low numbers of DWI fatalities. Boston drivers don't deserve the torment they receive. They have few automotive fatalities and rarely kill people in alcohol-related accidents. It goes to show how flawed opinion polls can be.