The article considers the Yule-Walker estimator of the autoregressive coefficient based on the observed time series that contains an unknown trend function and an autoregressive error term. The trend function is estimated by means of B-splines and then subtracted from the observations. The Yule-Walker estimator is obtained from the residual sequence. Asymptotic properties of this estimator are derived. The performance of the estimator is illustrated by simulation studies and real data analysis.