For eight years, Peter Coles had an economist’s dream job at Harvard Business School.

His research focused on the design of efficient markets, an important and growing field that has influenced such things as Treasury bill auctions and decisions on who receives organ transplants. He even got to work with Alvin E. Roth, who won a Nobel in economic science in 2012.

But prestige was not enough to keep Mr. Coles at Harvard. In 2013, he moved to the San Francisco Bay Area. He now works at Airbnb, the online lodging marketplace, one of a number of tech companies luring economists with the promise of big sets of data and big salaries.

Silicon Valley is turning to the dismal science in its never-ending quest to squeeze more money out of old markets and build new ones. In turn, the economists say they are eager to explore the digital world for fresh insights into timeless economic questions of pricing, incentives and behavior.

“It’s an absolute candy store for economists,” Mr. Coles said.

The pay, of course, is a lot better than you would find in academia, where economists typically earn $125,000 to $150,000 a year. In tech companies, pay for a Ph.D. economist will usually come in at more than $200,000 a year, the companies say. With bonuses and stock grants, compensation can easily double in a few years. Senior economists who manage teams can make even more.