After housing, transportation is the average American’s second largest yearly expense. Gasoline, insurance, and car repairs cost the average driver more than $3,000 annually. A number of factors, such as gas prices and road infrastructure, determine the cost of owning and operating a car. These factors vary widely from state to state.

To identify the most expensive states to drive in, 24/7 Wall St. calculated the annual cost of owning and operating a vehicle. The calculation included fuel expenditures, repairs and maintenance costs, and insurance premiums. The most expensive state to drive in is Michigan, where the cost to own and operate a car is $4,654 a year. The least expensive state is Ohio, where the annual cost is $2,522.

Fuel is the largest transportation expense in 36 states. Fuel expenses mostly depend on gas prices and driving practices. In an interview with 24/7 Wall St., Michael Calkins, manager of technical services at the American Automobile Association, explained that in some parts of the country, destinations are typically much further apart. “It’s a lot easier to go from Boston to Philadelphia than it is to go from Houston to Dallas,” he said. As a result, residents drive more in rural Southern and Western states than in urban Northeastern ones, and ultimately consume more fuel.

State and local governments set various fuel taxes, ranging from 12.25 cents a gallon in Alaska to 50.30 cents a gallon in Pennsylvania. Other factors, such as a state’s production capacity and fuel regulations, can affect the price of gas by state. With the average car consuming 528 gallons of gas annually nationwide, differences in gas prices add up.

15. Connecticut

> Total operating cost: $3,228
> No. of vehicles per 1,000 people: 798 (8th lowest)
> Avg. price of gas: $2.90 (10th highest)
> Avg. insurance premium: $1,367 (16th highest)

The cost of gasoline in Connecticut is higher than it is in the majority of states. This is in part due to the state’s relatively high 37.9 cent a gallon gas tax. However, because state residents tend to drive less, they pay slightly less on gasoline a year than the national average of $1,451 per car.

Goods and services are generally more expensive in the state, which likely contributes to Connecticut’s relatively high repair costs. Insurance costs are also above average in the state.

In most states, car insurance comprises the second largest expense. “Insurance varies widely,” Calkins said, from $808 for the average premium in Maine to $2,738 in Michigan. “It depends on the individual, their driving history, the type of vehicle, where they drive, how they drive, where the car is parked, what their average miles are per year, whether they’re married or have children,” he continued.

According to consumer insurance website, insurance carriers also consider factors such as the probability of accidents in a given state or the likelihood of residents to sue when setting rates.

According to Calkins, while it is not an out of pocket expense, depreciation is actually the costliest aspect of car ownership. Cars lose resale value every year — and lose it faster the more they are driven. Cars can also depreciate faster depending on the quality of an area’s roads.

It is also important to note how car ownership varies across the country. While the average cost of owning and operating one car in the U.S. is $3,164, many Americans are likely paying this expense for more than one vehicle. In Montana, for example, the average car is driven about 4,000 fewer miles in a year than the national average, and the average annual fuel cost per car is the lowest in the country. However, there are more than twice as many cars in Montana as there are licensed drivers. As a result, the actual cost of driving in a state with high car ownership such as Montana is likely understated by the cost of driving just one car.

In order to determine the most and least expensive states to drive, 24/7 Wall St. added the average annual costs of insurance, gasoline, and repairs cost by state. The total cost of repair represents the sum of the average amount paid for parts and labor by drivers getting their check engine lights fixed, and was provided by automobile software developer CarMD. The cost of repairs are not necessarily on an annual basis and were used as a proxy for annual repair costs. Gas expenditure per car was calculated from average miles per gallon and annual vehicle miles travelled, which came from the Federal Highway Administration (FHWA). The average car insurance premium in each state came from, an insurance review website. All data are as of the most recent period available. We also reviewed the average price of gas as of June 10, 2015 in each state from AAA. The number of vehicles, vehicle registrations, miles driven, total gallons of fuel consumed, and total miles travelled came from the FHWA and are for 2014. The percentage of miles of road in poor condition also came from the FHWA and are for 2013. State excise taxes on gasoline came from the American Petroleum Institute. All commuting figures and urban and rural composition data came from the U.S. Census Bureau’s American Community Survey. Accident fatality data came from the Insurance Institute for Highway Safety.

Click here to see the most (and least) expensive states to drive.