Legendary investor Warren Buffett is viewed by many as one of the greatest investors of all time. The large conglomerate he runs, Berkshire Hathaway (BRK.A 0.36%) (BRK.B 0.21%), has beaten the broader market by a wide margin since Buffett took over the company in 1965 all the way to 2021.

While Buffett is now 91 years old, he still seems to have the magic touch. Berkshire Hathaway's stock is down only about 5.2% this year, which is widely beating the S&P 500's roughly 22% loss as of this writing, putting the broader benchmark index into bear territory.

Part of this is due to investments Berkshire made in its roughly $328 billion-plus equities portfolio. Here are three stocks in the Berkshire portfolio that crushed the stock market so far in 2022.

1. Occidental Petroleum

Berkshire began buying shares of the Texas-based oil and gas producer Occidental Petroleum (OXY -1.26%) at the beginning of 2022 and really hasn't stopped since. Occidental made up more than 4% of Berkshire's total portfolio and Berkshire owned close to a 21% stake in the company at the end of the second quarter.

We already know Berkshire's position increased in Occidental because Berkshire recently made further disclosures about purchasing additional shares. At this point, many think Berkshire might eventually acquire Occidental.

The stock was one of the biggest winners this year and is now up about 149% for the year. That's largely thanks to Russia's ongoing invasion of Ukraine, which led the U.S. and many other European countries to ban the import of Russian oil. This drove up oil prices in the U.S. and made a domestic producer of energy much more valuable.

Higher oil prices enabled Occidental to generate profits it can use to reduce its debt, pay its dividend, and repurchase stock. Management believes it can continue to pay the current dividend as long as U.S. oil prices stay higher than $40 per barrel, which isn't a problem right now. The plan is also to use profits to invest in its more environmentally friendly carbon capture and sequestration business. A recession could bring down the price of oil, but Buffett seems to like the risk-reward setup here.

2. Kraft Heinz

The multinational food and beverage company Kraft Heinz (KHC 0.85%), which produces many recognizable food brands such as Heinz Ketchup and Oscar Mayer, has been considered one of Buffett's biggest investing mistakes.

In 2013, Berkshire teamed up with 3G Capital to acquire Heinz for $23 billion. In 2015, the company merged with Kraft to become Kraft Heinz. The merged company started trading with a share price of about $71. Today, the stock trades below $38 per share. But Buffett hasn't given up; Berkshire still owns a roughly 26.6% stake in the company at the end of the second quarter.

The investment looks better this year, though, with the stock up about 5.8% this year. The company sells food and drink brands all over the world in 200 countries and as such ran into supply chain issues brought on by the pandemic that still seem to be challenging international companies. But in the third quarter, the company managed to make some hefty price increases on its products without losing too much sales volume. Kraft Heinz also pays an annual dividend yield of more than 4%. The company does face recessionary risks but still trades below pre-pandemic levels.

3. Coca-Cola

An iconic beverage brand, Coca-Cola (KO 0.78%) stood out in Berkshire's portfolio this year -- it's down only about 0.7%, which is much better than the broader market. 

Coca-Cola in recent years shifted to more of a franchise model that is less focused on being a bottling business, and more concentrated on having a strong slate of brands and then franchising those brands so that others do the bottling and distribution. The strategy seems to be working, accelerating revenue growth in recent years.

Furthermore, having an iconic brand in times of high inflation and with a recession looming can be a huge advantage because customers are less likely to abandon the company.

It also makes it easier to pass price hikes on to consumers, which Coca-Cola did successfully in the third quarter without losing sales volume. The company recently raised its full-year guidance, showing that it can navigate the difficult environment well.