You need a sample of numerical data from a population with a known standard deviation (or a large enough sample size) to run a z-test. The z-test compares a sample mean to a known population mean (one-sample) or compares the means of two independent groups (two-sample) when the population variance is known or the sample size is large (typically n ≥ 30).
What Is a Z-Test and When Is It Used?
A z-test is a statistical hypothesis test that determines whether the difference between a sample statistic and a population parameter is statistically significant, assuming the data follows a normal distribution. It is used when the population standard deviation is known, or when the sample size is large enough that the sampling distribution of the mean is approximately normal (by the Central Limit Theorem). Common applications include quality control (e.g., checking if a batch of products meets a specification), standardized testing (comparing a class average to a national average), and medical research (comparing a treatment group to a known baseline).
Types of Z-Tests and Their Data Requirements
There are several types of z-tests, each with specific data requirements:
- One-sample z-test: You need a single sample of continuous numerical data, the population mean (μ) under the null hypothesis, and the population standard deviation (σ) or a large sample (n ≥ 30) to estimate it.
- Two-sample z-test: You need two independent samples of continuous numerical data, the population standard deviations for both groups (or large sample sizes), and you compare the difference between the two sample means.
- Proportion z-test (one-sample or two-sample): You need categorical data (success/failure) and the hypothesized population proportion (p₀) for a one-sample test, or two independent samples for comparing proportions.
For all types, the data must be randomly sampled, observations must be independent, and the underlying population (or sampling distribution) should be approximately normal.
How to Collect and Prepare Data for a Z-Test
To collect data for a z-test, follow these steps:
- Define your null and alternative hypotheses. For example, H₀: μ = 100, H₁: μ ≠ 100.
- Determine the significance level (α), commonly 0.05.
- Collect a random sample from the population of interest. Ensure the sample is representative and independent.
- Record the numerical values. For a one-sample z-test, you need the sample mean (x̄) and sample size (n). For a two-sample test, you need both sample means and sizes.
- Verify assumptions: If the population standard deviation is unknown, check that n ≥ 30. If the sample size is small, the data should come from a normally distributed population.
Example: Suppose you want to test whether the average height of adult women in a city is 165 cm. You collect a random sample of 50 women and measure their heights. The population standard deviation is known from previous studies to be 6 cm. Your data is the list of 50 heights.
How to Choose Between Z-Test and T-Test
The main decision factor is whether the population standard deviation is known and the sample size.
- Use a z-test when: The population standard deviation (σ) is known, OR the sample size is large (n ≥ 30) regardless of σ (due to Central Limit Theorem).
- Use a t-test when: The population standard deviation is unknown and the sample size is small (n < 30). The t-test is more robust with small samples because it accounts for extra uncertainty.
In practice, the population standard deviation is rarely known, so t-tests are more common. However, many textbooks and software use z-tests for large samples because the t-distribution approximates the normal distribution as n grows.
Common Problems and Misconceptions
One common misconception is that you need a sample size of at least 30 to use a z-test. While n ≥ 30 is a rule of thumb, it is not a strict requirement if the population is normally distributed and σ is known. Another issue is using a z-test when the population standard deviation is unknown and the sample is small; this can lead to inaccurate p-values. Also, ensure your data is continuous and measured on an interval or ratio scale for mean-based z-tests. For proportion z-tests, the data must be categorical with two outcomes (e.g., success/failure), and you need at least 10 successes and 10 failures in the sample to approximate normality.
Real-World Example: Quality Control
Imagine a factory produces bolts with a nominal diameter of 10 mm. The process has a known standard deviation of 0.2 mm. A quality control engineer samples 40 bolts and measures their diameters. The sample mean is 10.05 mm. To test if the process is on target, the engineer uses a one-sample z-test:
- H₀: μ = 10, H₁: μ ≠ 10
- z = (x̄ – μ) / (σ / √n) = (10.05 – 10) / (0.2 / √40) ≈ 1.58
- At α = 0.05, the critical z-value is ±1.96. Since 1.58 < 1.96, the engineer fails to reject H₀, concluding the process is likely on target.
This shows how the z-test uses the sample mean, known σ, and sample size to make a decision.
Alternatives to the Z-Test
When the assumptions for a z-test are not met, consider these alternatives:
- t-test: For small samples with unknown population standard deviation.
- Mann-Whitney U test: A nonparametric alternative for comparing two independent groups when data is not normally distributed.
- Wilcoxon signed-rank test: For paired data when normality is violated.
- Bootstrap methods: Resampling techniques that do not rely on distributional assumptions.
These alternatives are useful when your data is skewed, ordinal, or has outliers.
Frequently Asked Questions
Can I use a z-test if the population standard deviation is unknown?
Yes, if your sample size is large (n ≥ 30), you can estimate the population standard deviation with the sample standard deviation (s) and still use a z-test because the sampling distribution is approximately normal. For small samples, use a t-test instead.
What is the minimum sample size for a z-test?
There is no strict minimum, but a common rule of thumb is n ≥ 30 for the Central Limit Theorem to apply when the population distribution is not normal. If the population is normally distributed and σ is known, even a small sample (e.g., n = 10) can be used.
What if my data is not normally distributed?
If the sample size is large, the z-test is robust to non-normality due to the Central Limit Theorem. For small samples, consider a nonparametric test like the Mann-Whitney U test or transform the data.
Can I use a z-test for proportions?
Yes, the one-sample proportion z-test compares a sample proportion to a hypothesized population proportion. You need categorical data with two outcomes, and the sample size should satisfy np₀ ≥ 10 and n(1-p₀) ≥ 10.
How do I calculate the z-score in Excel?
In Excel, you can use the formula =(sample_mean - population_mean)/(population_sd/SQRT(n)) directly. For a two-sample z-test, use =(mean1 - mean2)/SQRT((sd1^2/n1)+(sd2^2/n2)). Then use NORM.S.DIST to find the p-value.
What is the difference between z-test and z-score?
A z-score is a single data point’s distance from the mean in standard deviations. A z-test is a hypothesis test that uses the z-score of the sample mean to determine statistical significance. The z-test statistic is essentially a z-score for the sample mean.
Related
- Data Entry Jobs: No Experience Needed?
- Company P&L and Balance Sheet Format Explained
- Housekeeping Checklist Template Excel: Free & How to Build
Try it: the Date Difference Calculator: days, months, years and weekdays between two dates, with the DATEDIF formulas.
More in How-to basics
- Excel Data Validation List: Allow Multiple Values?Excel’s standard data validation list lets a cell accept one item from a dropdown; it does not let…
- Excel Find Minimum Value Based on Criteria in a RangeTo find the smallest value that meets one or more conditions, use Excel’s MINIFS function. With regions in…
- Jurong East Printing Shop: Where to Print in SingaporeIf you are looking for a printing shop in Jurong East, the most direct answer is that there…
- Excel: How to Split Text Into Two Columns Without ErrorsTo split text in Excel, select the cells, choose Data > Text to Columns, select Delimited or Fixed…
- Google Docs and Google Sheets: Differences and UsesGoogle Docs is Google’s word-processing app for writing and formatting documents; Google Sheets is its spreadsheet app for…
- Insert a Checkbox in Excel on Windows 7: Step-by-StepTo insert a checkbox in Excel on Windows 7, use the Form Controls option: enable the Developer tab,…
Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources
Spotted an error in this guide? Let us know.