Heart rate variability (HRV) analysis technology based on an autoregressive (AR) model is widely used in the assessment of autonomic nervous system function. The order of AR models has important influence on the accuracy of HRV analysis. This article presents a method to determine the optimum order of AR models. After acquiring the ECG signal of 46 healthy adults in their natural breathing state and extracting the beat-to-beat intervals (RRI) in the ECG, we used two criteria, i.e. final prediction error (FPE ) criterion to estimate the optimum model order for AR models, and prediction error whiteness test to decide the reliability of the model. We compared the frequency domain parameters including total power, power in high frequency (HF), power in low frequency (LF), LF power in normalized units and ratio of LF/HF of our HRV analysis to the results of Kubios-HRV. The results showed that the correlation coefficients of the five parameters between our methods and Kubios-HRV were greater than 0.95, and the Bland-Altman plot of the parameters was in the consistent band. The results indicate that the optimization algorithm of HRV analysis based on AR models proposed in this paper can obtain accurate results, and the results of this algorithm has good coherence with those of the Kubios-HRV software in HRV analysis.