Adjusted AR(1) code to fix prediction issues