To test for stationarity in a time series, you primarily want to determine if the statistical properties of the series, like the mean and variance, are constant over time. A stationary time series will not show trends or seasonal effects, making it easier to model. There are several methods to check for stationarity, with the most common being visual inspection, the Augmented Dickey-Fuller (ADF) test, and the Kwiatkowski-Phillips-Schmidt-Shin (KPSS) test.
Visual inspection is a simple starting point. You can plot the time series and look for patterns such as trends or seasonality. If you notice a trend moving upward or downward, it indicates non-stationarity. Additionally, plotting the rolling mean and rolling standard deviation can help visualize changes over time. If both remain relatively constant, this suggests that the series might be stationary. However, this method is subjective and may not be reliable for more complicated series.
For a more formal analysis, the ADF and KPSS tests are widely used statistical tests. The ADF test checks for the presence of a unit root, which indicates non-stationarity. If the test statistic is less than the critical value, you reject the null hypothesis and conclude that the series is stationary. Conversely, the KPSS test operates under the opposite hypothesis; it assumes that the series is stationary and checks if that assumption can be rejected. If the test statistic exceeds the critical value, you reject the null hypothesis, suggesting the series is non-stationary. Using both tests in conjunction can give a clearer picture of the stationarity of your time series data.