# Tag Info

## Hot answers tagged z-test

26

@AdamO is right, you simply always use the $t$-test if you don't know the population standard deviation a-priori. You don't have to worry about when to switch to the $z$-test, because the $t$-distribution 'switches' for you. More specifically, the $t$-distribution converges to the normal, thus it is the correct distribution to use at every $N$. There is ...

18

Short version: You don't use a t-test because the obvious statistic doesn't have a t-distribution. It does (approximately) have a z-distribution. Longer version: In the usual t-tests, the t-statistics are all of the form: $\frac{d}{s}$, where $s$ is an estimated standard error of $d$. The t-distribution arises from the following: 1) $d$ is normally ...

16

Let us have a 2x2 frequency table where columns are two groups of respondents and rows are the two responses "Yes" and "No". And we've turned the frequencies into the proportions within group, i.e. into the vertical profiles: Gr1 Gr2 Total Yes p1 p2 p No q1 q2 q -------------- 100% 100% 100% n1 n2 N ...

13

Yes, it's possible to do a chi-square test on this. Specifically, this is the chi-square goodness of fit test. To do it correctly you set up two cells (one for dead, one for not dead), like so: Dead NotDead Total Obs 19 101 120 Exp 12 108 120 The chi-square is $\sum_i (O_i-E_i)^2/E_i$ and has $k-1$ df, where $k$ is the ...

12

The reason you can use a $z$-test with proportion data is because the standard deviation of a proportion is a function of the proportion itself. Thus, once you have estimated the proportion in your sample, you don't have an extra source of uncertainty that you have to take into account. As a result, you can use the normal distribution instead of the $t$ ...

12

The main problem is that if you're going to use the ratio as your response variable, you should be using the weights argument. You must have ignored a warning about "non-integer #successes in a binomial glm" ... Dilution <- c(1/128, 1/64, 1/32, 1/16, 1/8, 1/4, 1/2, 1, 2, 4) NoofPlates <- rep(x=5, times=10) NoPositive <- c(0, 0, 2, 2, 3, 4, 5, 5, 5,...

12

There's nothing to discuss on the matter. Use a $t$-test always for a nonparametric test of differences in means, unless a more sophisticated resampling tool—e.g. permutation or bootstrap—is called for (useful in very small samples with large departures from normality). If the degrees of freedom actually matter, then the $t$-test will provide consistent ...

10

You are mixing a couple of concepts (one of which is really outdated in the age of computers, but still persists anyways). For numerical variables you should use the t-test when you are calculating the standard deviation(s) from the sample(s). If you know the true population standard deviation(s) then you can use the z-test (it is rare that you would know ...

10

I'm not sure that this issue really comes up "often" outside of Stats 101 (introduction to statistics). I'm not sure I've ever seen it. On the other hand, we do present the material that way when teaching introductory courses, because it provides a logical progression: You start with a simple situation where there is only one group and you know the ...

10

My comment was specifically about your articulation of the appropriate one-sample one-sided (aka one-tailed) null hypothesis (not about one-sided tests per se) which, for proportions, should either be $H_{0}: p \ge p_{0}$ with $H_{1}: p < p_{0}$, or $H_{0}: p \le p_{0}$ with $H_{1}: p > p_{0}$. Bear in mind that null hypotheses are articulated before ...

9

Statsmodels has a ztest function that allows you to compare two means, assuming they are independent and have the same standard deviation. See the documentation here If you need to compare means from distributions with different standard deviation, you should use CompareMeans.ztest_ind. See documentation here. There might be other functions I'm missing so ...

9

No, but this wouldn't be that hard to write a function for: def twoSampZ(X1, X2, mudiff, sd1, sd2, n1, n2): from numpy import sqrt, abs, round from scipy.stats import norm pooledSE = sqrt(sd1**2/n1 + sd2**2/n2) z = ((X1 - X2) - mudiff)/pooledSE pval = 2*(1 - norm.cdf(abs(z))) return round(z, 3), round(pval, 4) where X1 = $\bar{X1}$, ...

9

I am leaving this paragraph for the comments to make sense: Probably the assumption of normality in the original populations is too restrictive, and can be forgone focusing on the sampling distribution, and thanks to the central limit theorem, especially for large samples. Applying the $t$ test is probably a good idea if (as is usually the case) you don't ...

9

Let's look at a specific example, a one sample t-test. The t-statistic consists of a numerator and a denominator: $$t = \frac{\bar{X}-\mu_0}{s_X/\sqrt{n}}$$ Both $\bar{X}$ and $s_X$ -- the sample mean and standard deviation -- are random quantities that depend on the (random) sample. Because the random values in the sample we will be taking ($X_1,X_2,...,... 8 Some people call both "the Wald test". See, for example, Wikipedia on the Wald test. Note that if you square the Z statistic you get the chi-square statistic; similarly the square of the two tailed Z critical value is the chi square critical value. So they're not really doing different things. I wouldn't say one really generalizes the other in the case ... 8 The image you used is wrong. If you know the population standard deviation then your statistic follows a normal distribution. When you do not know it, and you estimate from the sample than your statistic follows a t distribution and that is all. In your image and the text that follows the image you reverted yes with no. Other than that when you know the ... 7 I think this is a common misunderstanding of the CLT. Not only does the CLT have nothing to do with preserving type II error (which no one has mentioned here) but it is often not applicable when you must estimate the population variance. The sample variance can be very far from a scaled chi-squared distribution when the data are non-Gaussian, so the CLT may ... 7 To achieve that level of confidence, you would have to satisfy the most stringent critic. They would require you to establish Your sample truly is a simple random sample. The respondents answer honestly and correctly. That if the barest minority, just less than half, of the population actually would answer "yes", you would have less than a$100 - 90\% = 10\...

6

One approach to problems like this is "multilevel" or "hierarchical" modeling: build a model for the individual students' scores which are nested within a model for the schools. The problem you pose is actually very similar to the classic Bayesian problem for "the eight schools," which is discussed in Gelman's Bayesian Data Analysis: students in eight ...

6

It depends. For instance, I'm testing my series for the unit-root, maybe with ADF test. Null in this case means the presence of unit root. Failing to reject null suggests that there might be a unit root in the series. The consequence is that I might have to go with modeling the series with random walk like process instead of autorgressive. So, although it ...

6

With large $N$, your test statistic will be distributed as a normal. Thus, we can refer to your test statistic as "$z$", and we can also use "$z$" to refer to the asymptotic sampling distribution. However, these are not the same $z$'s. When you form your $1-\alpha\%$ confidence interval, you need to multiply the standard error by $z_{1-\alpha/2}$ to get ...

6

This is a tricky question. First, I think a lot of people will denounce the idea of using a z or t test on data which are not continuous. "Your data are ordinal/nominal, use a different test!" they will cry! And they are not wrong; your data are not normal even in theory, so a different test truly is best. But are those other tests necessary? I argue ...

6

This is because Z-test uses standard normal distribution that is set and does not change with number of observations. While the other distributions actually change their shape with number of observations. For example on the graph below you can see comparison of students t distribution for t-test and standard normal distribution for z-test for 3 cases where ...

6

You can just use a Fisher Exact Test. Let us know if you have trouble following what it does. Not super related, but if you're thinking of difference of binomials, it's nice to convince yourself that if $p_1 \neq p_2$, then the difference is not itself a binomial! I think that's kinda fun to think about.

5

Note that the $\beta$'s in your $z$ formula should be $\hat \beta$'s (both in the numerator and denominator). The short answer is 'yes'; as long as (a) the sample sizes are sufficiently large that (i) the $\hat \beta$ terms are close to normal (i.e. the CLT 'kicks in'), and (ii) the two $\hat\sigma$ terms (on which the $SE$ terms are based) are very ...

5

If your distributions are known to be normal, and you have sample mean and standard deviation, you'd use a t-test. If, however, you know the population standard deviation, then you would instead use that in place of the sample standard deviation, giving a z-test, not a t-test. However, I have difficulty thinking of many practical situations where you'd ...

5

All participants answered two questions. One question was answered correctly by 85% and the other question was answered correctly by 65%. I am interested in whether the proportion of correct answers is significantly larger for the first than the second question. That would be a paired test. Why is wrong to use a two-proportions z test in this case? ...

5

As noted in the linked thread, the chi-squared test and the z-test of equal proportions are ultimately the same test. However, not everyone knows that, and the names differ. I will typically use the name "z-test of equal proportions" in discussions and write-ups, or recommend it to people (see, e.g.: What is the difference between McNemar's test and the ...

5

If we fail to reject the null hypothesis, it does not mean that the null hypothesis is true. That's because a hypothesis test does not determine which hypothesis is true, or even which one is very much more likely. What it does assess is whether the evidence available is statistically significant enough to to reject the null hypothesis. So The data doesn'...

Only top voted, non community-wiki answers of a minimum length are eligible