Seasonality Detection
Detect and analyze seasonal patterns in your time series data.
anofox_fcst_ts_detect_seasonality
Detect if a series has seasonal patterns at a specific period.
Parameters
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
values | DOUBLE[] | Yes | - | Time series values |
period | INTEGER | Yes | - | Period to test |
Output
Returns BOOLEAN indicating if seasonality is detected.
Example
SELECT anofox_fcst_ts_detect_seasonality(
LIST(sales ORDER BY date),
7 -- period to test
) as is_seasonal
FROM sales_data;
Use when:
- Exploring data
- Deciding on model
- Validating forecast assumptions
anofox_fcst_ts_analyze_seasonality
Detailed seasonality analysis with strength metrics and detected periods.
Parameters
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
table_name | VARCHAR | Yes | - | Source table |
group_col | VARCHAR | No | NULL | Group column |
date_col | VARCHAR | Yes | - | Date column |
value_col | VARCHAR | Yes | - | Value column |
params | MAP | No | MAP | Configuration |
Output
Returns STRUCT containing:
| Field | Type | Description |
|---|---|---|
detected_periods | INTEGER[] | All detected seasonal periods |
primary_period | INTEGER | Most significant period |
seasonal_strength | DOUBLE | Strength of seasonality (0-1) |
trend_strength | DOUBLE | Strength of trend (0-1) |
Example
SELECT * FROM anofox_fcst_ts_analyze_seasonality(
'sales_data',
NULL, -- group_col
date,
sales,
MAP{}
);
Use when:
- Multiple seasonality suspected
- Hourly/sub-daily data
- Complex patterns
Seasonality Analysis Workflow
-- Step 1: Quick check for weekly seasonality
SELECT anofox_fcst_ts_detect_seasonality(
LIST(sales ORDER BY date),
7
) as has_weekly_pattern
FROM sales_data;
-- Step 2: Detailed analysis if seasonality detected
SELECT * FROM anofox_fcst_ts_analyze_seasonality(
'sales_data',
NULL,
date,
sales,
MAP{}
);
-- Step 3: Use findings to select appropriate model
-- High seasonal_strength → Use AutoETS or HoltWinters
-- Multiple periods → Use AutoTBATS or MSTL
Interpretation Guide
| Metric | Value | Interpretation |
|---|---|---|
seasonal_strength | > 0.6 | Strong seasonality, use seasonal models |
seasonal_strength | 0.3 - 0.6 | Moderate seasonality |
seasonal_strength | < 0.3 | Weak or no seasonality, try non-seasonal models |
trend_strength | > 0.6 | Strong trend, consider trend components |
trend_strength | < 0.3 | Little trend, simpler models may work |