For four decades now, long before the current wave of corporate takeovers shook Wall Street, J. Peter Grace, the 72-year-old head of W. R. Grace & Co., has been busy building a highly diversified, $6 billion conglomerate, buying and selling companies and transforming the financial empire he inherited.

The company was founded in 1854 by his grandfather, William R. Grace, and originally was built on trade in guano -- the seabird droppings found off the coast of Peru that are a key ingredient in fertilizer.

At the close of World War II, W. R. Grace was a giant in South America with interests in shipping, mining, finance and much more, but Peter Grace wanted a domestic company with more stability and a high growth rate. As a result, in 1954, he bought Dewey Almy Chemical Co. and started a vast specialty-chemical business that is perhaps the most diverse U.S. conglomerate today.

About 60 percent of Grace's profits are in specialty chemicals such as sealing compounds, metal-working lubricants, silica gels and industrial catalysts, but the conglomerate also owns agricultural chemicals, natural resources, 860 restaurants, 325 home center stores nationwide, and a small but growing number of high-technology and health-care companies.

W. R. Grace has more than 2,500 facilities in 47 states and 42 countries, and it employs 80,000 people worldwide. Peter Grace says he still logs 100-hour weeks, spending 70 hours on company business and the remainder on pet projects such as the Grace Commission's plan to cut federal spending, a private effort to point out potential savings.

The Grace credo is simple. "I think you have to change your spots to survive," Grace says emphatically. "I believe in changing spots and making money." And he's done just that.

However, some think he might do better, and rumblings about the need for change now are being heard inside and outside the company. Stock analysts long have carped about the dizzying array of ventures the company has bought (150) and sold (75). They credit Grace with a great record in specialty chemicals, but wonder what his company is doing buying so many businesses in disparate fields such as retailing and restaurants. Jack Henry, a chemical analyst at E. F. Hutton, said, "As far as theory goes, it makes sense, but it hasn't worked out too well. The culture of a chemical company is different from retailing."

Coming off a relatively good year in 1984, when net income and earnings per share were above 1983 levels, the first nine months of 1985 looked dismal, with net income at $102 million compared with $141.6 million last year and net earnings at $1.96 versus $2.73 at this juncture last year. And overall, sales are up just slightly over last year to date.

Declines have been especially severe in agricultural chemicals as the farm crisis and the high dollar have cut fertilizer sales fallen by 7 percent from their 1984 levels. Sales of natural resources also are off for the first nine months of 1985, by 12 percent, partly because of lower oil and gas prices. And the retailing sector, after rapid expansion in the last 10 years, has been hit by tough competition and price cutting in the Sun Belt, forcing Grace to close some stores in Florida. Executives say more may be shut. The Grace restaurant chain, which consists of El Torito and about a dozen other smaller chains, has emerged as the nation's seventh-largest restaurant group.

The future direction of Grace became more clouded last Wednesday when the largest Grace shareholder, the Flick Group of West Germany, which holds 26 percent of the stock, was acquired by Deutsche Bank of West Germany. Flick holds three seats on the board of directors and long has been a strong supporter of Peter Grace. Analysts in Wall Street have contended that the Flick holdings were an insurance policy against a hostile takeover or a restructuring, and a Grace executive said Flick was a "bulwark against the takeover."

Grace and Deutsche Bank officials met in New York and issued a statement that they would work together to reach an acceptable plan for disposing of the 15 million shares of Flick stock, which analysts say could sell for about $600 million. Further, Grace officials noted that they have a right-of-first-refusal agreement.

Several stock analysts said they view the Flick sale as a positive development for Grace, the first step in making some overdue changes. Many of these same analysts recently have pointed to problems in agricultural chemicals and natural resources and retailing as elements calling for change. Peter Grace also is talking about those sectors of the company in a somber note these days. "We've had such big losses in agricultural chemicals the last year, and energy services are in the dumps, with natural gas prices down," Grace said.

Grace executives have responded with a nod or two in the direction of their Wall Street critics and signs that W. R. Grace may change again to improve immediate earnings and to bolster the company's long-term position. Grace executives say next year will feature a "general corporate slowdown" with a "cash conservation program designed to maximize profits." One exception will be the high-technology acquisitions on which Grace is betting heavily for its future growth. Executives say biotechnology and medical services are compatible with Grace's specialty-chemicals business.

Charles H. Erhart Jr., the vice chairman and heir apparent to Peter Grace, said the company wants to have more "businesses where we have control of our destiny." There have been some mistakes, he said. "We got carried away in the late '60s and early '70s with natural resources . . . We made a lot of money . . . We put more money into natural resources than, in retrospect, we should have. We should have stopped about three years before the balloon burst." Erhart said that 1981 and 1982 marked a turning point for the company when it realized it had become too dependent on commodities, basic products such as oil. Grace now is looking for a better mix in its businesses.

Peter Grace said he sees the problem similarly and noted that restaurants offer more security. "In the restaurant business, you have full control of all results and profitability, unlike in the commodities business, where you have no control and the price wiggles up and down."

A number of signs indicate that Grace has begun cutting back in commodities and expanding further in the consumer and high-tech arenas:

*Early this year, Grace sold some of its oil and gas properties to Exxon Corp. for $126.5 million, following a similar sale in 1984 to Shell Oil Co. for $50 million.

*Grace completed an initial public offering of common stock in its subsidiary, Herman's Sporting Goods Inc., the country's largest sports retailer with 115 stores, leaving Grace with a 56 percent interest in the company. In late 1984, Grace also spun off 26 percent of its El Torito Mexican restaurant chain, and executives say more public offerings are likely.

*Grace will buy 53 restaurants from General Mills Inc. and acquire Hungry Tiger Inc., which has restaurants in Arizona, California and Nevada, this year.

*Grace purchased Chomerics Inc., a high-tech company that makes materials to shield electronic equipment from electromagnetic interference, and also makes electronic chemicals that Grace executives say could boost their specialty chemical business.

*In 1984, Grace formed a joint partnership called Agracetus with Cetus Corp., a California-based gene splicing firm, to develop new techniques in animal and plant genetics to increase yields; and Grace also purchased a 49.9 percent stake in National Medical Care Inc., the leading operator of kidney dialysis centers.

But in light of the Flick sale, Grace seems likely to speed its efforts to boost short-term earnings and maximize profits, because it no longer can depend on Flick's backing, analysts say. Given the current financial strains, Grace would be hard pressed to buy back the Flick stock, analysts note.

Several Wall Street analysts contend that the Deutsche Bank purchase will spur a restructuring of Grace that they said they believe is overdue and that could benefit the company by boosting its stock from its $40-a-share level to between $60 and $70 a share, which they say is closer to the real value. The stock closed Friday at $44.25, up 50 cents.

Stan Deutsch, a chemical analyst at First Boston Corp., said, "I see it as a big positive for Grace . . . I think it may be the first stage of reorganization."

Peter Grace, however, with his knack for juggling companies around, probably has other ideas up his sleeve. Asked about the possible takeover before the Flick sale was announced, he declared that he was always worried about a takeover. But Grace added that the company has "never changed its policies because of a takeover threat."