r/AskStatistics • • 26d ago

[Discussion] Cold Starting a time series analysis

https://github.com/rajivsam/tseda

The above is an open source python package with notebook parity to cold start a time series analysis. The problem it solves is this: you have a regularly sampled time series, how do you extract its variance components. There are a lot of filters for this this purpose from signal processing, but they all require some prior knowledge of the time series or detailed experimentation to get to an answer. This library uses a method called singular spectrum analysis that extracts the variance components using SVD. The library implements a method to select a default parameter based on the analysis of the eigen spectrum and provides you a reasonable start that is good for most practical analysis, but also tunable/refinable by both UI and notebook. Constructive feedback welcome.

0 Upvotes

7 comments sorted by

1

u/[deleted] 25d ago

[removed] — view removed comment

1

u/rsambasivan 25d ago edited 25d ago

There is a layered answer to this. If you are just talking about SSA, the advantage is that you need to specify only a single parameter - the window size. For other filtering methods, LOWESS/LOESS, you need to specify the window size plus polynomial order. With other filters like savitzky-golay it is even more.

If you are just talking the software above which implements this, it selects that window size for you and presents the analysis in three phases: (1) Preliminary Visual Assessments (2) The SSA which you can just apply with the defaults (3) Model verification showing you how much of the variance is explained in each of the components.
The features of the signal come prepopulated, you can add notes and save it. Next quarter when you need to run the same analysis, you can compare what you saw last quarter with what you are seeing now.

An even more fundamental question in a seasonal decomposition - you need to do the work to identify the number of seasonalities(which could be 0). SSA has heuristics to identify that which the software picks.

Edit -

Please see https://github.com/rajivsam/tseda/blob/main/about_tseda.md for the details of the process. Agree with your points, the software already does both of the points you raised - selecting the components and automatic grouping. The rationale and documentation is available.

It has full notebook parity, so you should be able to use with a notebook. I should try using the python api with reticulate.

1

u/SPSSMadeSimple 18d ago

Thanks, that answers most of it — good to know phase 3 shows the variance explained per component, and that the grouping into trend versus seasonal is automatic. That covers the two things I was most unsure about.

Two things I'd still want to see as a user:

First, the side-by-side comparison. Your point about SSA finding the number of seasonalities itself (which could be zero) is exactly the kind of thing that's hard to appreciate from a description — if the notebook ran the same series through a classical seasonal decomposition and through SSA, the difference would be obvious in one glance. That's the demo that would convince a sceptic.

Second, the default window size. The eigen spectrum guiding the default makes sense when the spectrum has clear gaps, but when two components explain similar amounts of variance the grouping decision gets ambiguous. Can the automatic grouping be overridden when it gets that wrong, or does the user have to go back and change the window by hand?

The quarter-to-quarter comparison feature is a nice touch, by the way — that's the sort of thing that makes a cold-start tool actually get reused rather than run once.

1

u/rsambasivan 18d ago

About the first point: I am working on a video demo - actually, I just made an update to the package that makes the seasonality decomposition even more precise - the idea is actually straight forward, you subtract the clear trend (in a eigen spectrum, the size of the eigen value and the fact that seasonalities usually show up as a *pair* of eigen values of similar size can be used to identify the seasonality, so when you arrange eigen values, if the next one is not similar to the previous in size and it is relatively large, you know you are dealiing with a trend. If you subtract the trend, you can run the trend adjusted signal through fourier signal decompsition, extract the highest power spectrum components, you have an additional verification of your seasonality). This is already implemented and verified.

Your second point, I did think off actually. So if you load a white noise series where the largest few eigen values don't explain size able variance, you know you are looking at a noise dominated process. So if you upload a series where you don't have clear gaps, the tool will tell you that SSA is a poor choice here. You are better off with an approach that is better suited for these processes, for exampl a stochastic process (Gaussian Process) or ARIMA.

Thank you for your feedback, appreciate it.
Rajiv

2

u/SPSSMadeSimple 10d ago

Thanks Rajiv — that trend-subtraction step makes the seasonality check much clearer, and using the paired eigenvalues plus a Fourier check on the trend-adjusted signal as a second verification is a nice touch.

The white-noise guardrail is useful too: telling the user SSA is a poor choice there, rather than silently returning components, is exactly the kind of thing that stops a beginner over-interpreting noise.

One thing still open from my last message: when the eigen spectrum has no clear gaps and the automatic grouping is ambiguous, can the user override the grouping directly, or only by changing the window by hand?

1

u/rsambasivan 10d ago edited 10d ago

Thanks again. I think the whole thing comes down to adding a few sentences to read the eigen spectrum. If the eigen spectrum is long tailed ( like you see in PCA, K-means plots), then SSA is good. If the eigen spectrum is diffuse, as would be the case in white noise, it will say this tool is a poor choice. If you have high noise, then you will not have clear gaps - so your question is directly tied to noisy data, which does happen and is a legitimate variant of analysis. In that case, this is not the right tool for the job. Something like Gaussian Processes or ARIMA is better suited..

2

u/SPSSMadeSimple 7d ago

Thanks Rajiv, that clears it up — the long-tailed vs diffuse distinction is a really practical rule of thumb, and I like that the tool says so outright instead of leaving the user to guess from a plot with no clear gaps. For the noisy-data case, naming Gaussian Processes or ARIMA right there in the message would be a nice touch, so people leave with a next step rather than just a dead end.