Understand the idea
The z-test measures how far the sample mean is from the value you are testing (written μ₀), in units of the standard error σ/√n (how much the mean of n values typically varies from sample to sample). A z of 2 means the sample mean is two standard errors above μ₀.
It needs σ, the population standard deviation, known before you look at the data: a published value or a long-run process value. If you would use the standard deviation of your own sample, the right test is the one-sample t-test, which allows for the uncertainty in that estimate.
A small p-value means a sample mean this far from μ₀ would be rare if the true mean were μ₀. A large p-value means there is no clear evidence of a difference; it does not show that the mean equals μ₀. The confidence interval gives the means that remain compatible with the data.
Practitioner explanation
KernelStats computes z from the column's non-missing values and the σ you enter, with p from the standard normal: 2P(Z ≥ |z|) two-sided, P(Z ≥ z) or P(Z ≤ z) one-sided. The interval follows R's BSDA::z.test: two-sided for a two-sided test, a one-sided bound for a one-sided test, so the bound and the test always agree; α = 1 − the confidence level.
The card checks the stated σ against the sample's own spread with a two-sided chi-square test of the variance ((n − 1)s²/σ² on n − 1 df; sensitive to non-normality, so a screen) and reports Shapiro-Wilk normality. It also shows the one-sample t-test under Alternative Tests. The standardized effect d = (x̄ − μ₀)/σ and the detectable effect at 80% power are design-honest: no observed power is reported. The worked example's numbers agree with BSDA::z.test in R 4.5.3.
When to use it
Consider it when
One numeric variable, a reference mean μ₀, and a population standard deviation σ known from outside the data (a long-run process SD, a published test-score SD, a textbook exercise that states σ).
Use caution when
When σ is estimated from the same sample (use the one-sample t-test), when the sample is small with a few extreme values (cross-check with the Wilcoxon signed-rank test, which then tests the median if the values are roughly symmetric about their middle), or for a proportion (use the proportion test).
Formulas and symbols
z statistic
x̄ the sample mean, μ₀ the hypothesized mean, σ the known population standard deviation, n the number of values used.
Two-sided confidence interval for the mean
z_{1-α/2} the standard normal quantile (1.96 for 95%); one-sided tests use the one-sided bound with z_{1-α}.
Alternatives
- One-Sample t-Test (One-Sample t-Test). σ is not known in advance and is estimated from the sample.
- Wilcoxon Signed-Rank Test (Wilcoxon Signed-Rank Test). Few values and a few extreme ones, and the values are roughly symmetric about their middle: it then tests the median against μ₀. On clearly lopsided values it no longer tests the median; with enough values the z-test or t-test on the mean is the safer choice.
Worked example
Scenario
Penguin body mass (342 birds with a value), μ₀ = 4200 g, σ = 800 g taken as known, two-sided, 95%.
Result
x̄ = 4201.75 g, z = 0.0406, p = 0.9677, 95% CI [4116.97, 4286.54] g, d = 0.002.
Interpretation
No clear evidence that the mean body mass differs from 4200 g; means from about 4117 to 4287 g remain compatible with the data.
Dataset: penguins.csv
Common misconceptions
Misconception
I can use my sample's standard deviation as σ in a z-test.
Correction
That treats an estimate as exact: the p-value comes out too small and the interval too narrow, most of all in small samples. With σ estimated from the data, use the one-sample t-test.
Misconception
A non-significant z-test shows that the mean equals μ₀.
Correction
It shows no clear evidence of a difference. Every mean inside the confidence interval remains compatible with the data.
