Deviation in a magnetic compass is caused by the