When someone yells at you, your gut reaction may be to yell back. But following your gut can get you in trouble, and in this case, may result in a damaged relationship. Instead, try responding to the outcome. When an unsettling event happens, pause and ask yourself: what is the outcome I want? Instead of reacting to the event, act in accordance with your desired outcome.
The person who yelled at you: do you want an improved relationship with him or do you want to make him feel as bad as you do? If it’s the latter, go ahead and yell back. If it’s the former, empathize with his anger and respond to the underlying issue in a calm manner.