Skip to content

statsmodels

Regression fits and hypothesis tests over SQL relations

Connector software
Free and open source
Service credentials
Not needed
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
Result
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.

setup.sql
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;

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'
);

3. Run a query

query.sql
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
More example queries →
Technical details
Verified connector release
v0.5.0
Engine
2.0.1
VGI protocol
3.4.0
Verified on
December 1, 2026
Release notes on GitHub
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'
);

Overview

statsmodels-powered regression and inference for DuckDB/SQL: OLS/Logit/GLM fits, model statistics, and t-test/ADF hypothesis tests

Catalog

Everything statsmodels exposes once attached — read straight from the worker's released build.

statsmodels 1 schema
main 1 view · 6 functions

Regression (OLS/Logit/GLM) and hypothesis tests (t-test, ADF) for SQL

Schema examples (7)
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;
Result
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');
Views
glm_families 2 examples4 cols

The GLM error families the glm() function accepts, one per row (discovery view).

Columns
family VARCHAR
GLM error-family name; pass it as glm(..., family := '<family>').
link VARCHAR
Default link function statsmodels uses for this family.
typical_outcome VARCHAR
The kind of response variable this family models.
example_use VARCHAR
A short, concrete example of when to choose this family.
Examples (2)

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';
Link
Table in-out functions
adfuller (data TABLE, column := VARCHAR) 2 examples

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.

Positional arguments
data TABLE
Ordered relation containing the series column.
Named arguments
column := VARCHAR
Name of the time-ordered series column to test for a unit root. · default "value"
Returns columns
statistic DOUBLE
Augmented Dickey-Fuller test statistic.
p_value DOUBLE
MacKinnon p-value; small => reject unit root (stationary).
used_lag INTEGER
Number of lags chosen by AIC.
n_obs INTEGER
Observations used after lagging/differencing.
Examples (2)

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');
Link
glm (data TABLE, family := VARCHAR, formula := VARCHAR) 1 example

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.

Positional arguments
data TABLE
Relation; every column is available to the formula.
Named arguments
family := VARCHAR
Error distribution for the response, one of the supported GLM families (default gaussian). · default "gaussian"
formula := VARCHAR
Patsy formula, e.g. 'y ~ x1 + x2'. · default ""
Returns columns
term VARCHAR
Model term (a predictor or 'Intercept').
coef DOUBLE
Estimated coefficient (on the link scale).
std_err DOUBLE
Standard error of the coefficient.
z_value DOUBLE
Wald z-statistic (coef / std_err).
p_value DOUBLE
Two-sided p-value for H0: coef = 0.
ci_lower DOUBLE
Lower bound of the 95% confidence interval.
ci_upper DOUBLE
Upper bound of the 95% confidence interval.
Example

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';
Link
logit (data TABLE, formula := VARCHAR) 1 example

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.

Positional arguments
data TABLE
Relation; every column is available to the formula.
Named arguments
formula := VARCHAR
Patsy formula, e.g. 'y ~ x1 + x2'. · default ""
Returns columns
term VARCHAR
Model term (a predictor or 'Intercept').
coef DOUBLE
Estimated log-odds coefficient.
std_err DOUBLE
Standard error of the coefficient.
z_value DOUBLE
Wald z-statistic (coef / std_err).
p_value DOUBLE
Two-sided p-value for H0: coef = 0.
ci_lower DOUBLE
Lower bound of the 95% confidence interval.
ci_upper DOUBLE
Upper bound of the 95% confidence interval.
odds_ratio DOUBLE
Odds ratio exp(coef); >1 raises odds, <1 lowers.
Example

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';
Link
model_stats (data TABLE, formula := VARCHAR) 2 examples

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.

Positional arguments
data TABLE
Relation; every column is available to the formula.
Named arguments
formula := VARCHAR
Patsy formula, e.g. 'y ~ x1 + x2'. · default ""
Returns columns
statistic VARCHAR
Fit-statistic name.
value DOUBLE
Statistic value.
Examples (2)

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;
Link
ols (data TABLE, formula := VARCHAR) 2 examples

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.

Positional arguments
data TABLE
Relation; every column is available to the formula.
Named arguments
formula := VARCHAR
Patsy formula, e.g. 'y ~ x1 + x2'. · default ""
Returns columns
term VARCHAR
Model term (a predictor or 'Intercept').
coef DOUBLE
Estimated coefficient.
std_err DOUBLE
Standard error of the coefficient.
t_value DOUBLE
t-statistic (coef / std_err).
p_value DOUBLE
Two-sided p-value for H0: coef = 0.
ci_lower DOUBLE
Lower bound of the 95% confidence interval.
ci_upper DOUBLE
Upper bound of the 95% confidence interval.
Examples (2)

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;
Link
ttest (data TABLE, column := VARCHAR, group := VARCHAR) 1 example

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.

Positional arguments
data TABLE
Relation containing the value and group columns.
Named arguments
column := VARCHAR
Name of the value column whose means are compared across the two groups. · default "value"
group := VARCHAR
Grouping column with two levels. · default "group"
Returns columns
statistic DOUBLE
Two-sample t-statistic.
p_value DOUBLE
Two-sided p-value for equal means.
df DOUBLE
Degrees of freedom.
mean_diff DOUBLE
mean(group0) - mean(group1).
Example

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');
Link

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')

Uses olsadfuller

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.