Detecting a change in regression: first-order optimality