Z-Test Calculator
Calculate the Z-test statistic for comparing two population proportions or means.
Note: This calculator is for Z-tests comparing two proportions. For means, you'll need sample means, standard deviations, and sizes.
Z-Statistic
Understanding the Z-Test for Proportions
The Z-test is a statistical hypothesis test used to determine whether a sample statistic (like a proportion or a mean) is significantly different from a population parameter or to compare two sample statistics. When comparing two independent population proportions (p₁ and p₂), the Z-test is a common method, especially when sample sizes are sufficiently large.
When to Use This Calculator (Comparing Two Proportions)
- You have two independent groups or samples.
- You are interested in comparing the proportion of a certain characteristic or outcome in each group.
- The sample sizes are large enough for the normal approximation to the binomial distribution to be valid (generally, np ≥ 10 and n(1-p) ≥ 10 for both samples, where p is the pooled proportion).
The Math Behind the Z-Statistic
For comparing two independent proportions, the null hypothesis (H₀) typically states that the two population proportions are equal (p₁ = p₂), while the alternative hypothesis (H₁) can be one-sided (p₁ > p₂, p₁ < p₂) or two-sided (p₁ ≠ p₂).
First, we calculate the pooled proportion (p̂), which is an estimate of the common population proportion under the null hypothesis:
p̂ = (x₁ + x₂) / (n₁ + n₂)
Where:
x₁is the number of successes in sample 1 (calculated asn₁ * p̂₁)x₂is the number of successes in sample 2 (calculated asn₂ * p̂₂)n₁is the size of sample 1n₂is the size of sample 2
Then, the Z-test statistic is calculated as:
Z = (p̂₁ - p̂₂) / SE
Where SE is the standard error of the difference between the two proportions, calculated using the pooled proportion:
SE = √[ p̂ * (1 - p̂) * (1/n₁ + 1/n₂) ]
A larger absolute value of the Z-statistic indicates stronger evidence against the null hypothesis.
Interpreting the Z-Statistic
The calculated Z-statistic tells you how many standard errors your observed difference in proportions is away from zero (the difference expected under the null hypothesis).
- Z close to 0: Little to no evidence against the null hypothesis. The observed difference is likely due to random chance.
- Large positive Z: Sample 1 proportion is significantly larger than Sample 2 proportion.
- Large negative Z: Sample 2 proportion is significantly larger than Sample 1 proportion.
To make a formal decision, you would compare the calculated Z-statistic to a critical value from the standard normal distribution (based on your chosen significance level, α) or calculate a p-value. A common rule of thumb is that a Z-statistic with an absolute value greater than approximately 1.96 suggests statistical significance at the α = 0.05 level for a two-tailed test.
Example Calculation
Suppose we want to compare the proportion of customers who click an ad in two different campaigns.
- Campaign 1: 65 clicks out of 100 impressions (p̂₁ = 0.65, n₁ = 100)
- Campaign 2: 58 clicks out of 120 impressions (p̂₂ = 0.58, n₂ = 120)
1. Calculate successes: * x₁ = 100 * 0.65 = 65 * x₂ = 120 * 0.58 = 69.6 (Note: In real data, you'd have whole numbers. For calculation purposes, using the proportion * size gives a precise value.) 2. Calculate pooled proportion (p̂): * p̂ = (65 + 69.6) / (100 + 120) = 134.6 / 220 ≈ 0.6118 3. Calculate standard error (SE): * SE = √[ 0.6118 * (1 – 0.6118) * (1/100 + 1/120) ] * SE = √[ 0.6118 * 0.3882 * (0.01 + 0.008333) ] * SE = √[ 0.2375 * 0.018333 ] * SE = √0.004354 ≈ 0.0660 4. Calculate Z-statistic: * Z = (0.65 – 0.58) / 0.0660 * Z = 0.07 / 0.0660 ≈ 1.06
In this example, the Z-statistic is approximately 1.06. This value is relatively small, suggesting that the difference in click-through rates between the two campaigns is not statistically significant at common significance levels (like 0.05).