added AR(1) trend detection function