On Friday, I woke up at 4:45 a.m. to catch a flight home from Toronto. I’m not a morning person, and I forgot which airline I was flying. I went to the wrong terminal. I checked in late. I forgot that U.S. customs is on the Canadian side of the border. I was bumped from the flight. Fortunately, I made it to the gate with a few minutes to spare and was allowed to board as a standby passenger.

So the risk of human error may be higher early in the morning. But it’s the best time to fly if you want to minimize your time in the transit system.

The Bureau of Transportation Statistics keeps on-time data on every domestic flight flown by the 14 largest U.S.-based airlines. I collected summary data for the more than 6 million flights in the database in 2013 and organized them in one-hour blocks by their scheduled hour of departure (for instance, 10:00 a.m. to 10:59 a.m.). Then I looked at how many minutes late the flights arrived on average.

A few notes on this procedure: As should be clear, I prefer to look at delays in terms of time lost rather than a binary definition of arriving late or on time. (A 20-minute delay is nothing compared to a whole afternoon spent in transit hell.) I counted diverted and cancelled flights as equivalent to 120-minute delays. Some versions of the BTS data assign a flight negative minutes if it arrives early; I used a version where the minimum delay is 0 minutes instead.

The best time to fly is between 6 and 7 in the morning. Flights scheduled to depart in that window arrived just 8.6 minutes late on average. Flights leaving before 6, or between 7 and 8, are nearly as good.

But delay times build from there. Through the rest of the morning and the afternoon, for every hour later you depart you can expect an extra minute of delays. Delay times peak at 20.7 minutes — more than twice as long as for early-morning flights — in the block between 6 and 7 p.m. They remain at 20-plus minutes through the 9 p.m. hour.

Very late flights — those scheduled to leave at 10 p.m. or later — are much better. But it’s hard to find these, especially on the East Coast. Late flights represent only 2 percent of scheduled domestic departures.

What causes the accumulation of delays? The BTS data breaks delays down into five categories: aviation system delays, severe weather delays, late-arriving aircraft, security delays and carrier delays (such as those caused by mechanical or crew problems). Here’s the share of delay minutes each type of delay was responsible for:

Late-arriving aircraft account for the bulk of the difference in the timing of delays. Ever have one of those days when you’re 10 minutes late to your first appointment and never make up the time? Airplanes are the same way. Early in the morning, almost all of them are in position from the previous evening. But there isn’t much slack. Once they’re late, their schedule may be off for the rest of the day.

Aviation system delays peak in the mid-to-late afternoon, when the transit system is at its fullest capacity. (The combined number of arrivals plus departures is highest between 4 and 5 p.m.) Weather-related delays are highest between 3 and 11 p.m., when thunderstorms are more likely to form. (These definitions are a little fuzzy: For instance, delays caused by moderately bad weather rather than severe weather are often classified as aviation system delays since they would theoretically be avoidable if the system was getting everything else right.)

Carrier delays are more or less constant throughout the day. Security delays constitute just 0.1 percent of the total — they’re too negligible to plot on the chart, and don’t much affect the best timing for your flight.

Perhaps these differences seem too small to be worth worrying about; a flight scheduled to depart at 10 a.m. is only 2.5 minutes more delayed on average than one that leaves at 7 a.m. But — based on my frequent travels — there are some other advantages to early flights that we haven’t yet accounted for.

Traffic can be much better when getting to the airport. Some airports have shorter security lines early in the morning (there are exceptions). Well-trained crews usually keep cabin announcements and other distractions to a minimum on very early flights, so it can be a lot easier to fall back asleep.

And if you’re like I am in the morning and miss your flight, you’ll be first in the queue for the rest of the day.