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?
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
-
$\begingroup$ Expansion on the comment in the footnote warrants its own question. $\endgroup$– DaveCommented Jan 23, 2022 at 14:27
-
$\begingroup$ @SubhashC.Davar What do you propose is the correct equation? $\endgroup$– DaveCommented Jan 23, 2022 at 15:45
-
$\begingroup$ @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$. $\endgroup$– DaveCommented Jan 23, 2022 at 16:05
The t-test assumes a normal distribution and uses standard error computed by sample S.D.divided by square root of n(sample-sizes).t-test is small-sample test. The z-test assumes standard normal distribution and a large sample. It invokes true standard deviation i.e. population standard deviation. Does t-test require Standard Deviation of sample for calculation? Yes. Without it you can not calculate standard error required for t-test?