Improving self-training under distribution shifts via anchored confidence with theoretical guarantees