Adaptive order selection for autoregressive models