President Reagan has spent much of his public career emulating the style and cheerful confidence of his first political hero, Franklin D. Roosevelt. Now, however, he is trying to dodge the legacy of Roosevelt's luckless presidential predecessor, Herbert Hoover.

"The fundamental business of the country, that is production and distribution of commodities, is on a sound and prosperous basis," Hoover said after the 1929 stock market crash that signaled the advent of the Great Depression.

" . . . The underlying economy remains sound," said Reagan after the record stock market plunge last Monday. "We are in the longest peacetime expansion in history."

Reagan has always found it difficult to accept realities that clash with cherished dogmas, even though the dogmas themselves have changed over time. He once believed, for instance, in the Republican commandment that governments should balance their books. But in pursuit of the presidency, Reagan accepted the new supply-side religion and followed the will-of-the-wisp of endless tax cuts.

Reagan's new theology was denounced as "voodoo economics" by George Bush during the 1980 campaign. Another rival, independent candidate John B. Anderson, observed that the only way Reagan could simultaneously slash taxes, reduce domestic spending and swell the defense budget was with "mirrors."

With an optimism that would have done credit to FDR, Reagan brushed aside these candidates and their contentions and swept to victory over them and President Jimmy Carter. Reagan clung to his new beliefs during the difficult recession of 1981-82, which he conveniently blamed on Carter, and was rewarded with the longest period of peacetime prosperity in the last half-century. When the recovery began, he boasted that "they don't call it Reaganomics anymore."

It is a sign of the troubled times that congressional critics are once more crying, "Reaganomics." Their own credentials for finger-pointing are dubious, in view of the congressional contributions to the deficit, but Reagan was quick to take credit for the recovery and he cannot escape blame for the crash. His advisers recognize that he will not get by with Hooverish statements about the soundness of the economy.

The unanswered question is whether Reagan is up to dealing with the shambles he helped create. Reagan's saving grace usually has been a desire to succeed in office and a willingness to change policies and put prejudices aside to do it. In this he resembles Roosevelt, who ran on one platform and enacted another and was willing to try almost anything to see if it worked.

Governor Reagan and President Reagan, if not candidate Reagan, also have been flexible. In California, Reagan fought income tax withholding as a matter of principle, than dropped his opposition to get his budget enacted. President Reagan, in his first term, accepted Social Security changes and tax increases he initially opposed.

Since he won reelection on the empty platform of "morning again in America," Reagan, now 76, has become notably more rigid and stubborn. Like Hoover after the crash, he has ignored danger signals and closed his mind to arguments. Until the stock market plunge, aides were afraid even to raise the idea of a tax increase, knowing that they would be rejected out of hand.

Ironically, Reagan's inaction of the past two years occurred when he could have accomplished a lot by yielding very little. Because of the strength and duration of the recovery, the gross national product has grown tremendously. This means that Reagan might have achieved significant deficit reductions by agreeing to small tax increases as the price for the domestic spending cuts he has been demanding of Congress. Everyone could have claimed victory, and the deficit would have tumbled, perhaps averting the market collapse.

Instead, Reagan celebrated the recovery and wasted the advantage it had provided. He has now lost the luxury of continued shortsightedness and must demonstrate that he accepts the portent of the market and is willing to become the Great Compromiser again. To put it another way, he can avoid the Hoover legacy if he is willing to behave like FDR.

Reaganism of the Week: Asked his analysis of the market crash at his news conference last Thursday, the president said: "I think this was a long-overdue correction, and what factors led to its kind of getting into the panic stage, I don't know."