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 –
filterwith convolution method - Differencing filter –
diffwith lag and differences arguments - Simulation –
arima.simfor AR(p), MA(q), and ARMA(p,q) models - Auto-correlation – ACF with
acf, PACF withpacf - Parameter estimation –
arfor AR models,arimafor ARMA models - Model comparison –
AICcfor comparing fitted models - Forecasting –
predictand plotting predicted values with confidence intervals