refactoring regression/pa.cpp