The stock of DreamWorks Animation gained 5 percent early Wednesday following an upgrade by an analyst.

Based on the box-office results of “Madagascar 3,” the latest movie produced by Glendale-based DreamWorks, Benjamin Mogil at Stifel Nicolaus & Co. changed his recommendation to “hold” from “sell” in a note to investors.

“‘Madagascar 3’ is performing better than our expectations,” the note states. “The rating change does not alter our view that DreamWorks’s business still has material structural challenges. We continue to believe that digital distribution will largely be rental/subscription focused (VOD/SVOD) and not the ownership model (i.e., DVD) and that margins will consequently continue to be under pressure. We see a new distribution deal later this year as the next major catalyst.”

In three weeks since its release, “Madagascar 3” has sold an estimated $157 million in cinema tickets according to Bloomberg.

By midday, shares of Dreamwork traded at $18.21, a gain of 79 cents or 5 percent on the Nasdaq.