I have time series data for different countries and factors, e.g. birth rate for "Afghanistan" for years from 1972 up until 2007 (source).
Goal: Predict e.g. birth rate for 2008 and 2012
I am familiar with linear regressions, but need some help on how to work with time series data and predict future values.
Can you point me to examples or share code snippets?
Take a look at the statsmodels
Time Series Analysis module. Time series models are often based around autocorrelation, and the module has the standard univariate (for individual time series) AR(p)
and MA(p)
models, as well as the combined version ARIMA
that allows for unit roots
. You'll also find multivariate (for various interrelated time series) VAR
models.
And here's a time series
tutorial for statistical analysis and forecasting using pandas
and statsmodels
.