They say happiness is a state of mind, but it also depends on your state—that is, where you live. And according to a recent study by WalletHub, the happiest state in the U.S. is a shocker: Minnesota. Who would have guessed this chilly hinterland could inspire such euphoria?

“There are quite a few surprises on the list, not least of which is Minnesota, which is infamous for its dreary winters,” says Brian Davis, director of education at SparkRental.

While WalletHub’s analysis did take weather into account, it was just one of 28 metrics the team considered. They included factors such as the average number of hours people worked, commute times, hours slept, as well as rates of depression, suicide, and obesity. And, harsh winters aside, Minnesota has a lot to offer on these fronts.

“Minnesota is great if you can stand the cold,” says Tyler Drew, who has invested in real estate across the country. “Out of the northern Midwest states, it has the most functional state government, the best schools, and the strongest economy. It’s primarily agricultural, unlike Michigan or Illinois. It also survived the last housing crisis relatively unscathed.”

As for the unhappiest place? West Virginia takes the ignominious crown, due to a hodgepodge of problems.

“West Virginia—as well as Oklahoma and Louisiana—have systemic poverty combined with a lack of a decent educational environment,” says Drew. “That leads to a negative feedback loop. There aren’t any jobs, and the people who live there rarely have any skills outside a poor high school education. Teacher flight is also a very real thing in these states, and it dramatically affects how people buy their homes. No one wants to raise their kids in a state where there are no teachers.”

As a result, “in these three states, I don’t see gentrification happening any time soon,” says Drew. “Oklahoma and Louisiana run on the cyclical oil industry that may or may not be around in 30 years. And West Virginia’s main industry is already dead—coal is never coming back. Its state government seems to be perpetually looking to the past rather than the future. Their governor is a former coal company CEO, so that’s not surprising.”

To top things off, “add in a massive heroin epidemic, and West Virginia is not even a place I’d ever consider going to again,” says Drew, “let alone invest in.”

Does happiness affect real estate?

The take-home lesson for all? Do your homework on an area where you want to live before you put down roots.

“People looking to move should first do some research on the state or city they are interested in and see what type of environment it offers,” says Diana Popa at WalletHub. “Happy states tend to offer communities with strong social ties and economic environments that are thriving with low unemployment rates and high job satisfaction.”

So do people pay top dollar to buy a home in happy states? Not necessarily.

“Real estate values are quite low in the least happy states, presumably because there are few job opportunities or other strong reasons for happy, healthy, wealthy people to move there,” says Davis. “But among the happiest states, it’s a surprisingly mixed bag. Utah, California, and Hawaii are all in the top 10 states for real estate values. But Minnesota, Nebraska, and South Dakota? Not so much.”

In other words, if you’re looking for a happy place to live (and who isn’t?) but want a bargain to boot, you might want to don a parka and move north.