--- warning: DO NOT CHANGE THIS MANUALLY, THIS IS GENERATED BY https://github.com/duckdb/community-extensions repository, check README there title: anofox_statistics excerpt: | DuckDB Community Extensions A DuckDB extension for statistical regression and inference in SQL - OLS, Ridge, Elastic Net, LARS/LassoLars, WLS, recursive least squares, robust estimators (Huber, RANSAC, Theil-Sen), GLMs (Poisson, Negative Binomial, Binomial, Tweedie, Gamma, Logistic) with offset support, mixed-effects/hierarchical GLMs with random slopes and crossed/nested factors, AFT survival regression, explicit priors with Laplace intervals, empirical-Bayes shrinkage, and time-series regression, all with full diagnostics and inference. extension: name: anofox_statistics description: A DuckDB extension for statistical regression and inference in SQL - OLS, Ridge, Elastic Net, LARS/LassoLars, WLS, recursive least squares, robust estimators (Huber, RANSAC, Theil-Sen), GLMs (Poisson, Negative Binomial, Binomial, Tweedie, Gamma, Logistic) with offset support, mixed-effects/hierarchical GLMs with random slopes and crossed/nested factors, AFT survival regression, explicit priors with Laplace intervals, empirical-Bayes shrinkage, and time-series regression, all with full diagnostics and inference. language: C++ build: cmake license: BSL 1.1 maintainers: - sipemu requires_toolchains: rust repo: github: DataZooDE/anofox-statistics ref: afc9ebca4b7c91c97df3edaed751640645e0209a variegata: afc9ebca4b7c91c97df3edaed751640645e0209a extension_star_count: 20 extension_star_count_pretty: 20 extension_download_count: 2683 extension_download_count_pretty: 2.7k image: '/images/community_extensions/social_preview/preview_community_extension_anofox_statistics.png' layout: community_extension_doc --- ### Compatibility Matrix This table covers all DuckDB releases that have not reached [end-of-life](https://duckdb.org/release_calendar), including LTS releases, and shows the 2 most recent patch releases of each. Older patch releases are not listed, but the extension may be available for them as well.
| Platform | 1.4.4 | 1.4.5 | 1.5.5 | 1.5.6 | 2.0.0 | | :--- | :---: | :---: | :---: | :---: | :---: | | Linux AMD64 | ✅ | ❌ | ✅ | ✅ | ✅ | | Linux ARM64 | ✅ | ❌ | ✅ | ✅ | ✅ | | macOS AMD64 | ✅ | ❌ | ✅ | ✅ | ✅ | | macOS ARM64 | ✅ | ❌ | ✅ | ✅ | ✅ | | Windows AMD64 | ✅ | ❌ | ✅ | ✅ | ✅ | | Windows ARM64 | ❌ | ❌ | ❌ | ❌ | ❌ | | WebAssembly | ✅ | ❌ | ✅ | ✅ | ✅ | ### Installing and Loading ```sql INSTALL {{ page.extension.name }} FROM community; LOAD {{ page.extension.name }}; ``` {% if page.docs.hello_world %} ### Example ```sql {{ page.docs.hello_world }}``` {% endif %} {% if page.docs.extended_description %} ### About {{ page.extension.name }} {{ page.docs.extended_description }} {% endif %} ### Added Functions
| function_name | function_type | description | comment | examples | |------------------------------------|---------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | acf_agg | aggregate | Sample autocorrelation function of x in the aggregate's ORDER BY order (R acf): one row per lag 0..max_lag with the 95% white-noise band conf_low/conf_high = -/+ qnorm(0.975)/sqrt(n). max_lag defaults to R's floor(10 log10 n). NULL values are skipped; NULL when n <= max_lag. | NULL | [acf_agg(resid, 10 ORDER BY t)] | | acf_by | table_macro | Table macro: the sample autocorrelation function (R acf) of value_col ordered by order_col within each group of source, one row per lag (the integration contract's `curve` schema, curve_type 'acf'): the group column, model_id, series, curve_type, x (lag), y, y_low / y_high (95% white-noise band), threshold, weight, n_censor. max_lag defaults to R's floor(10 log10 n). | NULL | [acf_by('residuals', store, resid, t, max_lag := 12)] | | ad_test_agg | aggregate | k-sample Anderson-Darling test (Scholz and Stephens; kSamples::ad.test, asymptotic p-value) of two or more groups. | NULL | [ad_test_agg(value, group_id, {'midrank': true})] | | ad_test_agg | aggregate | k-sample Anderson-Darling test (Scholz and Stephens; kSamples::ad.test, asymptotic p-value) of two or more groups. Default options. | NULL | [ad_test_agg(value, group_id)] | | aft_augment_agg | aggregate | Window aggregate: fits the same AFT model as aft_fit_agg over the frame and returns one STRUCT per input row (in frame order): linear_predictor, standardized_residual ((log t - eta) / scale), cox_snell_residual (-log S(t \| x)), score_contributions (intercept, coefficients, log(scale)) and is_training. Use it over a whole partition, as aft_augment_by does. | NULL | [aft_augment_agg(duration, [x1, x2], event) OVER ()] | | aft_augment_agg | aggregate | Window aggregate: fits the same AFT model as aft_fit_agg over the frame and returns one STRUCT per input row (in frame order): linear_predictor, standardized_residual ((log t - eta) / scale), cox_snell_residual (-log S(t \| x)), score_contributions (intercept, coefficients, log(scale)) and is_training. Use it over a whole partition, as aft_augment_by does. With the options of aft_fit_agg. | NULL | [aft_augment_agg(duration, [x1, x2], event, {'distribution': 'lognormal'}) OVER ()] | | aft_augment_by | table_macro | Table macro: fits an AFT survival model (aft_augment_agg, same options as aft_fit_agg) per group of source and returns every source row with its per-observation results (the integration contract's `obs` schema): all source columns, model_id and model_name ('aft'), row_id, fitted (the linear predictor of log T), residual (Cox-Snell, -log S(t \| x)), resid_type ('cox_snell'), std_residual ((log t - fitted) / scale), stud_residual, leverage, cooks_d, dffits (NULL), weight (1), is_training, n_params (NULL), then score_contributions (intercept, coefficients, log(scale)). Rows the fit could not use get NULLs. | NULL | [aft_augment_by('po_lines', supplier, days, [rating, qty], delivered)] | | aft_cdf | scalar | Cumulative distribution P(T <= t) of an AFT survival time with linear predictor eta, scale and distribution (weibull, lognormal, loglogistic, exponential). | NULL | [aft_cdf(5.0, f.intercept + f.coefficients[1] * x1, f.scale, 'weibull')] | | aft_fit_agg | aggregate | Fits an accelerated failure time (AFT) survival model to right-censored durations (event = 1 observed, 0 censored); coefficients are on the log-time scale. | NULL | [aft_fit_agg(duration, [x1, x2], event)] | | aft_fit_agg | aggregate | Fits an accelerated failure time (AFT) survival model with a MAP of options (distribution, fit_intercept, compute_inference, confidence_level, ...). | NULL | [aft_fit_agg(duration, [x1, x2], event, {'distribution': 'lognormal'})] | | aft_fit_agg | aggregate | Fits the same AFT model with a cluster-robust coefficient covariance (survreg(..., cluster = id), rms::robcov): std_errors, z tests, intercept_std_error and log_scale_std_error are clustered, plus vcov (intercept, coefficients, log(scale)), vcov_type and n_clusters. cluster: one id per row of any type, or a LIST / STRUCT of ids for multiway clustering. 'hc_type': 'hc0' (default) or 'hc1', 'cadjust' (default false, as survreg); with priors the penalized bread is used. compute_inference defaults to true. | NULL | [aft_fit_agg(duration, [x1, x2], event, patient_id, MAP {})] | | aft_glance_by | table_macro | Table macro: fits an accelerated failure time (AFT) survival model per group of source and returns its fit statistics in long form, one row per available metric: the group column, id (the group), model_id and model_name (the method), model_type, metric, value. | NULL | [aft_glance_by('my_table', group_col, y, [x1, x2], event)] | | aft_quantile | scalar | p-quantile of an AFT survival time with linear predictor eta, scale and distribution (weibull, lognormal, loglogistic, exponential). | NULL | [aft_quantile(0.5, f.intercept + f.coefficients[1] * x1, f.scale, 'weibull')] | | aft_survival | scalar | Model-based survival curve S(t \| x) of a fitted AFT model (the STRUCT returned by aft_fit_agg) for the covariate row x, at each of times (R psurvreg(t, eta, scale, dist, lower.tail = FALSE)): one {time, surv} per time. | NULL | [aft_survival(m, [1.0, 0.5], [1, 5, 10, 20])] | | aft_tidy_by | table_macro | Table macro: fits an accelerated failure time (AFT) survival model per group of source and returns one row per term (intercept first): the group column, id (the group), model_id and model_name (the method), term, estimate, std_error, statistic, p_value, conf_low, conf_high, conf_level, index_name, index_value. Inference is computed by default (compute_inference is merged under options). names := [...] labels the terms. | NULL | [aft_tidy_by('my_table', group_col, y, [x1, x2], event, names := ['x1', 'x2'])] | | aic | scalar | Computes Akaike Information Criterion (AIC) from residual sum of squares, number of observations, and number of parameters. | NULL | [aic(rss, n, k)] | | aid_agg | aggregate | Classifies demand patterns (smooth, intermittent, erratic, lumpy) using Automatic Identification of Demand (AID). | NULL | [aid_agg(y)] | | aid_agg | aggregate | Classifies demand patterns using AID with a MAP of options (intermittent_threshold, outlier_method). | NULL | [aid_agg(y, {'intermittent_threshold': 0.3})] | | aid_anomaly_agg | aggregate | Identifies anomalies in demand time series using AID with a MAP of options (intermittent_threshold, outlier_method). | NULL | [aid_anomaly_agg(y, {'outlier_method': 'iqr'})] | | aid_anomaly_agg | aggregate | Identifies anomalies in demand time series using the AID classification framework. | NULL | [aid_anomaly_agg(y)] | | aid_anomaly_by | table_macro | Table macro: AID anomaly flags per group of source, ordered by order_col; returns one row per input row with stockout, new_product, obsolete_product, high_outlier and low_outlier flags. | NULL | [aid_anomaly_by('sales', product_id, date, demand)] | | aid_by | table_macro | Table macro: Automatic Identification of Demand (AID); classifies the demand pattern of each group of source and returns one row per group. Pass order_by :=