---
title: Bayesian statistics
description: >-
  Bayesian statistical modeling and PK/PD analysis with PyMC — regression,
  hierarchical models, dose-response curves, and compartmental PK models.
tags:
  - bayesian
---

Bayesian analysis fits a statistical model to your data with PyMC and returns a full posterior over the parameters — not a single point estimate, but a distribution with credible intervals — using MCMC, variational inference, or pathfinder sampling. Reach for it when you need uncertainty-aware regression, hierarchical (mixed-effects) models, dose-response curves, or compartmental pharmacokinetic modeling from a dataset you supply. It is one of the specialized predictors that supplements the main property panels. See the [Predictors overview](/docs/predictors) for where this fits.

## What Bayesian Optimization does

The tool fits one of several model families to a data file you provide (CSV or Parquet) and an outcome/predictor column specification, then samples the posterior with PyMC:

- **regression** — Bayesian linear (or generalized linear, via `link_function`) regression over predictor columns.
- **hierarchical** — multi-level/mixed-effects models, grouped by a `group_column`.
- **time_series** — models indexed by a `time_column`.
- **mixture** — mixture models over the outcome distribution.
- **dose_response** — dose-response curve fitting.
- **pkpd** — pharmacokinetic modeling: one-, two-, or three-compartment models, with `iv_bolus`, `iv_infusion`, or `oral` administration, and an optional population (mixed-effects) mode with per-subject random effects.
- **custom** — user-supplied PyMC model code.

## Inference

- **Method**: `mcmc` (default), `variational`, or `pathfinder`.
- **Likelihood**: `normal` (default), `student_t`, `poisson`, `binomial`, or `beta`.
- **Link function**: `identity` (default), `log`, or `logit`.
- **Sampling**: `num_chains` (default 4), `num_samples` (default 2000), `num_tune` warmup samples (default 1000), `target_accept` (default 0.9).
- **Priors**: optional, as `{param_name: {distribution: "Normal", params: {mu: 0, sigma: 1}}}`.

Typical jobs need no GPU and complete in 2–30 minutes.

## Outputs

- A parameter summary (mean, sd, 3%/97% highest-density interval, ESS, R-hat) as CSV.
- The full posterior trace as NetCDF, for further analysis.
- Diagnostics — divergence count, max R-hat, min effective sample size, and (when `compute_loo`/`compute_waic` are enabled, both on by default) LOO and WAIC for model comparison.
- Trace, posterior, and posterior-predictive-check plots, when `generate_plots` is enabled (default).

## Chat usage

### Example prompts

- "Fit a Bayesian hierarchical model to my dose-response data, grouped by batch"
- "Run a two-compartment PK model on this oral-dose concentration-time data"
- "Fit a Bayesian regression of IC50 against my molecular descriptors and give me credible intervals"

### Workflow chaining

- **Accepts from**: a data file (CSV/Parquet) with your outcome and predictor columns — experimental measurements, PK sampling data, or predictions exported from another tool.
- **Feeds into**: population PK/PD reporting, decision-making that needs a calibrated uncertainty estimate rather than a point value.

## Read next
