This cheat sheet covers the key steps of time series analysis in R using base functions: plotting time series, applying linear and differencing filters, fitting AR and ARMA models, and forecasting future observations with confidence intervals.

What’s covered#

  • Plot time series – tsplot, plot(ts(...)), ts.plot
  • Linear filter – filter with convolution method
  • Differencing filter – diff with lag and differences arguments
  • Simulation – arima.sim for AR(p), MA(q), and ARMA(p,q) models
  • Auto-correlation – ACF with acf, PACF with pacf
  • Parameter estimation – ar for AR models, arima for ARMA models
  • Model comparison – AICc for comparing fitted models
  • Forecasting – predict and plotting predicted values with confidence intervals