RainbowStats · Learning through model comparison
Does seasonality change the relationship?
Compare ordinary regression with the same model plus sine and cosine predictors.
Try the residual-spectrum comparison
Fit monthly housing starts on building permits from January 2000 through December 2024. Run these two lines to display the comparison directly.
Housing=SERIES_BETWEEN(LIST(HOUSTNSA,PERMITNSA),20000101,20241231) Fit=SEASONAL_REGRESSION(Housing,"spectrum",4)
In “Compare residual cycles”, read across each row for Durbin–Watson, lag-one residual autocorrelation and holdout RMSE. Row 0 is the baseline. Rows 1 through 4 add sine/cosine pairs in order of residual spectral power. Each of the four expanding training windows finds its own frequencies. Holdout predictions use observed permits.
To inspect two pairs, append Model=EX(Fit,"model:2") for the regression
or ACF=EX(Fit,"acf:2") for the residual autocorrelation chart.
Other spectrum extracts include summary, coefficients, periods and validation.
Try a fixed period on the same sample
Fixed=SEASONAL_REGRESSION(Housing,8) Results=EX(Fixed,"summary")
Here 8 specifies an eight-month period. With the default of one harmonic, the model adds one sine/cosine pair and compares the fit with the baseline on the same dates.
Why both cosine and sine?
A pair allows the seasonal peak to occur anywhere in the cycle. One harmonic gives one smooth annual wave; two add a half-year wave. Individual coefficient significance depends on the time origin; consider the pair jointly.
Period
Optional period defaults to an annual cycle: 12 for monthly, 4 for quarterly, 365.2425/7 for weekly, 365.2425 days for daily or unrecognized frequency. Annual data require an explicit multiyear period. Optional harmonics default to 1, must be integers from 1 to 20, and require period greater than twice the harmonic count.
Time uses UTC dates relative to 1970, not compressed row positions. Monthly and quarterly coordinates use calendar bins. Daily/weekly coordinates use elapsed time. Existing alignment may convert frequency; inspect the aligned frequency before choosing the period.
Read the comparison
Shared coefficients appear side by side with seasonal-minus-baseline differences. Added terms are shown separately. These differences are descriptive, not significance tests. R-squared normally rises when predictors are added; adjusted R-squared and AIC/BIC account for model size. Neither is proof of better forecasts or causality.
DW near 2 is consistent with little first-order residual autocorrelation. A move toward 2 can accompany a better seasonal specification, but DW alone cannot determine which model is correct. Inspect residual plots and autocorrelation; HAC inference uses retained-row lag counts.
Fixed-period extracts
| Key | Result |
|---|---|
| regression | Baseline RegressionOperator |
| seasonalregression | Augmented RegressionOperator |
| harmonicAnalysis:N | Compare baseline OLS and each count through N on the same sample. Includes coefficients, R², adjusted R², DW, residual standard error, AIC and BIC. The lowest BIC row is highlighted. Example: EXTRACT(Fixed,"harmonicAnalysis:4") with period 12. N may be zero and must satisfy the model’s period and sample limits. |
| comparison / summarytable | HTML coefficient comparison |
| summary | Fit metrics and interpretation |
| slideshow | Educational slides and model diagnostics; default JSON output |
| data / seasonaldata | Baseline / augmented aligned lists |
baseline=EXTRACT(Fixed,"regression") seasonal=EXTRACT(Fixed,"seasonalregression") EXTRACT(seasonal,"hac")
Keep predictors few relative to observations; use several cycles when possible. Constant or duplicate predictors and aliased seasonal terms can make a fit singular. This comparison does not select a model automatically or provide a test of coefficient differences.
Available extracts
Save the command result in a variable, then use EXTRACT(result, "key"). Availability can depend on the input form and fitted model.
regressionseasonalregressioncomparisonharmonicAnalysis:Nsummarytablesummaryvalidationcoefficientsperiodsmodel:Kacf:Kslideshowdataseasonaldata
In indexed patterns such as beta:n, replace n with the required index.