Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

proper interpretation of fabletools Fourier model report coefficients #345

Open
bhonz opened this issue Feb 1, 2022 · 0 comments
Open

Comments

@bhonz
Copy link

bhonz commented Feb 1, 2022

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:
table

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

code

report

Dec_18-plot

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant