tidyverts / tidyverts/fabletools
proper interpretation of fabletools Fourier model report coefficients
Nobody has claimed this yet.
- Dominant language
- R
- Stars
- 98
- Forks
- 37
- PR merge metrics
- No merged PRs in 30d
Description
I could not find anywhere stated the proper interpretation of the C1, S1, C2, S2, C3, S3,... values in the report for the Fourier model fit from fabletools. At first I assumed they represented the real and imaginary harmonic coefficients (that is, the amplitudes of the cosine and sine components). But when I treated the values as such in a spread sheet, the resulting synthesis shape had little resemblance to the target data. However, the reported fitted values were a very reasonable close fit. I then fitted the same target data using the Octave (MatLab) fft() and got a very similar fit. Assuming the C and S values were the real and imaginary coefficients, the calculated magnitudes of the of the harmonics are quite similar to what Octave produced (as is the DC value, labeled as Intercept in the report), but the phases are dramatically different, accounting for the very different observed shape. So, in summary, the actual fabletools fitting seems just fine, but I am primarily interested in the numerical magnitude and phase values (for classification purposes, not for forecasting), which latter I do not understand how to calculate from the reported Cn and Sn values. Using atan2(Cn, Sn) does not yield anything remotely near to the fitted or Octave results. Just to illustrate by example the degree of difference in the first three components:

Because the actual fits and amplitudes are so close to being the same, I believe it's very unlikely to be due to a coding error, which leads me to believe it is somehow a problem with how to interpret the reported coefficients. Or is there some other variable somewhere that could affect the coefficient reporting but not the actual fitting?
For completeness I am including the details of my example:
R-4.1.2, Windows 64-bit, all packages obtained from CRAN within the last two weeks
Dec_18-data.txt



Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
No source file or test is named. Start by reproducing the attached example with the supplied data, code, and report, then trace the Fourier model's coefficient reporting and compare it with the reported fit. Done means the Cn and Sn magnitude and phase interpretation is established and documented clearly enough to reproduce the fitted series.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- r
- Domain
- data
- Issue type
- Documentation
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100