NextStatNextStat

NextStat for Biologists & Pharma

Clinical trials, PK/PD, and treatment effects

You design clinical trials, model drug kinetics, and quantify treatment effects. NextStat gives you a fast, reproducible inference engine with survival analysis (Cox PH, Weibull, AFT), pharmacometrics (PK/PD, NLME), GLMs, and Bayesian NUTS — plus validation artifacts designed for GxP and 21 CFR Part 11 audit trails.

Why NextStat for Life Sciences?

Regulatory submissions require reproducible, auditable statistical analyses. NextStat produces deterministic validation reports (JSON + PDF) with dataset SHA-256 hashes, model specifications, environment fingerprints, and per-suite pass/fail — designed for IQ/OQ/PQ validation packs and FDA/EMA review.

What You Already Know → What NextStat Calls It

Bio / PharmaNextStat APIContext
Cox proportional hazardsnextstat.CoxPhModel()Time-to-event with right censoring (Breslow/Efron ties)
Weibull / AFT survivalnextstat.WeibullModel()Parametric survival: Weibull, log-normal AFT
PK 1-compartment oralnextstat.pk_1cmt_oral()Closed-form concentration C(t) with ka, ke, V
NLME (population PK)nextstat.nlme()Log-normal random effects, diagonal Omega, Laplacian approximation
Treatment effect (ATE)nextstat.aipw()Doubly-robust AIPW estimator for observational studies
Logistic regressionnextstat.logistic()Binary outcomes with odds ratios and Wald CIs
Bayesian posteriornextstat.sample_nuts()NUTS/HMC with R-hat, ESS, divergence diagnostics
Validation reportnextstat validation-reportJSON + PDF artifact for IQ/OQ/PQ packs

Quickstart: Survival Analysis

import nextstat
import numpy as np

# Time-to-event data with right censoring
times  = np.array([4.1, 7.3, 2.0, 11.5, 6.8, 1.2, 9.4, 3.7])
events = np.array([True, True, False, True, True, True, False, True])
X = np.array([
    [1, 65], [0, 72], [1, 58], [0, 61],
    [1, 70], [0, 55], [1, 68], [0, 63],
], dtype=float)  # treatment + age

# Cox PH with Efron ties
model = nextstat.CoxPhModel(times, events, X, ties="efron")
result = nextstat.fit(model)
print(f"Hazard ratios: {np.exp(result.params)}")
print(f"Standard errors: {result.std_errors}")

# Weibull parametric survival
weibull = nextstat.WeibullModel(times, events, X)
wb_fit = nextstat.fit(weibull)
print(f"Shape (k): {wb_fit.params[0]:.3f}")
print(f"Covariate effects: {wb_fit.params[2:]}")

Quickstart: Population PK (NLME)

import nextstat

# Population pharmacokinetic model
# 1-compartment oral with log-normal random effects
subjects = [
    {"id": 1, "times": [0.5, 1, 2, 4, 8], "conc": [2.1, 5.3, 4.8, 3.1, 1.2],
     "dose": 100, "weight": 70},
    {"id": 2, "times": [0.5, 1, 2, 4, 8], "conc": [1.8, 4.7, 4.2, 2.8, 0.9],
     "dose": 100, "weight": 85},
    # ... more subjects
]

# Fit population model: fixed effects (θ) + random effects (η)
pop_fit = nextstat.nlme(
    model="pk_1cmt_oral",
    data=subjects,
    fixed={"ka": 1.0, "ke": 0.2, "V": 10.0},  # initial estimates
    random=["ka", "V"],                          # random on absorption + volume
)
print(f"Population ka: {pop_fit.fixed['ka']:.3f}")
print(f"Population V:  {pop_fit.fixed['V']:.2f}")
print(f"Omega (variance of random effects): {pop_fit.omega}")

Validation: GxP-Ready Artifacts

NextStat's validation report is designed for regulated environments. The CLI produces a deterministic JSON artifact + optional PDF suitable for:

  • IQ/OQ/PQ validation packs (FDA 21 CFR Part 11)
  • EMA GxP / CSA (Computer Software Assurance) evidence
  • Per-suite pass/fail with dataset fingerprints (SHA-256)
  • Environment lock: OS, Rust version, cargo.lock hash, Python version
  • Deterministic mode: stable JSON key ordering, reproducible PDF metadata
# Generate validation report (CLI)
nextstat validation-report \
  --apex2 tmp/apex2_master_report.json \
  --workspace workspace.json \
  --out validation_report.json \
  --pdf validation_report.pdf \
  --deterministic

# Or via Makefile (local + CI)
make validation-pack

When to Use NextStat vs NONMEM / R

TaskBest Tool
Complex multi-compartment PK with covariatesNONMEM / Monolix
Quick survival analysis with Kaplan-Meier curvesR (survival / survminer)
Reproducible Cox PH + validation artifactNextStat
Fast NLME for 1-compartment PKNextStat
Bayesian treatment effect with NUTS + diagnosticsNextStat
GPU-accelerated batch hypothesis testingNextStat
Audit-ready validation report (JSON+PDF)NextStat

Next Steps

  • Survival AnalysisCox PH, Weibull, log-normal AFT Survival Analysis
  • Bayesian SamplingNUTS/HMC with full diagnostics Bayesian Sampling
  • Regression & GLMLogistic, Poisson, negative binomial Regression & GLM
  • Validation ReportGxP-ready JSON+PDF artifacts Validation Report
  • Agentic ToolsLLM tool definitions for AI-driven analysis Agentic Tools
  • Server APISelf-hosted GPU inference for shared compute Server API
  • GlossaryHEP ↔ DS ↔ Quant ↔ Bio term mapping Glossary