It's a long time since I have thought about this one but I believe that the deviation of the compass is affected by pitch attitude - don't ask me why!
Perhaps best to ask the question on Tech Log - I am sure there is some boffin out there who knows the answer.