Millennials get flack for postponing marriage, living with parents and shying away from homeownership. But what’s less discussed is this: To some extent, they’re just responding rationally to their local housing markets.

Nearly 50% of Millennials aged 23 to 34 living in metro areas with “ideal housing conditions” in 2012 were married (46.1%), versus around 30% of Millennials living with “unfavorable” housing conditions (33.4%), according to a new study by demographer Jonathan Vespa and others in the U.S. Census Bureau’s Social, Economic and Housing Statistics Division. (“Ideal housing conditions” are defined as low costs, high availability/low competition, lots of detached homes, more rooms and low unemployment.)