The formula is (HR*13+(BB+HBP)*3-K*2)/IP + a league factor that is usually between 3 and 3.5. It is a very good tool to help understand what a pitchers ERA should really be.