Niall Ferguson, a Harvard history professor and author, apologized on Saturday for saying economist John Maynard Keynes was less invested in the future because he was gay and had no children.

Ferguson said his remarks at an earlier conference were “as stupid as they were insensitive.”

During a question-and-answer session after a speech at the Altegris Strategic Investment conference in Carlsbad, Calif., on Thursday, Ferguson was asked to comment about Keynes, an influential 20th century British economist who advocated government spending as a way to make up for lagging demand in a down economy.

Ferguson suggested that Keynes’ philosophy was shaped by his homosexuality, saying that since Keynes had no children, he wasn’t as invested in future generations as others might be.

On Saturday, Ferguson acknowledged the remarks — which were reported by the website of Financial Advisor magazine and other online publications — and said he “deeply and unreservedly” apologized.

“I should not have suggested . . . that Keynes was indifferent to the long run because he had no children, nor that he had no children because he was gay,” he said. “It is obvious that people who do not have children also care about future generations.”