statsmodels
Regression fits and hypothesis tests over SQL relations
- Connector software
- Free and open source
- Service credentials
- Not needed
- Query Farm hosting
- Available · $10/month organization minimum
Use with an agent
Install the Orchard skill in your project to help your agent find connectors, configure them, and verify SQL results.
npx skills add Query-farm/vgi-skills --skill orchard
Copy this request into your coding agent to get started.
Use https://query.farm/products/orchard/connectors/statsmodels/index.md to help me query statsmodels with DuckDB or Haybarn 2.0.1 and VGI protocol 3.4. Ask only for missing details about the result I need or whether I want local execution, self-hosting or Query Farm hosting. Check the connector's actual hosting availability, credentials and input requirements. Read one format of each needed reference and the exact object declarations before writing SQL. Use a released connector, and distinguish a saved example result from anything you actually execute. If you cannot run the query, tell me what remains to verify.
Fit a regression and inspect its coefficients
Example output · captured
- Connector release
- v0.5.0
- Engine
- 2.0.1
- VGI protocol
- 3.4.0
SELECT term, round(coef, 3) AS coef, round(p_value, 6) AS p_value
FROM statsmodels.main.ols((SELECT * FROM (VALUES (1,5.1),(2,7.9),(3,11.2),(4,13.8)) AS t(x, y)), formula := 'y ~ x')
ORDER BY term
| term | coef | p_value |
|---|---|---|
| Intercept | 2.15 | 0.013 |
| x | 2.94 | 0.0009 |
Quick start
Choose where to run statsmodels, then follow the steps below.
The connector runs alongside DuckDB or Haybarn. No Query Farm account is needed.
1. Install the vgi extension
Run this in your SQL client. On DuckDB, keep FROM query_farm on LOAD in later sessions.
SET allow_extension_repositories = 'allowed';
CREATE EXTENSION REPOSITORY IF NOT EXISTS query_farm
WITH PREFIX 'https://duckdb-extensions.query.farm';
INSTALL vgi FROM query_farm;
LOAD vgi FROM query_farm;
INSTALL vgi FROM community;
LOAD vgi;
2. Attach the connector
Attach with uvx
Needs uv. uvx builds the worker from its release tag on first attach and reuses the cached environment after that.
ATTACH 'statsmodels' AS statsmodels (
TYPE vgi,
LOCATION 'uvx --from git+https://github.com/Query-farm/[email protected] vgi-statsmodels'
);
Attach the signed image
Needs Docker, Podman or another OCI runtime. The extension runs the container and talks to it over stdio.
ATTACH 'statsmodels' AS statsmodels (
TYPE vgi,
LOCATION 'oci://ghcr.io/query-farm/vgi-statsmodels:0.5.0'
);
3. Run a query
SELECT term, round(coef, 3) AS coef, round(p_value, 6) AS p_value
FROM statsmodels.main.ols((SELECT * FROM (VALUES (1,5.1),(2,7.9),(3,11.2),(4,13.8)) AS t(x, y)), formula := 'y ~ x')
ORDER BY term
Run the connector on a server you manage. You operate the service and choose who can connect.
1. Deploy the connector on your server
Follow the connector’s deployment instructions. Use its supported HTTP transport, or launch it remotely over SSH. The connection guide explains both options.
2. Install the vgi extension
Run this in your SQL client. On DuckDB, keep FROM query_farm on LOAD in later sessions.
SET allow_extension_repositories = 'allowed';
CREATE EXTENSION REPOSITORY IF NOT EXISTS query_farm
WITH PREFIX 'https://duckdb-extensions.query.farm';
INSTALL vgi FROM query_farm;
LOAD vgi FROM query_farm;
INSTALL vgi FROM community;
LOAD vgi;
3. Attach the connector
For an HTTP deployment, replace the example URL with your endpoint. Add the authentication options your deployment requires. For SSH, use the SSH connection instructions.
ATTACH 'statsmodels' AS statsmodels
(TYPE vgi, LOCATION 'https://your-connector.example.com');
4. Run a query
SELECT term, round(coef, 3) AS coef, round(p_value, 6) AS p_value
FROM statsmodels.main.ols((SELECT * FROM (VALUES (1,5.1),(2,7.9),(3,11.2),(4,13.8)) AS t(x, y)), formula := 'y ~ x')
ORDER BY term
Query Farm operates statsmodels for your team. Hosting has a $10 monthly minimum per organization; usage counts toward it. From $2.97 per instance-month ($10 monthly minimum).
1. Create your hosted connector
Open the console, choose your organization and deployment size, and add any service credentials there.
2. Install the vgi extension
SET allow_extension_repositories = 'allowed';
CREATE EXTENSION REPOSITORY IF NOT EXISTS query_farm
WITH PREFIX 'https://duckdb-extensions.query.farm';
INSTALL vgi FROM query_farm;
LOAD vgi FROM query_farm;
INSTALL vgi FROM community;
LOAD vgi;
3. Attach your deployment
Copy the ATTACH statement from your deployment in the console and run it in DuckDB or Haybarn. Use statsmodels as the catalog alias for the query below.
4. Run a query
SELECT term, round(coef, 3) AS coef, round(p_value, 6) AS p_value
FROM statsmodels.main.ols((SELECT * FROM (VALUES (1,5.1),(2,7.9),(3,11.2),(4,13.8)) AS t(x, y)), formula := 'y ~ x')
ORDER BY term
Technical details
- Verified connector release
- v0.5.0
- Engine
- 2.0.1
- VGI protocol
- 3.4.0
- Verified on
- December 1, 2026
Pin a version for production
When running the connector yourself, keep a specific release until you’re ready to upgrade. Replace the ATTACH statement above with this one and follow the same extension and credential setup.
Attach with uvx
Needs uv. uvx builds the worker from its release tag on first attach and reuses the cached environment after that.
ATTACH 'statsmodels' AS statsmodels (
TYPE vgi,
LOCATION 'uvx --from git+https://github.com/Query-farm/[email protected] vgi-statsmodels'
);
Attach the signed image
Needs Docker, Podman or another OCI runtime. The extension runs the container and talks to it over stdio.
ATTACH 'statsmodels' AS statsmodels (
TYPE vgi,
LOCATION 'oci://ghcr.io/query-farm/vgi-statsmodels:0.5.0'
);
Overview
statsmodels-powered regression and inference for DuckDB/SQL: OLS/Logit/GLM fits, model statistics, and t-test/ADF hypothesis tests
Run regression with full statistical inference and classic hypothesis tests directly in DuckDB SQL: fit OLS, logistic, and generalized linear models and get coefficient tables complete with standard errors, t/z-statistics, p-values, and 95% confidence intervals — no Python notebook required.
This extension brings the proven statistics of the statsmodels library (source on GitHub) to anyone who already speaks SQL. It is built for data analysts, data scientists, and engineers who want trustworthy estimation and inference — effect sizes, significance, model fit, and stationarity checks — without exporting data to a separate stats environment. Every function takes a whole input relation as a (SELECT ...) subquery, so you model the result of any DuckDB query: joins, filters, window functions, and aggregates all flow straight into the fit.
Under the hood each call buffers the input relation, builds the design matrices from a Patsy (source on GitHub) formula (for the regressions) or from named column roles (for the tests), then runs the corresponding statsmodels routine once and returns the results as an ordinary SQL table you can join, filter, and persist. The familiar R-style formula syntax (y ~ x1 + x2 + C(group)) makes specifying interactions, transformations, and categorical encodings concise and readable.
The capabilities group into three areas. Regression estimates how predictors drive an outcome — linear for continuous responses, logistic for binary events, and generalized linear models for counts and other exponential-family outcomes — always returning coefficients with standard errors, t- or z-statistics, p-values, and 95% confidence intervals. Model fit reports whole-model diagnostics such as R-squared, adjusted R-squared, the F-test, AIC/BIC, and log-likelihood so you can judge how well a linear model explains the data. Hypothesis tests compare two group means and check a time series for a unit root (stationarity). Together they let you ask, in SQL alone, which predictors matter and by how much, whether an effect is significant, how well a model fits, and whether a series is stationary.
Catalog
Everything statsmodels exposes once attached — read straight from the worker's
released build.
main 1 view · 6 functions
Regression (OLS/Logit/GLM) and hypothesis tests (t-test, ADF) for SQL
Schema examples (7)
Fit y ~ x by OLS and read each term's coefficient and p-value.
SELECT term, round(coef, 3) AS coef, round(p_value, 6) AS p_value
FROM statsmodels.main.ols((SELECT * FROM (VALUES (1,5.1),(2,7.9),(3,11.2),(4,13.8)) AS t(x, y)), formula := 'y ~ x')
ORDER BY term;
| term | coef | p_value |
|---|---|---|
| Intercept | 2.15 | 0.013 |
| x | 2.94 | 0.0009 |
Report the R-squared goodness-of-fit for an OLS model of y on x.
SELECT round(value, 4) AS r_squared
FROM statsmodels.main.model_stats((SELECT * FROM (VALUES (1,5.1),(2,7.9),(3,11.2),(4,13.8)) AS t(x, y)), formula := 'y ~ x')
WHERE statistic = 'r_squared';
Fit a Poisson GLM of count y on x and read the log-rate coefficient on x.
SELECT term, round(coef, 3) AS coef
FROM statsmodels.main.glm((SELECT * FROM (VALUES (1,1),(2,2),(3,2),(4,4),(5,5),(6,7),(7,9),(8,12)) AS t(x, y)), formula := 'y ~ x', family := 'poisson')
WHERE term = 'x';
Two-sample t-test of v across groups; read the p-value and mean difference.
SELECT round(p_value, 6) AS p_value, round(mean_diff, 2) AS mean_diff
FROM statsmodels.main.ttest((SELECT * FROM (VALUES (10,'a'),(11,'a'),(20,'b'),(22,'b')) AS t(v, g)), "column" := 'v', "group" := 'g');
3 more examples
Regress sales on ad spend and price with ols, and attach model_stats' adjusted R-squared and overall F-test verdict to every coefficient row
WITH ads AS (SELECT * FROM (VALUES (1,8.5,12.6),(2,10.0,12.7),(3,10.4,15.6),(4,8.1,24.8),(5,8.6,28.7),(6,11.7,26.0),(7,8.3,35.2),(8,8.5,40.6),(9,11.8,36.6),(10,10.5,41.2),(11,9.5,50.5),(12,10.0,51.7)) AS t(spend, price, sales)), fit AS (SELECT max(value) FILTER (WHERE statistic = 'adj_r_squared') AS adj_r_squared, max(value) FILTER (WHERE statistic = 'f_pvalue') AS f_pvalue FROM statsmodels.main.model_stats((SELECT * FROM ads), formula := 'sales ~ spend + price')) SELECT o.term, round(o.coef, 3) AS coef, round(o.p_value, 6) AS p_value, round(fit.adj_r_squared, 4) AS adj_r_squared, fit.f_pvalue < 0.001 AS model_significant
FROM statsmodels.main.ols((SELECT * FROM ads), formula := 'sales ~ spend + price') AS o
CROSS JOIN fit
ORDER BY o.term;
Compare a linear and a quadratic model of the same data side by side on adjusted R-squared, AIC and BIC (the quadratic wins: higher adj R-squared, lower AIC/BIC)
WITH curve AS (SELECT * FROM (VALUES (1,2.0),(2,4.8),(3,7.6),(4,10.2),(5,14.0),(6,20.4),(7,27.0),(8,32.4),(9,39.2),(10,48.4)) AS t(x, y)), lin AS (SELECT statistic, value FROM statsmodels.main.model_stats((SELECT * FROM curve), formula := 'y ~ x')), quad AS (SELECT statistic, value FROM statsmodels.main.model_stats((SELECT * FROM curve), formula := 'y ~ x + I(x**2)')) SELECT lin.statistic, round(lin.value, 4) AS linear, round(quad.value, 4) AS quadratic
FROM lin
JOIN quad USING (statistic)
WHERE lin.statistic IN ('adj_r_squared', 'aic', 'bic')
ORDER BY lin.statistic;
Cointegration check in the Engle-Granger style: fit y ~ x with ols, then run adfuller on the regression residuals; a small p-value means the two trending series move together
WITH pair AS (SELECT * FROM (VALUES (0,20.0,41.57),(1,20.3,42.14),(2,20.03,40.82),(3,19.14,39.83),(4,18.68,39.68),(5,17.69,35.95),(6,17.75,37.52),(7,19.09,39.75),(8,18.6,38.32),(9,17.98,38.66),(10,18.47,38.9),(11,18.82,38.42),(12,18.93,39.4),(13,18.0,37.85),(14,17.97,37.33),(15,18.66,39.23),(16,17.32,36.1),(17,16.86,35.62),(18,14.96,32.28),(19,13.67,28.43),(20,11.83,25.28),(21,11.59,24.4),(22,10.33,22.24),(23,10.6,21.99),(24,10.76,22.67),(25,10.57,22.52),(26,8.05,18.14),(27,7.51,17.21),(28,7.46,15.63),(29,7.58,16.18),(30,6.05,13.99),(31,5.57,11.44),(32,4.59,10.4),(33,3.78,9.0),(34,4.84,11.93),(35,4.04,9.99),(36,4.0,9.3),(37,4.89,11.06),(38,4.3,9.95),(39,4.19,10.79)) AS t(t, x, y)), fit AS (SELECT max(coef) FILTER (WHERE term = 'Intercept') AS a, max(coef) FILTER (WHERE term = 'x') AS b FROM statsmodels.main.ols((SELECT x, y FROM pair), formula := 'y ~ x')) SELECT round(statistic, 3) AS adf_statistic, p_value < 0.01 AS residuals_stationary, used_lag, n_obs
FROM statsmodels.main.adfuller((SELECT pair.y - (fit.a + fit.b * pair.x) AS resid FROM pair, fit ORDER BY pair.t), "column" := 'resid');
glm_families
The GLM error families the glm() function accepts, one per row (discovery view).
List every GLM family with its link function and the outcome it suits.
SELECT family, link, typical_outcome
FROM statsmodels.main.glm_families
ORDER BY family;
Which GLM family should you use for count outcomes?
SELECT family, example_use
FROM statsmodels.main.glm_families
WHERE typical_outcome = 'Non-negative integer counts';
adfuller (data TABLE, column := VARCHAR)
Augmented Dickey-Fuller unit-root (stationarity) test over an already-ordered series; emits one row (statistic, p_value, used_lag, n_obs). Pass an ORDER BY'd relation so rows are in time order. Small p_value => reject unit root => stationary.
ADF stationarity test on an ordered series; read the lag, n_obs, and p-value
SELECT used_lag, n_obs, round(p_value, 4) AS p_value
FROM statsmodels.main.adfuller((SELECT * FROM (VALUES (0,10.0),(1,13.82),(2,16.66),(3,14.87),(4,14.38),(5,12.71),(6,7.79),(7,6.64),(8,7.02),(9,6.14),(10,9.6),(11,13.56),(12,13.97),(13,15.99),(14,16.27),(15,12.06),(16,10.13),(17,8.5),(18,5.1),(19,6.4),(20,9.32),(21,10.17),(22,13.96),(23,16.72),(24,14.83),(25,14.25),(26,12.54),(27,7.64),(28,6.56),(29,7.04)) AS t(t, v) ORDER BY t), "column" := 'v');
Cointegration check in the Engle-Granger style: fit y ~ x with ols, then run adfuller on the regression residuals; a small p-value means the two trending series move together
WITH pair AS (SELECT * FROM (VALUES (0,20.0,41.57),(1,20.3,42.14),(2,20.03,40.82),(3,19.14,39.83),(4,18.68,39.68),(5,17.69,35.95),(6,17.75,37.52),(7,19.09,39.75),(8,18.6,38.32),(9,17.98,38.66),(10,18.47,38.9),(11,18.82,38.42),(12,18.93,39.4),(13,18.0,37.85),(14,17.97,37.33),(15,18.66,39.23),(16,17.32,36.1),(17,16.86,35.62),(18,14.96,32.28),(19,13.67,28.43),(20,11.83,25.28),(21,11.59,24.4),(22,10.33,22.24),(23,10.6,21.99),(24,10.76,22.67),(25,10.57,22.52),(26,8.05,18.14),(27,7.51,17.21),(28,7.46,15.63),(29,7.58,16.18),(30,6.05,13.99),(31,5.57,11.44),(32,4.59,10.4),(33,3.78,9.0),(34,4.84,11.93),(35,4.04,9.99),(36,4.0,9.3),(37,4.89,11.06),(38,4.3,9.95),(39,4.19,10.79)) AS t(t, x, y)), fit AS (SELECT max(coef) FILTER (WHERE term = 'Intercept') AS a, max(coef) FILTER (WHERE term = 'x') AS b FROM statsmodels.main.ols((SELECT x, y FROM pair), formula := 'y ~ x')) SELECT round(statistic, 3) AS adf_statistic, p_value < 0.01 AS residuals_stationary, used_lag, n_obs
FROM statsmodels.main.adfuller((SELECT pair.y - (fit.a + fit.b * pair.x) AS resid FROM pair, fit ORDER BY pair.t), "column" := 'resid');
glm (data TABLE, family := VARCHAR, formula := VARCHAR)
Generalized linear model with a 'family' arg (gaussian|binomial|poisson|gamma): emits (term, coef, std_err, z_value, p_value, ci_lower, ci_upper). Pass a Patsy formula.
Poisson GLM of count y on x; read the log-rate coefficient on x
SELECT term, round(coef, 3) AS coef
FROM statsmodels.main.glm((SELECT * FROM (VALUES (1,1),(2,2),(3,2),(4,4),(5,5),(6,7),(7,9),(8,12)) AS t(x, y)), formula := 'y ~ x', family := 'poisson')
WHERE term = 'x';
logit (data TABLE, formula := VARCHAR)
Logistic (binary-outcome) regression with full inference: emits (term, coef, std_err, z_value, p_value, ci_lower, ci_upper, odds_ratio). Response must be binary. Pass a Patsy formula.
Logistic fit of binary y on x; read the x log-odds coefficient and odds ratio
SELECT term, round(coef, 3) AS coef, round(odds_ratio, 3) AS odds_ratio
FROM statsmodels.main.logit((SELECT * FROM (VALUES (1,0),(2,0),(3,0),(4,1),(5,0),(6,1),(7,0),(8,1),(9,1),(10,1),(11,1),(12,1)) AS t(x, y)), formula := 'y ~ x')
WHERE term = 'x';
model_stats (data TABLE, formula := VARCHAR)
OLS whole-model fit statistics as (statistic, value) rows: r_squared, adj_r_squared, f_statistic, f_pvalue, aic, bic, log_likelihood, nobs, df_model, df_resid. Pass a Patsy formula.
Read the R-squared goodness-of-fit for an OLS model of y on x
SELECT round(value, 4) AS r_squared
FROM statsmodels.main.model_stats((SELECT * FROM (VALUES (1,5.1),(2,7.9),(3,11.2),(4,13.8),(5,17.1),(6,19.9),(7,23.2),(8,25.8)) AS t(x, y)), formula := 'y ~ x')
WHERE statistic = 'r_squared';
Compare a linear and a quadratic model of the same data side by side on adjusted R-squared, AIC and BIC (the quadratic wins: higher adj R-squared, lower AIC/BIC)
WITH curve AS (SELECT * FROM (VALUES (1,2.0),(2,4.8),(3,7.6),(4,10.2),(5,14.0),(6,20.4),(7,27.0),(8,32.4),(9,39.2),(10,48.4)) AS t(x, y)), lin AS (SELECT statistic, value FROM statsmodels.main.model_stats((SELECT * FROM curve), formula := 'y ~ x')), quad AS (SELECT statistic, value FROM statsmodels.main.model_stats((SELECT * FROM curve), formula := 'y ~ x + I(x**2)')) SELECT lin.statistic, round(lin.value, 4) AS linear, round(quad.value, 4) AS quadratic
FROM lin
JOIN quad USING (statistic)
WHERE lin.statistic IN ('adj_r_squared', 'aic', 'bic')
ORDER BY lin.statistic;
ols (data TABLE, formula := VARCHAR)
Ordinary least squares regression with full inference: emits (term, coef, std_err, t_value, p_value, ci_lower, ci_upper), one row per term including the Intercept. Pass a Patsy formula.
Fit y ~ x by OLS and read each term's coefficient and p-value
SELECT term, round(coef, 3) AS coef, round(p_value, 6) AS p_value
FROM statsmodels.main.ols((SELECT * FROM (VALUES (1,5.1),(2,7.9),(3,11.2),(4,13.8),(5,17.1),(6,19.9),(7,23.2),(8,25.8)) AS t(x, y)), formula := 'y ~ x')
ORDER BY term;
Regress sales on ad spend and price with ols, and attach model_stats' adjusted R-squared and overall F-test verdict to every coefficient row
WITH ads AS (SELECT * FROM (VALUES (1,8.5,12.6),(2,10.0,12.7),(3,10.4,15.6),(4,8.1,24.8),(5,8.6,28.7),(6,11.7,26.0),(7,8.3,35.2),(8,8.5,40.6),(9,11.8,36.6),(10,10.5,41.2),(11,9.5,50.5),(12,10.0,51.7)) AS t(spend, price, sales)), fit AS (SELECT max(value) FILTER (WHERE statistic = 'adj_r_squared') AS adj_r_squared, max(value) FILTER (WHERE statistic = 'f_pvalue') AS f_pvalue FROM statsmodels.main.model_stats((SELECT * FROM ads), formula := 'sales ~ spend + price')) SELECT o.term, round(o.coef, 3) AS coef, round(o.p_value, 6) AS p_value, round(fit.adj_r_squared, 4) AS adj_r_squared, fit.f_pvalue < 0.001 AS model_significant
FROM statsmodels.main.ols((SELECT * FROM ads), formula := 'sales ~ spend + price') AS o
CROSS JOIN fit
ORDER BY o.term;
ttest (data TABLE, column := VARCHAR, group := VARCHAR)
Two-sample (pooled-variance) t-test of 'column' across the two levels of 'group'; emits one row (statistic, p_value, df, mean_diff). 'column' and 'group' are SQL keywords -- double-quote both arg names in SQL.
Two-sample t-test of v across groups; read the p-value and mean difference
SELECT round(p_value, 6) AS p_value, round(mean_diff, 2) AS mean_diff
FROM statsmodels.main.ttest((SELECT * FROM (VALUES (10,'a'),(11,'a'),(9,'a'),(12,'a'),(10,'a'),(20,'b'),(22,'b'),(19,'b'),(21,'b'),(20,'b')) AS t(v, g)), "column" := 'v', "group" := 'g');
Try these queries
Report the R-squared goodness-of-fit for an OLS model of y on x.
SELECT round(value, 4) AS r_squared
FROM statsmodels.main.model_stats((SELECT * FROM (VALUES (1,5.1),(2,7.9),(3,11.2),(4,13.8)) AS t(x, y)), formula := 'y ~ x')
WHERE statistic = 'r_squared'
Uses model_stats
Fit a Poisson GLM of count y on x and read the log-rate coefficient on x.
SELECT term, round(coef, 3) AS coef
FROM statsmodels.main.glm((SELECT * FROM (VALUES (1,1),(2,2),(3,2),(4,4),(5,5),(6,7),(7,9),(8,12)) AS t(x, y)), formula := 'y ~ x', family := 'poisson')
WHERE term = 'x'
Uses glm
Two-sample t-test of v across groups; read the p-value and mean difference.
SELECT round(p_value, 6) AS p_value, round(mean_diff, 2) AS mean_diff
FROM statsmodels.main.ttest((SELECT * FROM (VALUES (10,'a'),(11,'a'),(20,'b'),(22,'b')) AS t(v, g)), "column" := 'v', "group" := 'g')
Uses ttest
Cointegration check in the Engle-Granger style: fit y ~ x with ols, then run adfuller on the regression residuals; a small p-value means the two trending series move together
WITH pair AS (SELECT * FROM (VALUES (0,20.0,41.57),(1,20.3,42.14),(2,20.03,40.82),(3,19.14,39.83),(4,18.68,39.68),(5,17.69,35.95),(6,17.75,37.52),(7,19.09,39.75),(8,18.6,38.32),(9,17.98,38.66),(10,18.47,38.9),(11,18.82,38.42),(12,18.93,39.4),(13,18.0,37.85),(14,17.97,37.33),(15,18.66,39.23),(16,17.32,36.1),(17,16.86,35.62),(18,14.96,32.28),(19,13.67,28.43),(20,11.83,25.28),(21,11.59,24.4),(22,10.33,22.24),(23,10.6,21.99),(24,10.76,22.67),(25,10.57,22.52),(26,8.05,18.14),(27,7.51,17.21),(28,7.46,15.63),(29,7.58,16.18),(30,6.05,13.99),(31,5.57,11.44),(32,4.59,10.4),(33,3.78,9.0),(34,4.84,11.93),(35,4.04,9.99),(36,4.0,9.3),(37,4.89,11.06),(38,4.3,9.95),(39,4.19,10.79)) AS t(t, x, y)), fit AS (SELECT max(coef) FILTER (WHERE term = 'Intercept') AS a, max(coef) FILTER (WHERE term = 'x') AS b FROM statsmodels.main.ols((SELECT x, y FROM pair), formula := 'y ~ x')) SELECT round(statistic, 3) AS adf_statistic, p_value < 0.01 AS residuals_stationary, used_lag, n_obs
FROM statsmodels.main.adfuller((SELECT pair.y - (fit.a + fit.b * pair.x) AS resid FROM pair, fit ORDER BY pair.t), "column" := 'resid')
List every GLM family with its link function and the outcome it suits.
SELECT family, link, typical_outcome
FROM statsmodels.main.glm_families
ORDER BY family
Uses glm_families
Logistic fit of binary y on x; read the x log-odds coefficient and odds ratio
SELECT term, round(coef, 3) AS coef, round(odds_ratio, 3) AS odds_ratio
FROM statsmodels.main.logit((SELECT * FROM (VALUES (1,0),(2,0),(3,0),(4,1),(5,0),(6,1),(7,0),(8,1),(9,1),(10,1),(11,1),(12,1)) AS t(x, y)), formula := 'y ~ x')
WHERE term = 'x'
Uses logit
7 more examples in the Catalog, each listed under the table or function it uses.
statsmodels is an independent open-source connector from Query.Farm. It is not affiliated with, endorsed by or sponsored by the services, projects or organisations it works with. Product names, logos and trademarks belong to their respective owners.
Related workers
Explain
Statistics & ML
Explain scikit-learn and XGBoost model predictions with per-row SHAP values and global feature importance
LightGBM
Statistics & ML
Train, tune, evaluate, and explain gradient-boosted classifiers and regressors, with a saved-model registry
scikit-learn
Statistics & ML
scikit-learn — datasets, metrics, transforms and a train/predict model registry