harmonia forecasting model - nefarious671/sophia GitHub Wiki

Harmonia Forecasting Model – Enhanced Waveform-Based Forecasting with Fibonacci Constraints & Temporal-Agnostic Balancing

Step 1: Data Preparation

  • Import data from an Excel file.
  • Aggregate data monthly and normalize relative to a baseline (e.g., 2019 averages).

Step 2: Fourier Analysis (FFT)

  • Perform FFT on the entire historical dataset.
  • Identify major trend frequencies (low frequency).
  • Identify intermediate cycles (seasonal mid-frequency).
  • Isolate higher frequencies (noise and short-term cycles).

Step 3: Wavelet Analysis for Slope Estimation

  • Perform wavelet decomposition to achieve high-resolution frequency insights.
  • Derive short-term slope (rate of change) indicators from wavelet decomposition.

Step 4: Adaptive FFT-Wavelet Slope Integration

  • Calculate the slope of the FFT-based long-term trend.

  • Integrate wavelet-derived slope to adjust FFT trend directionally: [\text{Adjusted Slope} = \text{FFT Slope} + \beta \times \text{Wavelet Slope}]

  • Determining ( \beta ):

    • Optimize ( \beta ) by minimizing forecast errors (e.g., using historical RMSE or MAE).
    • Conduct sensitivity analyses to find stable ( \beta ) values that generalize well across different data periods.
  • Forecasting using adjusted slope:

    • Start forecast with the latest FFT-based trend point.
    • Iteratively apply the adjusted slope to produce subsequent forecast points: [Forecast_{t+1} = Forecast_t + Adjusted Slope_t]
    • This ensures forecasts reflect both long-term stability and recent directional momentum.

Step 5: Temporal-Agnostic Energy Balancing Adjustment

  • Construct a symmetric energy density function for past and future projections: [ E(t) = \frac{1}{2} \sum_{f} A_f^2 ]
    • Where ( A_f ) represents dominant frequency amplitudes extracted via FFT-Wavelet decomposition.
  • Identify phase-locking points from past wavelet slope transitions and ensure future forecasts reflect similar adjustments.
  • Apply a dynamic past-future constraint to forecast corrections: [ AdjustedForecast_{t+1} = FFTForecast + \beta \times (WaveletSlope_t - WaveletSlope_{t-p}) ]
    • Where ( t-p ) represents a past time-point with similar energy dynamics.
  • Introduce a temporal symmetry factor ( \lambda ) to weight past vs. future adjustments: [ AdjustedSlope_t = \lambda \times FFTSlope_t + (1 - \lambda) \times WaveletSlope_{t-p} ]
    • Higher ( \lambda ) → favors long-term FFT trend.
    • Lower ( \lambda ) → favors recent wavelet corrections.

Step 6: Fibonacci Retracement Constraint on Projection

  • Identify key Fibonacci retracement levels based on the last dominant wavelet-extracted high-low cycle.
  • Dynamically determine the appropriate constraint based on:
    • Steep trends: Apply a 0.382 constraint to prevent runaway projections.
    • Stable trends: Apply 0.5 or 0.618 retracement levels.
    • Reversing trends: Allow correction via 0.786 adjustment.
  • Adjust forecast slope weightings to remain within Fibonacci-restricted movement: [ AdjustedForecast_{t+1} = FFTForecast + \beta \times WaveletSlope \times F_{selected} ]

Step 7: Residual Correction

  • Calculate residuals from historical adjusted forecasts.
  • Apply residual correction to future forecasts based on recent deviations.

Step 8: Visualization

  • Plot historical data versus adjusted forecast clearly.
  • Display original FFT trend and wavelet-adjusted forecast separately for clarity.
  • Include a baseline reference (e.g., 100% of 2019).
  • Overlay Fibonacci retracement constraints to visualize forecast boundaries.
  • Highlight past-future energy balance zones to validate symmetry constraints.

Step 9: Validation and Iterative Tuning

  • Validate forecasts using performance metrics (MAE, RMSE).
  • Iteratively refine parameters (( \beta ), wavelet scales, FFT frequency cut-offs).
  • Continuously reassess ( \beta ) and ( \lambda ) to ensure adaptive responsiveness to recent data changes.

Mathematical Basis:

  • FFT: [ X_k = \sum_{n=0}^{N-1} x_n e^{-i2\pi k n/N} ]

  • Wavelet transform: [ W(a, b) = \frac{1}{\sqrt{|a|}} \int_{-\infty}^{\infty} x(t), \psi^* \left(\frac{t - b}{a}\right) dt ]

  • Slope adjustment: [ AdjustedSlope_t = FFTSlope_t + \beta \times WaveletSlope_t ]

  • Temporal-Agnostic Energy Balancing: [ AdjustedForecast_{t+1} = FFTForecast + \beta \times (WaveletSlope_t - WaveletSlope_{t-p}) ]

  • Fibonacci-Constrained Forecasting: [ AdjustedForecast_{t+1} = FFTForecast + \beta \times WaveletSlope \times F_{selected} ]