The problem comes when I was trying to calculate correlation in group.
When I have multiple groups I need to do something like this for the numerator:
sum