-- Fixture: small deterministic binomial data. 0s and 1s are interleaved -- across the x range so there is no complete separation. Kept literally in -- sync with scripts/parity_reference.R. CREATE TEMP TABLE t_binomial ( y integer, x double precision ); INSERT INTO t_binomial VALUES (0, 0.1), (0, 0.4), (1, 0.8), (0, 1.0), (1, 1.2), (0, 1.5), (1, 1.8), (1, 2.0), (0, 2.2), (1, 2.5), (1, 2.8), (0, 3.0); -- Full output relation (statistic is the z value for binomial). SELECT term, round(estimate::numeric, 4) AS estimate, round(std_error::numeric, 4) AS std_error, round(statistic::numeric, 4) AS statistic, round(p_value::numeric, 4) AS p_value, round(conf_low_95::numeric, 4) AS conf_low_95, round(conf_high_95::numeric, 4) AS conf_high_95, family, link, formula, n_obs, n_used, n_dropped, round(aic::numeric, 4) AS aic, round(deviance::numeric, 4) AS deviance, round(null_deviance::numeric, 4) AS null_deviance FROM fbsql.fit_glm( relation => $$ SELECT y, x FROM t_binomial $$, formula => 'y ~ x', family => 'binomial') ORDER BY term; term | estimate | std_error | statistic | p_value | conf_low_95 | conf_high_95 | family | link | formula | n_obs | n_used | n_dropped | aic | deviance | null_deviance -------------+----------+-----------+-----------+---------+-------------+--------------+----------+-------+---------+-------+--------+-----------+---------+----------+--------------- (Intercept) | -1.0172 | 1.2677 | -0.8023 | 0.4224 | -3.5019 | 1.4676 | binomial | logit | y ~ x | 12 | 12 | 0 | 19.7413 | 15.7413 | 16.6355 x | 0.6318 | 0.6925 | 0.9124 | 0.3616 | -0.7254 | 1.9890 | binomial | logit | y ~ x | 12 | 12 | 0 | 19.7413 | 15.7413 | 16.6355 (2 rows) -- A boolean response (as in the running example's churn_flag) must give the -- same fit as the 0/1 integer encoding. SELECT term, round(estimate::numeric, 4) AS estimate, round(std_error::numeric, 4) AS std_error FROM fbsql.fit_glm( relation => $$ SELECT y::boolean AS y, x FROM t_binomial $$, formula => 'y ~ x', family => 'binomial') ORDER BY term; term | estimate | std_error -------------+----------+----------- (Intercept) | -1.0172 | 1.2677 x | 0.6318 | 0.6925 (2 rows)