Time series
Trends, seasonality, autocorrelation, resampling, and forecasting for measurements ordered in time.
Log the temperature of a lab once an hour for a month and you have 720 readings, but not 720 independent ones. If each hour keeps 90 % of the previous hour's deviation from the mean, the month tells you as much about the mean as 38 independent readings would, and the textbook standard error comes out more than four times too small. Time series start from that order in time. Hydrologists bring river discharge and groundwater levels, geophysicists tide gauges and seismometers, biologists heart rates and population counts, engineers the drift of a sensor or the load on a power grid. They want trends separated from seasonal cycles, gaps filled, irregular timestamps put on a common grid, and forecasts.
In Python, pandas holds the data: a DatetimeIndex gives a series its timestamps, resample moves it to another interval, rolling computes moving averages, and interpolate fills gaps. The models live in statsmodels, whose statsmodels.tsa module has the autocorrelation function acf, seasonal decomposition with STL, and ARIMA for forecasting. In Julia, the Dates standard library and DataFrames.jl hold time-stamped tables, and StatsBase.jl computes the autocorrelation with autocor. Never fit a straight line to such a series by ordinary least squares and quote the error of its slope: it is too small for the same reason as the error of the mean.
Start by plotting the series and its autocorrelation, since how fast the correlation decays decides everything after it. Then resample to a regular grid, separate trend and seasonal cycle, and forecast last. Describing a series by its frequencies, with spectra and filters, belongs to signal processing.
What belongs here
Measurements ordered in time and the questions that come with the order: trends and seasonal cycles, autocorrelation, resampling and gaps, smoothing, change points, and forecasting with ARIMA and similar models. Spectra and filters belong to signal-processing; reshaping and joining time-stamped tables to data-wrangling.
0 tutorials by type and language
| Python | Julia | |
|---|---|---|
| Concept | – | – |
| Tool | – | – |
| Recipe | – | – |
| Visualization | – | – |
| Project | – | – |