# CV-screen confidence-interval calculator

M1 (Comparable-Strata Designer). Accurate confidence intervals for positive, right-skewed data when N is small — built in the log domain and back-transformed to the natural domain. Uses the M1 identity `σ² = ln(1 + CV²)`.

Group 1 (or your single sample) — positive numbers, any separators 4.2 5.1 6.0 7.3 9.8 14.2 31.0
Group 2 (optional — for a two-group comparison)
Load an example:
Example G is real public data: serum bilirubin (mg/dL), patients without vs with ascites in the Mayo Clinic primary-biliary-cirrhosis trial — the small ascites arm reads gamma on the eq-7 check. Dickson et al. (1989); R `survival::pbc`. Reproduce ↗
95% CIs. Nothing leaves your browser.
What this calculator is doing, and the one thing to watch

Why the log domain. If the data are log-normal, then `ln(x)` is exactly normal — so a Student-t interval on the logs is valid without invoking the central limit theorem, even at n = 5–10. Back-transforming with `exp(·)` gives an asymmetric natural-domain interval that respects the skew (the upper arm is longer), instead of the symmetric natural-domain t-interval that can dip below zero.

The catch — geometric vs arithmetic mean. The naive back-transform `exp(ȳ ± t·s_y/√n)` is a CI for the geometric mean = the median of the log-normal, not the arithmetic mean. For the arithmetic mean you must add the variance term: this calculator uses Cox's method on `ȳ + s_y²/2` (Land's method is the exact version). Reporting a back-transformed interval as if it were the arithmetic mean is the classic error.

Heteroscedasticity. Constant CV means SD ∝ mean (multiplicative error) — the signature of variance that grows with the level. The log transform is the variance-stabilizing transform for exactly that case, so it removes natural-scale heteroscedasticity. For two groups, M1's `ρ = ln(1+CV₂²)/ln(1+CV₁²)` screens whether the log-scale variances still differ: ρ≈1 → pooled (Student) t on the logs; ρ≠1 → Welch t on the logs. This calculator picks automatically.

When to not use it. Zeros/negatives (log undefined), heavy tails beyond log-normal, or bimodality. The screen flags these.

M1 cross-check shown in the output compares the directly-estimated log variance `s_y²` against `ln(1+CV²)` from the natural-scale CV; close agreement supports the log-normal model. Cite: Zenodo 10.5281/zenodo.20709963.

## How to build a confidence interval when data are skewed and N < 30

### 1. Why the usual interval breaks here

The textbook 95% confidence interval for a mean is

x̄ ± t(n−1, .975) · s / √n

where x̄ is the sample mean, s the sample standard deviation, n the sample size, and t the Student-t critical value. This formula assumes the sample mean is itself normally distributed. The Central Limit Theorem (CLT) makes that true — but only when n is large or the data are symmetric. With strong right-skew and n < 30 the CLT has not arrived: the interval comes out too short, is forced to be symmetric, and can even dip below zero for a quantity that must be positive. So it is not really a 95% interval.

The multiplier, precisely. Because the interval is two-sided, α = 0.05 is split into 0.025 per tail, so t(n−1, .975) is the 0.975 quantile — the value leaving 2.5% in the upper tail — of the t-distribution on n−1 degrees of freedom. We use t rather than z precisely because s is an estimate of σ; that added uncertainty is what gives t its heavier tails, and t → z as n grows. Here s is the sample SD computed with the (n−1) denominator (Bessel's correction) and the standard error is s/√n.

If you have seen the same interval written with z and s/√(N−1), it is not in conflict. The z form is the large-sample approximation to the t form, and the √(N−1) denominator is simply the algebraic equivalent that arises when s is defined with N in the denominator instead of N−1. The two standard errors are mathematically identical:

sN / √(N−1) = s(N−1) / √N

So the two notations agree; the more general t form is the one that matters at small n — exactly the regime this calculator is built for.

### 2. The fix: change the scale

Many positive, skewed quantities (concentrations, costs, durations, biomarkers) are log-normal: their logarithm is normal. If y = ln(x) is exactly normal, a t-interval built on the y-values is valid at any sample size — it never needed the CLT, because normality is now exact, not approximate. Four steps:

1) yi = ln(xi) 2) compute ȳ, sy 3) ȳ ± t(n−1,.975) · sy/√n 4) apply exp( · )

The back-transformed interval is asymmetric in the original units — the upper arm reaches further, exactly as skew demands.

### 3. Which "average" are you bounding? (the key subtlety)

Back-transforming the log-mean does not give the ordinary arithmetic mean. `exp(ȳ)` is the geometric mean, which for a log-normal equals the median. So there are two different targets:

Median / geometric mean: exp( ȳ ± t · sy/√n )

Arithmetic mean (Cox): exp( ȳ + sy²/2 ± t · √( sy²/n + sy⁴ / [2(n−1)] ) )

The arithmetic mean of a log-normal is `exp(μ + σ²/2)`, so it needs the extra `sy²/2` term. (Land's method is the exact-coverage version of Cox's.) Reporting the back-transformed median as if it were the mean is the most common error in this area — this calculator shows both, labeled.

### 4. Where the coefficient of variation comes in (the screen)

The coefficient of variation CV = s / x̄ is a unit-free measure of relative spread. For a log-normal there is an exact bridge between the natural-scale CV and the log-scale variance σ²:

σ² = ln( 1 + CV² )

This is why the CV is the right trigger: a large CV ⇒ large log-scale spread ⇒ strong skew. It also gives a free honesty check: estimate the log variance two ways — directly as `sy²`, and from the CV as `ln(1+CV²)` — and compare. Close agreement supports the log-normal model; a big gap warns that the data are not log-normal and the back-transformed interval should not be trusted.

A gamma companion (the three-way check). The same CV implies a second reference value under the gamma model — the other canonical skewed-positive law — namely `ψ′(1/CV²)` (the trigamma function). The two model values straddle `CV²`: the log-normal value `ln(1+CV²)` sits just below it and the gamma value `ψ′(1/CV²)` just above (they agree to order CV² and split at order CV⁴). Comparing the observed `sy²` to both turns the honesty check three-way: nearer `ln(1+CV²)` → log-normal (use the log-scale t); nearer `ψ′(1/CV²)` → gamma (a gamma GLM with a log link models the mean directly, with no back-transform bias); outside both → a heavier or lighter tail than either, so fall back to the bootstrap. The output's eq-7 line reports this verdict. (Derivation: the Polygamma Bridge companion note.)

### 5. Heteroscedasticity and comparing two groups

A constant CV means the standard deviation grows in proportion to the mean (SD ∝ mean) — heteroscedasticity, or unequal spread across levels. The log transform is precisely the transform that stabilizes that. For two groups, compare their log-scale variances with M1's ratio

ρ = ln(1 + CV₂²) / ln(1 + CV₁²)

ρ ≈ 1 → equal log spread → use the pooled (Student) t on the logs; ρ far from 1 with unequal group sizes → use the Welch (unequal-variance) t on the logs. The result is reported as a ratio of geometric means, `exp( (ȳ₂ − ȳ₁) ± t · SE )`, because for skewed data a ratio is meaningful where a difference is not.

### 5b. The gamma rescue, and reading either rescue in the natural domain

When the eq-7 check points to gamma rather than log-normal, the logarithm no longer normalizes the data, so the matched rescue is not the log-scale t but a gamma generalized linear model with a log link. It models the mean directly, so the contrast is a ratio of arithmetic means — `exp(β)` — with no back-transformation bias, and its variance function `V(μ)=φμ²` is exactly the mean-proportional spread the CV screen detected. Inference is by analysis of deviance (an F-test).

Carrying either rescue back to the natural domain. The p-value needs no transform: testing “ratio of means = 1” in natural units is the same hypothesis as “difference of log-means = 0”, so the rescued p is the natural-domain p. The interval is formed on the log/link scale and mapped back by exp(·) to an asymmetric natural-domain ratio — geometric-mean ratio for the log route, arithmetic-mean ratio for the gamma route.

Example G (real data — serum bilirubin by ascites): the naive raw-scale t gives p ≈ 5×10⁻⁴; the log-normal rescue returns a geometric-mean ratio 3.45 (95% CI 2.11–5.64, p ≈ 2×10⁻⁵) and the gamma rescue an arithmetic-mean ratio 3.33 (95% CI 1.90–5.81, p ≈ 9×10⁻⁷) — two honest natural-domain effects (a median ratio and a mean ratio), each sharper than the naive interval.

### 6. When NOT to use the log route

If any value is zero or negative, `ln()` is undefined. If the data are skewed but not log-normal (the `sy²` vs `ln(1+CV²)` check disagrees, or the tail is heavier than log-normal), switch to a method that assumes no particular shape: a bias-corrected and accelerated (BCa) bootstrap, or a frankly wider distribution-free interval. You trade some precision for honesty — the right trade when the shape can't be trusted.

### 7. Worked example (Example A, n = 7)

Data: 4.2, 5.1, 6.0, 7.3, 9.8, 14.2, 31.0. t(6,.975) = 2.447.

Natural scale: mean = 11.09, SD = 9.41, CV = 0.85, skew = 2.0. Naive interval = 11.09 ± 2.447 × 9.41/√7 = [2.38, 19.79] (symmetric; ignores the long tail).

Logs: ȳ = 2.173, sy = 0.690.

Geometric mean / median: exp(2.173) = 8.79; CI = exp(2.173 ± 2.447 × 0.690/√7) = [4.64, 16.63] (asymmetric).

Arithmetic mean (Cox): exp(2.173 + 0.690²/2) = 11.15; CI = [5.42, 22.91].

Check: sy² = 0.475 vs ln(1 + 0.85²) = 0.543 — close, so log-normal is reasonable here.

In one sentence: small-N accuracy for skewed data is bought from a distributional assumption (log-normality) instead of from sample size (the CLT) — so the calculator checks that assumption and tells you to fall back to a bootstrap when it fails.