But there are a few places that vote differently than you’d expect from their local economic fundamentals. Colorado Springs and the Provo-Orem area, for instance, have education levels and an occupation mix more typical of blue metros but voted for Donald J. Trump in 2016 by a wide margin. On the flip side, Stockton, Calif., and El Paso look more like red metros economically but voted for Mrs. Clinton.

Why do some metros vote differently than their economics might suggest they would? Race, ethnicity and religion. Metros that vote Democratic despite having lower education and a job mix more typical of redder metros tend to have large Hispanic populations, including many in inland California and on the Texas border. Metros that vote more Republican despite having higher education and a blue-metro job mix tend to be whiter. (Colorado Springs also has a large evangelical population, and Provo-Orem a large Mormon one.)

Although most economic fundamentals look better in bluer metros, national economic confidence is higher among Republicans. And people who are upbeat about the national economy tend to be upbeat about their local economy. But once you account for personal political views, local economic confidence is higher in blue metros than in red metros. That means Republicans in blue metros have the highest levels of local economic confidence.

Moreover, redder metros have their own advantages, especially for people in certain economic situations. The lower cost of living in redder metros is a big advantage for retirees and others not in the labor market.