A U.S. recession probably won't happen for another two years, and in the meantime stocks are a good bet, according to closely followed Credit Suisse analyst Andrew Garthwaite.

"We conclude that a US recession is unlikely until Q3 2020," Garthwaite wrote in a note to clients Friday. "Remain overweight equities."

Typically, an inverted yield curve, when longer-term interest rates dip below shorter-term rates, and full employment with wage growth at 3.5 percent happen about a year before a recession. Garthwaite predicted those phenomena wouldn't hit the U.S. until halfway through 2019.

Based on that timing and historical behavior, stocks could keep rising until 2020. In the past 50 years, with the exception of 1987, when the equity risk premium hit a very low 1 percent, "equities have never peaked more than 13 months ahead of a recession," he said.

High volatility is also here to stay, meaning credit is riskier than equity, Garthwaite said. He told clients to sell and "remain cautious" on highly leveraged companies with low free cash flow, such as GlaxoSmithKline.

But the Credit Suisse analyst is not bullish on all sectors.

Garthwaite suggested staying underweight non-financial cyclicals such as consumer discretionary, materials and industrials, calling them "expensive" and "over-owned." He instead favors lowly leveraged defensive sectors such as consumer staples, utilities, health care and telecoms.

"At this stage of yield curve flattening, normally software and energy are the best performing sectors, while consumer staples and utilities perform the worst," Garthwaite said.