Inflation crossed the 2% target in March 2021 and it kept rising, but the Federal Reserve failed to take action for almost a full year, insisting that transitory factors were to blame. That was a costly miscalculation in hindsight, so the Fed is now trying to make up for lost time by raising interest rates at their fastest pace in four decades.

Unfortunately, many experts believe central bank officials will tighten monetary policy too aggressively, which could tip the U.S. economy into a recession. That fear has made the stock market sink like a stone this year. In fact, the broad-based S&P 500 delivered its worst first-half performance since 1970, and the index has now declined for three consecutive quarters.

Given the uncertain state of the economy, is it safe to invest in the stock market right now? Consider this advice from Warren Buffett.

A downward trend red arrow is overlaid on a background of $100 bills.

Image source: Getty Images.

"Be greedy when others are fearful."

Buffett has turned his uncanny ability to pick winning stocks into a multibillion-dollar fortune, and his success has inspired countless others. Investors pour over his shareholder letters each quarter in search of actionable insights, and thousands of fans attend Berkshire Hathaway's annual meeting each spring to hear his thoughts on business and the economy.

Buffett has undoubtedly provided a lot of good advice over the years, but a few pearls of wisdom are particularly relevant right now. For instance, in his 2013 letter to shareholders, Buffett said, "A climate of fear is your friend when investing; a euphoric world is your enemy." That statement hits on the irrationality of human nature. People get too optimistic in good times and too pessimistic in bad times. As a result, the stock market flies too high during bull markets, and sinks too low during bear markets.

However, anyone who understands that quirk of human nature can use it to their advantage. To borrow a line from Buffett, investors should "be greedy when others are fearful." That means right now is an excellent time to buy stocks. Many businesses that are brimming with long-term potential have seen their valuations slashed during the current downturn.

A long-term mindset increases the odds of profitability

In his 1993 letter to shareholders, Buffett included a quote from his mentor Benjamin Graham: "In the short run, the market is a voting machine [...] but in the long run, the market is a weighing machine." That analogy explains the importance of a long-term mindset. Individual stocks can rise and fall without rhyme or reason in the short term, but good businesses will create value for shareholders given enough time.

More broadly, the entire stock market is prone to volatility when measured in weeks or months, but investors who think in terms of years and decades are much more likely to profit. For instance, the rolling 20-year return of the S&P 500 has been positive for the past 103 years, according to Crestmont Research. In other words, if you had bought and held an S&P 500 index fund for at least 20 years at any point in the past century, you would have made money. 

I will close with one last pearl from Buffett: "A market downturn doesn't bother us. It is an opportunity to increase our ownership of great companies with great management at good prices."