Skip to content

pg_statkit

Descriptive statistics and clinical effect-size functions over arrays

Overview

PackageVersionCategoryLicenseLanguage
pg_statkit1.1.0FUNCMITRust
IDExtensionBinLibLoadCreateTrustRelocSchema
4690pg_statkitNoYesNoYesNoNo-

Release Cargo/CI support PostgreSQL 13-17 with pgrx 0.18.1; no PG18 feature. This is statistical computation, not server monitoring.

Version

TypeRepoVersionPG VerPackageDeps
EXTPIGSTY1.1.01817161514pg_statkit-
RPMPIGSTY1.1.01817161514pg_statkit_$v-
DEBPIGSTY1.1.01817161514postgresql-$v-pg-statkit-
OS / PGPG18PG17PG16PG15PG14
el8.x86_64N/A
el8.aarch64N/A
el9.x86_64N/A
el9.aarch64N/A
el10.x86_64N/A
el10.aarch64N/A
d12.x86_64N/A
d12.aarch64N/A
PIGSTY 1.1.0
PIGSTY 1.1.0
PIGSTY 1.1.0
PIGSTY 1.1.0
d13.x86_64N/A
PIGSTY 1.1.0
PIGSTY 1.1.0
PIGSTY 1.1.0
PIGSTY 1.1.0
d13.aarch64N/A
PIGSTY 1.1.0
PIGSTY 1.1.0
PIGSTY 1.1.0
PIGSTY 1.1.0
u22.x86_64N/A
PIGSTY 1.1.0
PIGSTY 1.1.0
PIGSTY 1.1.0
PIGSTY 1.1.0
u22.aarch64N/A
PIGSTY 1.1.0
PIGSTY 1.1.0
PIGSTY 1.1.0
PIGSTY 1.1.0
u24.x86_64N/A
PIGSTY 1.1.0
PIGSTY 1.1.0
PIGSTY 1.1.0
PIGSTY 1.1.0
u24.aarch64N/A
PIGSTY 1.1.0
PIGSTY 1.1.0
PIGSTY 1.1.0
PIGSTY 1.1.0
u26.x86_64N/A
u26.aarch64N/A
PIGSTY 1.1.0
PIGSTY 1.1.0
PIGSTY 1.1.0
PIGSTY 1.1.0

Build

You can build the RPM / DEB packages for pg_statkit using pig build:

pig build pkg pg_statkit         # build RPM / DEB packages

Install

You can install pg_statkit directly. First, make sure the PGDG and PIGSTY repositories are added and enabled:

pig repo add pgsql -u          # Add repo and update cache

Install the extension using pig or apt/yum/dnf:

Install
pig install pg_statkit;          # Install for current active PG version
pig
pig ext install -y pg_statkit -v 17  # PG 17
pig ext install -y pg_statkit -v 16  # PG 16
pig ext install -y pg_statkit -v 15  # PG 15
pig ext install -y pg_statkit -v 14  # PG 14
dnf
dnf install -y pg_statkit_17       # PG 17
dnf install -y pg_statkit_16       # PG 16
dnf install -y pg_statkit_15       # PG 15
dnf install -y pg_statkit_14       # PG 14
apt
apt install -y postgresql-17-pg-statkit   # PG 17
apt install -y postgresql-16-pg-statkit   # PG 16
apt install -y postgresql-15-pg-statkit   # PG 15
apt install -y postgresql-14-pg-statkit   # PG 14

Create Extension:

CREATE EXTENSION pg_statkit;

Usage

Sources:

pg_statkit provides descriptive statistics and clinical effect-size functions over PostgreSQL arrays without exporting source data to a separate analysis process.

Enablement

Release 1.1.0 builds and tests PostgreSQL 13–17 with pgrx 0.18.1. Install the matching native artifact, then create the non-relocatable, untrusted extension as a superuser:

CREATE EXTENSION pg_statkit;

It does not require preloading or a restart.

Descriptive Statistics

Functions accept double precision[]; explicitly cast array literals because decimal literals otherwise form numeric[].

SELECT statkit_mean('{1,2,3,4,5}'::float8[]);
SELECT statkit_median('{1,2,3,4,5}'::float8[]);
SELECT statkit_iqr('{1,2,3,4,5}'::float8[]);
SELECT statkit_percentile('{1,2,3,4,5}'::float8[], 40);

SELECT patient_id,
       statkit_median(array_agg(value::float8)) AS median_value
FROM measurements
GROUP BY patient_id;

The surface also includes variance, population/sample standard deviation, MAD, coefficient of variation, and standard error.

Effect Sizes and Interpretation

statkit_risk_difference, statkit_risk_ratio, and statkit_odds_ratio accept a 2×2 table as four bigint counts. statkit_cohens_d, statkit_hedges_g, and statkit_glass_delta accept two samples.

SELECT statkit_odds_ratio(a => 8, b => 2, c => 2, d => 8);

SELECT statkit_cohens_d(
  array_agg(value::float8) FILTER (WHERE arm = 'treatment'),
  array_agg(value::float8) FILTER (WHERE arm = 'control')
)
FROM trial;

The odds-ratio function applies a 0.5 correction when any cell is zero. Undefined inputs return NULL. Version 1.1.0 does not provide confidence intervals, hypothesis tests, or assumption checks; use a full statistical package when those are required for research conclusions.

Was this page helpful?