When it comes to living a long life, Hawaii is the place to be. Beyond the beaches, balmy weather and laid-back vibe, the state also has the most efficient health care system in the U.S., according to a new analysis.

Hawaiians lived two years longer than the national average of 79 years, benefiting from four decades of employer-paid insurance, generous Medicaid benefits and favorable demographics. Residents of West Virginia, which ranked last, lived three years less than the average, even though per capita health care spending there was $9,462 compared with $7,299 for Hawaii.

States were ranked based on three weighted metrics scored on a scale of 0 to 100: life expectancy, health care costs per capita, and costs as a percentage of state gross domestic product. The data cover 2014, the most recent available.

Minnesota ranked fifth — after Hawaii, California, New York and Connecticut — for fewest deaths caused by major factors such as heart disease, cancer and accidents. Minnesota was fourth — after Utah, Colorado and California — in rankings of the lowest death rates from risky behaviors.

Hawaiians have an edge: The state's 43-year-old Prepaid Health Care Act, which sets minimum standards for employer-provided benefits, including coverage for office visits, maternal care and hospital stays for employees working at least 20 hours a week, said Hilton Raethel, chief executive of the advocacy group Healthcare Association of Hawaii. A state fund helps defray costs for small businesses.

Hawaii also has lower Medicaid eligibility requirements than most states and high concentrations of union workers and military personnel with medical plans, Raethel said. According to newly released census data, as of 2016, health coverage in Hawaii was 96.5 percent, second only to Massachusetts at 97.5 percent.

Hawaii's death rate — the age-adjusted share of people dying — was 588.7 for every 100,000 people, the lowest in the U.S. and well below the national average of 724.6. West Virginia was one of four states, all in the "diabetes belt," with a rate higher than 900.

Almost 43 percent of West Virginia adults had high blood pressure, compared with 30.9 percent nationally. More than 25 percent were smokers, compared with 17.5 percent, and 35.6 percent were obese, compared with less than 30 percent. The state also had the highest death rate from drugs.