Analysis of Mismatched Estimation Errors Using Gradients of Partition Functions