added correct r2 calculations and updated the doctest