Might be a novice question, but the main difference between a t-test and z-test, I was able to understand, is that the z-test calculation requires the SD value of the population where as in a t-test, we do work with SD of the sample itself when calculating the t-statistic. So what is the difference between a t-test and z-test? Can someone please clear this up?
-
1You have tagged this with [tag:machine-learning]. How does this relate to machine learning? – Dave Jan 23 '22 at 14:23
2 Answers
The z-test requires the population standard deviation.
$$ z=\dfrac{ \bar x -\mu_0 }{\sigma/\sqrt n} $$
You don’t estimate $\sigma$ from the data; you know it. If this sounds unreasonable, you’re right,$^{\dagger}$ so we have the t-test, which uses the sample standard deviation, which is calculated from the data.
$$ t=\dfrac{ \bar x-\mu_0 }{s/\sqrt n}\\ s=\dfrac{1}{n-1}\sum\bigg( x_i-\bar x \bigg)^2 $$
$^{\dagger}$There are situations where this is reasonable, but I would consider them the exception.
We can simulate this to show that the equations give different values.
set.seed(2022);
n <- 31;
true_mean <- 0.2;
mu_0 <- 0;
true_sd <- 1;
x <-rnorm(n, true_mean, true_sd);
z_stat <- (mean(x) - mu_0)/(true_sd/sqrt(n));
t_stat <- (mean(x) - mu_0)/(sd(x)/sqrt(n));
z_stat - t_stat
I get a difference of about $0.05$.
Addressing the question in the title, if you know variance or standard deviation, you know the other by either squaring (to get the variance from the standard deviation) or taking the square root (to get the standard deviation from th e variance).
REFERENCES
https://online.stat.psu.edu/stat200/lesson/8/8.2/8.2.3/8.2.3.3
https://online.stat.psu.edu/stat200/lesson/8/8.2/8.2.3/8.2.3.1
- 3,841
- 1
- 8
- 23
-
-
-
@SubhashC.Davar That is false. What makes you think that? // Drop that from the simulation code I gave, and watch how different the values are. When I do so, I get a difference of about $0.47$. – Dave Jan 23 '22 at 16:05
t-statistic converges in distribution to a normal for df-> infinity. Thus, t-test assumes a normal distribution. z-test assumes standard normal distribution. This results in differences in the formulas of two approaches.The two methods apparently should yield same inference!
- 578
- 4
- 18