Fix for case where row has no non zeros
Deal with sppy matrices
Fix for computing r in model selection