A Z-test is any statistical test for which the distribution of the test statistic under the null hypothesis can be approximated by a normal distribution. Z-test tests the mean of a distribution. For each significance level in the confidence interval, the Z-test has a single critical value (for example, 1.96 for 5% two-tailed), which makes it more convenient than the Student's t-test whose critical values are defined by the sample size (through the corresponding degrees of freedom). Both the Z-test and Student's t-test have similarities in that they both help determine the significance of a set of data. However, the Z-test requires knowing the population deviation, which is sometimes difficult to determine, making the t-test more convenient.
Applicability Because of the central limit theorem, many test statistics are approximately normally distributed for large samples. Therefore, many statistical tests can be conveniently performed as approximate Z-tests if the sample size is large or the population variance is known. If the population variance is unknown (and therefore has to be estimated from the sample itself) and the sample size is not large (n < 30), the Student's t-test may be more appropriate (in some cases, n < 50, as described below).
Procedure The procedure to perform a Z-test on a statistic T {\displaystyle T} that is approximately normally distributed under the null hypothesis is as follows:
Estimate the expected value μ of T {\displaystyle T} under the null hypothesis and obtain an estimate s of the standard deviation of T {\displaystyle T} . Determine the properties of T {\displaystyle T} : one-tailed or two-tailed. For null hypothesis H0: μ ≥ μ0 vs alternative hypothesis H1: μ < μ0, it is lower/left-tailed (one-tailed). For null hypothesis H0: μ ≤ μ0 vs alternative hypothesis H1: μ > μ0, it is upper/right-tailed (one-tailed). For null hypothesis H0: μ = μ0 vs alternative hypothesis H1: μ ≠ μ0, it is two-tailed. Calculate the standard score: Z = T ¯ − μ 0 s {\displaystyle Z={\frac {{\bar {T}}-\mu _{0}}{s}}}
One-tailed and two-tailed p-values can be calculated as Φ ( Z ) {\displaystyle \Phi (Z)} (for lower/left-tailed tests), Φ ( − Z ) {\displaystyle \Phi (-Z)} (for upper/right-tailed tests) and 2 Φ ( − | Z | ) {\displaystyle 2\Phi (-|Z|)} (for two-tailed tests), where Φ {\displaystyle \Phi } is the standard normal cumulative distribution function.
Use in location testing The term "Z-test" is often used to refer specifically to the one-sample location test comparing the mean of a set of measurements to a given constant when the sample variance is known. For example, if the observed data X1, ..., Xn are (i) independent, (ii) have a common mean μ, and (iii) have a common variance σ2, then the sample average X has mean μ and variance σ 2 n {\displaystyle {\frac {\sigma ^{2}}{n}}} . The null hypothesis is that the mean value of X is a given number μ0. We can use X as a test-statistic, rejecting the null hypothesis if X − μ0 is large. To calculate the standardized statistic Z = ( X ¯ − μ 0 ) s {\displaystyle Z={\frac {({\bar {X}}-\mu _{0})}{s}}} , we need to either know or have an approximate value for σ2, from which we can calculate s 2 = σ 2 n {\displaystyle s^{2}={\frac {\sigma ^{2}}{n}}} . In some applications, σ2 is known, but this is uncommon. If the sample size is moderate or large, we can substitute the sample variance for σ2, giving a plug-in test. The resulting test will not be an exact Z-test since the uncertainty in the sample variance is not accounted for—however, it will be a good approximation unless the sample size is small. A t-test can be used to account for the uncertainty in the sample variance when the data are exactly normal. Difference between Z-test and t-test: Z-test is used when sample size is large (n > 50), or the population variance is known. t-test is used when sample size is small (n < 50) and population variance is unknown. There is no universal constant at which the sample size is generally considered large enough to justify use of the plug-in test. Typical rules of thumb: the sample size should be 50 observations or more. For large sample sizes, the t-test procedure gives almost identical p-values as the Z-test procedure. Other location tests that can be performed as Z-tests are the two-sample location test and the paired difference test.
Conditions For the Z-test to be applicable, certain conditions must be met.
… excerpt ends here. Continue reading the full article.


