There has to be a formula for piston aircraft, but I'll give you an example of turboprop logic:
SHP= Torque x Np x .00019
Therefore, the higher the torque (or MP) and the higher the Np (prop RPM), the higher horsepower output of the engine. There would also be different combinations that could result in the same horsepower output.
Example:
SHP= 1000 x 2200 x .00019 = 418SHP
SHP= 1100 x 2000 x .00019 = 418SHP
SHP= 1222 x 1800 x .00019 = 418SHP
As UALT38 said, it's all about noise, fuel consumption, and temperature. What I've shown here, is there are different ways to get equal performance, but each way has a different drawback.