From ballistic to non-ballistic magnetoresistance in nanocontacts: theory and experiments