Connecting stellar mass and star-formation rate to dark matter halo mass out to z ∼ 2