# Trend & Seasonality Determination in Time Series without looking at Graph [duplicate]

Most of the articles I have read describe determining Trends and Seasonal (TS) effects through rolling your eyes on Graphs. Graph is a nice visual representation, but I am looking a way in either Python , R or through any other way and discover TS. In short I want to feed my time series data to some program in backend and through output values I determine Trend is Yes/No or Seasonal effects exists in my time series Yes/No. Will really appreciate your ideas. Thanks

## marked as duplicate by mkt, kjetil b halvorsen, mdewey, Michael Chernick, Frans RodenburgJul 4 at 6:31

A test for trend can be tricky because we never really know if the non- stationarity is caused by the deterministic or stochastic component.

But basically if you want to test if you have a trend in a series, you can do a t-test on your $$B$$ in $$y_t = Bt + y_{t-1} + u_t$$ for example.

For seasonality, you can do the same, a t-test for $$Z$$ in $$y_t = Z y_{t-12} + u_t$$ for annual seasonality and monthly data. You can test too for monthly, semester, quarter, weekly patterns etc. depending on your data format.

But I can't really encourage you to do this: graphical analysis is always mandatory and you never can't use it. It's one of the master rules of the statistician: ALWAYS PLOT YOUR DATA!

My expert and well-trained eye gets tired and bored and thusly often fails to deliver subtlety... particularly when I am imbibing which can be caused by looking at tooooo many graphs. Eyeballing is an anachronistic approach which sometimes works when the data is simple and uncomplicated which is of course a rare event in my opinion. Good analysis can suggest to the eye where to look!

I enjoy looking at graphs after an expert/computerized analysis has identified both the regular and the irregular structure in the data.

Simple tests for trend/seasonality simply don't work as Gaussian Violations (arima structure, latent deterministic structure like pulses, seasonal pulses, level/step shifts and time trends have unpredictable consequences and "can be tricky to deal with". Simple tests can work BUT not too often in my experience.

Changes in parameters over time What methods are available for forecasting with a sample of the data suggesting too much data or changes in error variance over time also can't be ignored and need to be treated or ignored at your own peril.

The objective is to follow https://autobox.com/pdfs/ARIMA%20FLOW%20CHART.pdf culminating in a clear picture of https://autobox.com/pdfs/SARMAX.pdf. (I am one of the the developers of AUTOBOX and AFS https://autobox.com/capable.pdf.) SARMAX model can include trends and/or level shifts while also discriminating between stochastic seasonal structure AND seasonal dummies.

I can suggest that you reach out to software providers that have these goals and submit a number of possibly simulated time series and have them deliver to you the SARMAX equations for you to decide whether or not they have adequately separated signal and noise with their "expert eye".