Aggregate & Window Functions
GROUP BY and OVER patterns for complex analyses.
GROUP BY Pattern
SELECT
group_id,
result.coefficient[2] as effect
FROM data
GROUP BY group_id
APPLY anofox_statistics_ols_agg(y, ARRAY[x1, x2]);
All models available with _agg suffix:
anofox_statistics_ols_agganofox_statistics_ridge_agganofox_statistics_wls_agganofox_statistics_rls_agganofox_statistics_elastic_net_agg
Window Functions
SELECT
date,
result.coefficient[2] as rolling_effect,
result.r_squared
FROM data
ORDER BY date
WINDOW w AS (ROWS BETWEEN 60 PRECEDING AND CURRENT ROW)
APPLY anofox_statistics_ols_agg(y, ARRAY[x1, x2]) OVER w;
Window Types:
ROWS BETWEEN N PRECEDING AND CURRENT ROW- RollingROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW- Expanding
Diagnostic Aggregates
All diagnostic functions available with _agg:
anofox_statistics_vif_agganofox_statistics_normality_test_agganofox_statistics_residual_diagnostics_agganofox_statistics_information_criteria_agg
Next Steps
- Utilities — Helper functions
- Grouped Analysis Guide — Examples