Skip to main content
removed inappropriate tag; formatted; edited for English
Source Link
gung - Reinstate Monica
  • 147.5k
  • 89
  • 406
  • 717

Contradiction between confidence intervals and Zz-test

I've got thea problem with Z$z$-test and confidence intervals. ZThe $z$-test rejects the null hypothesis (proportions are equal), but the confidence intervals are intersect.

Let us consider 2 companies. The proportion of smokers in company A$A$ is p(A)=0.22$p(A)=0.22$. And the proportion of smokers in company B$B$ is p(B)=0.303$p(B)=0.303$. The amount of employees in company A$A$ is 403$403$. And the amount of employees in company B$B$ is 404$404$.

So, we have the folowingfollowing data:

p(A)=0.22
n(A)=403

p(B)=0.303
n(B)=404\begin{align} p(A)&=0.22 &n(A)&=403 \\ p(B)&=0.303 &n(B)&=404 \end{align}

Now let's apply the Z$z$-test by the following forumulaformula for proportions (I'veI took the formula from https://onlinecourses.science.psu.edu/stat414/node/268here):

$$Z= \frac{p(B)-p(A)}{\sqrt{p(1-p)(\frac{1}{n(A)}+\frac{1}{n(b)})}}$$$$z= \frac{p(B)-p(A)}{\sqrt{p(1-p)(\frac{1}{n(A)}+\frac{1}{n(b)})}}$$

Where p$p$ is $$p=\frac{p(A)n(A)+p(B)n(B)}{n(A)+n(B)}$$

I'veI made the following computation: $$p=\frac{0.22*403+0.303*404}{403+404}=0.2614$$

$$z= \frac{0.303-0.22}{\sqrt{0.2614(1-0.2614)(\frac{1}{403}+\frac{1}{404})}}=2.6828$$

So, z$z$ more than 1.96$1.96$, it means that we reject the null hipothesishypothesis. The proportions p(A)$p(A)$ and p(B)$p(B)$ are not equal.

But then I've computed the 95% confidence intervals by the following formulas (I'veI took them formfrom https://onlinecourses.science.psu.edu/stat200/node/48here):

$$low=P-1.96*\sqrt{\frac{P*(1-P)}{N}}$$ $$high=P+1.96*\sqrt{\frac{P*(1-P)}{N}}$$\begin{align} \newcommand{\low}{{\rm low}} \newcommand{\high}{{\rm high}} \low &= P-1.96 \sqrt{\frac{P(1-P)}{N}} \\ \high &= P+1.96 \sqrt{\frac{P(1-P)}{N}} \end{align} Where P$P$ is proportion of smokers in some company and N$N$ is amount of employees in this company.

I've computed the interval for company A$A$: $$low(A)=p(A)-1.96*\sqrt{\frac{p(A)(1-p(A))}{n(A)}}=0.22-1.96*\sqrt{\frac{0.22*0.78}{403}}=0.1796$$ $$high(A)=p(A)+1.96*\sqrt{\frac{p(A)(1-p(A))}{n(A)}}=0.22+1.96*\sqrt{\frac{0.22*0.78}{403}}=0.2604$$\begin{align} \low(A) &= p(A)-1.96 \sqrt{\frac{p(A)(1-p(A))}{n(A)}} = 0.22-1.96 \sqrt{\frac{0.22*0.78}{403}} = 0.1796 \\ \high(A) &= p(A)+1.96 \sqrt{\frac{p(A)(1-p(A))}{n(A)}} = 0.22+1.96 \sqrt{\frac{0.22*0.78}{403}} = 0.2604 \end{align} So, for p(A)$p(A)$ the CI is (0.1796;0.2696)$(0.1796;0.2696)$.

And finally I've computed the interval for the company B$B$: $$low(B)=p(B)-1.96 \sqrt{{p(B)(1-p(B))}{n(B)}} =0.303-1.96 \sqrt{\frac{0.303 * 0.697}{404}}=0.2581$$ $$high(B)=p(B)+1.96*\sqrt{{p(B)(1-p(B))}{n(B)}} =0.303+1.96 \sqrt{\frac{0.303 * 0.697}{404}}=0.3477$$\begin{align} \low(B) &= p(B)-1.96 \sqrt{{p(B)(1-p(B))}{n(B)}} = 0.303-1.96 \sqrt{\frac{0.303 * 0.697}{404}} = 0.2581 \\ \high(B) &= p(B)+1.96 \sqrt{{p(B)(1-p(B))}{n(B)}} = 0.303+1.96 \sqrt{\frac{0.303 * 0.697}{404}} = 0.3477 \end{align} For p(B)$p(B)$ the confidence interval is (0.2581;0.3477)$(0.2581; 0.3477)$.

And now we see that confidence intervals are intersect, but it contradicts the computations for z$z$-test.

Finally I've used a web service for zcomputing the $z$-test and the CI computing. The service draweddrew the intersection of the CI's and rejected the null hipothesishypothesis of zthe $z$-test, too.

Please, could you explain me whatWhat is the cause of the contradiction?

Contradiction between confidence intervals and Z-test

I've got the problem with Z-test and confidence intervals. Z-test rejects null hypothesis (proportions are equal), but confidence intervals are intersect.

Let us consider 2 companies. The proportion of smokers in company A is p(A)=0.22. And the proportion of smokers in company B is p(B)=0.303. The amount of employees in company A is 403. And the amount of employees in company B is 404.

So, we have the folowing data:

p(A)=0.22
n(A)=403

p(B)=0.303
n(B)=404

Now let's apply the Z-test by the following forumula for proportions (I've took the formula from https://onlinecourses.science.psu.edu/stat414/node/268):

$$Z= \frac{p(B)-p(A)}{\sqrt{p(1-p)(\frac{1}{n(A)}+\frac{1}{n(b)})}}$$

Where p is $$p=\frac{p(A)n(A)+p(B)n(B)}{n(A)+n(B)}$$

I've made the following computation: $$p=\frac{0.22*403+0.303*404}{403+404}=0.2614$$

$$z= \frac{0.303-0.22}{\sqrt{0.2614(1-0.2614)(\frac{1}{403}+\frac{1}{404})}}=2.6828$$

So, z more than 1.96, it means that we reject the null hipothesis. The proportions p(A) and p(B) are not equal.

But then I've computed the 95% confidence intervals by the following formulas (I've took them form https://onlinecourses.science.psu.edu/stat200/node/48):

$$low=P-1.96*\sqrt{\frac{P*(1-P)}{N}}$$ $$high=P+1.96*\sqrt{\frac{P*(1-P)}{N}}$$ Where P is proportion of smokers in some company and N is amount of employees in this company.

I've computed the interval for company A: $$low(A)=p(A)-1.96*\sqrt{\frac{p(A)(1-p(A))}{n(A)}}=0.22-1.96*\sqrt{\frac{0.22*0.78}{403}}=0.1796$$ $$high(A)=p(A)+1.96*\sqrt{\frac{p(A)(1-p(A))}{n(A)}}=0.22+1.96*\sqrt{\frac{0.22*0.78}{403}}=0.2604$$ So, for p(A) the CI is (0.1796;0.2696).

And finally I've computed the interval for the company B: $$low(B)=p(B)-1.96 \sqrt{{p(B)(1-p(B))}{n(B)}} =0.303-1.96 \sqrt{\frac{0.303 * 0.697}{404}}=0.2581$$ $$high(B)=p(B)+1.96*\sqrt{{p(B)(1-p(B))}{n(B)}} =0.303+1.96 \sqrt{\frac{0.303 * 0.697}{404}}=0.3477$$ For p(B) the confidence interval is (0.2581;0.3477).

And now we see that confidence intervals are intersect, but it contradicts the computations for z-test.

Finally I've used a web service for z-test and CI computing. The service drawed intersection of CI's and rejected the null hipothesis of z-test too.

Please, could you explain me what the cause of the contradiction?

Contradiction between confidence intervals and z-test

I've got a problem with $z$-test and confidence intervals. The $z$-test rejects the null hypothesis (proportions are equal), but the confidence intervals are intersect.

Let us consider 2 companies. The proportion of smokers in company $A$ is $p(A)=0.22$. And the proportion of smokers in company $B$ is $p(B)=0.303$. The amount of employees in company $A$ is $403$. And the amount of employees in company $B$ is $404$.

So, we have the following data: \begin{align} p(A)&=0.22 &n(A)&=403 \\ p(B)&=0.303 &n(B)&=404 \end{align}

Now let's apply the $z$-test by the following formula for proportions (I took the formula from here):

$$z= \frac{p(B)-p(A)}{\sqrt{p(1-p)(\frac{1}{n(A)}+\frac{1}{n(b)})}}$$

Where $p$ is $$p=\frac{p(A)n(A)+p(B)n(B)}{n(A)+n(B)}$$

I made the following computation: $$p=\frac{0.22*403+0.303*404}{403+404}=0.2614$$

$$z= \frac{0.303-0.22}{\sqrt{0.2614(1-0.2614)(\frac{1}{403}+\frac{1}{404})}}=2.6828$$

So, $z$ more than $1.96$, it means that we reject the null hypothesis. The proportions $p(A)$ and $p(B)$ are not equal.

But then I've computed the 95% confidence intervals by the following formulas (I took them from here):

\begin{align} \newcommand{\low}{{\rm low}} \newcommand{\high}{{\rm high}} \low &= P-1.96 \sqrt{\frac{P(1-P)}{N}} \\ \high &= P+1.96 \sqrt{\frac{P(1-P)}{N}} \end{align} Where $P$ is proportion of smokers in some company and $N$ is amount of employees in this company.

I've computed the interval for company $A$: \begin{align} \low(A) &= p(A)-1.96 \sqrt{\frac{p(A)(1-p(A))}{n(A)}} = 0.22-1.96 \sqrt{\frac{0.22*0.78}{403}} = 0.1796 \\ \high(A) &= p(A)+1.96 \sqrt{\frac{p(A)(1-p(A))}{n(A)}} = 0.22+1.96 \sqrt{\frac{0.22*0.78}{403}} = 0.2604 \end{align} So, for $p(A)$ the CI is $(0.1796;0.2696)$.

And finally I've computed the interval for the company $B$: \begin{align} \low(B) &= p(B)-1.96 \sqrt{{p(B)(1-p(B))}{n(B)}} = 0.303-1.96 \sqrt{\frac{0.303 * 0.697}{404}} = 0.2581 \\ \high(B) &= p(B)+1.96 \sqrt{{p(B)(1-p(B))}{n(B)}} = 0.303+1.96 \sqrt{\frac{0.303 * 0.697}{404}} = 0.3477 \end{align} For $p(B)$ the confidence interval is $(0.2581; 0.3477)$.

And now we see that confidence intervals are intersect, but it contradicts the computations for $z$-test.

Finally I've used a web service for computing the $z$-test and the CI. The service drew the intersection of the CI's and rejected the null hypothesis of the $z$-test, too.

What is the cause of the contradiction?

deleted 2 characters in body
Source Link

I've got the problem with Z-test and confidence intervals. Z-test rejects null hypothesis (proportions are equal), but confidence intervals are intersect.

Let us consider 2 companies. The proportion of smokers in company A is p(A)=0.22. And the proportion of smokers in company B is p(B)=0.303. The amount of employees in company A is 403. And the amount of employees in company B is 404.

So, we have the folowing data:

p(A)=0.22
n(A)=403

p(B)=0.303
n(B)=404

Now let's apply the Z-test by the following forumula for proportions (I've took the formula from https://onlinecourses.science.psu.edu/stat414/node/268):

$$Z= \frac{p(B)-p(A)}{\sqrt{p(1-p)(\frac{1}{n(A)}+\frac{1}{n(b)})}}$$

Where p is $$p=\frac{p(A)n(A)+p(B)n(B)}{n(A)+n(B)}$$

I've made the following computation: $$p=\frac{0.22*403+0.303*404}{403+404}=0.2614$$

$$z= \frac{0.303-0.22}{\sqrt{0.2614(1-0.2614)(\frac{1}{403}+\frac{1}{404})}}=2.6828$$

So, z more than 1.96, it means that we reject the null hipothesis. The proportions p(A) and p(B) are not equal.

But then I've computed the 95% confidence intervals by the following formulas (I've took them form https://onlinecourses.science.psu.edu/stat200/node/48):

$$low=P-1.96*\sqrt{\frac{P*(1-P)}{N}}$$ $$high=P+1.96*\sqrt{\frac{P*(1-P)}{N}}$$ Where P is proportion of smokers in some company and N is amount of employees in this company.

I've computed the interval for company A: $$low(A)=p(A)-1.96*\sqrt{\frac{p(A)(1-p(A))}{n(A)}}=0.22-1.96*\sqrt{\frac{0.22*0.78}{403}}=0.1796$$ $$high(A)=p(A)+1.96*\sqrt{\frac{p(A)(1-p(A))}{n(A)}}=0.22+1.96*\sqrt{\frac{0.22*0.78}{403}}=0.2604$$ So, for p(A) the CI is (0.1796;0.2696).

And finally I've computed the interval for the company B: $$low(B)=p(B)-1.96 \sqrt{{p(B)(1-p(B))}{n(B)}} =0.303-1.96 \sqrt{\frac{0.303 * 0.697}{404}}=0.2581$$ $$high(B)=p(B)+1.96*\sqrt{{p(B)(1-p(B))}{n(B)}} =0.303+1.96 \sqrt{\frac{0.303 * 0.697}{404}}=0.3477$$ For p(B) the confidence interval is (0.2581;0.3477).

And now we see that confidence intervals are intersect, but it contradicts the computations for z-test.

Finally I've used a web service for z-test and CI computing. The service drawed intersection of CI's and rejected the null hipothesis of z-test too.

Please, could you explain me what the cause of the contradiction?

I've got the problem with Z-test and confidence intervals. Z-test rejects null hypothesis (proportions are equal), but confidence intervals are intersect.

Let us consider 2 companies. The proportion of smokers in company A is p(A)=0.22. And the proportion of smokers in company B is p(B)=0.303. The amount of employees in company A is 403. And the amount of employees in company B is 404.

So, we have the folowing data:

p(A)=0.22
n(A)=403

p(B)=0.303
n(B)=404

Now let's apply the Z-test by the following forumula for proportions (I've took the formula from https://onlinecourses.science.psu.edu/stat414/node/268):

$$Z= \frac{p(B)-p(A)}{\sqrt{p(1-p)(\frac{1}{n(A)}+\frac{1}{n(b)})}}$$

Where p is $$p=\frac{p(A)n(A)+p(B)n(B)}{n(A)+n(B)}$$

I've made the following computation: $$p=\frac{0.22*403+0.303*404}{403+404}=0.2614$$

$$z= \frac{0.303-0.22}{\sqrt{0.2614(1-0.2614)(\frac{1}{403}+\frac{1}{404})}}=2.6828$$

So, z more than 1.96, it means that we reject the null hipothesis. The proportions p(A) and p(B) are not equal.

But then I've computed the 95% confidence intervals by the following formulas (I've took them form https://onlinecourses.science.psu.edu/stat200/node/48):

$$low=P-1.96*\sqrt{\frac{P*(1-P)}{N}}$$ $$high=P+1.96*\sqrt{\frac{P*(1-P)}{N}}$$ Where P is proportion of smokers in some company and N is amount of employees in this company.

I've computed the interval for company A: $$low(A)=p(A)-1.96*\sqrt{\frac{p(A)(1-p(A))}{n(A)}}=0.22-1.96*\sqrt{\frac{0.22*0.78}{403}}=0.1796$$ $$high(A)=p(A)+1.96*\sqrt{\frac{p(A)(1-p(A))}{n(A)}}=0.22+1.96*\sqrt{\frac{0.22*0.78}{403}}=0.2604$$ So, for p(A) the CI is (0.1796;0.2696).

And finally I've computed the interval for the company B: $$low(B)=p(B)-1.96 \sqrt{{p(B)(1-p(B))}{n(B)}} =0.303-1.96 \sqrt{\frac{0.303 * 0.697}{404}}=0.2581$$ $$high(B)=p(B)+1.96*\sqrt{{p(B)(1-p(B))}{n(B)}} =0.303+1.96 \sqrt{\frac{0.303 * 0.697}{404}}=0.3477$$ For p(B) the confidence interval is (0.2581;0.3477).

And now we see that confidence intervals are intersect, but it contradicts the computations for z-test.

Finally I've used a web service for z-test and CI computing. The service drawed intersection of CI's and rejected the null hipothesis of z-test too.

Please, could you explain me what the cause of the contradiction?

I've got the problem with Z-test and confidence intervals. Z-test rejects null hypothesis (proportions are equal), but confidence intervals are intersect.

Let us consider 2 companies. The proportion of smokers in company A is p(A)=0.22. And the proportion of smokers in company B is p(B)=0.303. The amount of employees in company A is 403. And the amount of employees in company B is 404.

So, we have the folowing data:

p(A)=0.22
n(A)=403

p(B)=0.303
n(B)=404

Now let's apply the Z-test by the following forumula for proportions (I've took the formula from https://onlinecourses.science.psu.edu/stat414/node/268):

$$Z= \frac{p(B)-p(A)}{\sqrt{p(1-p)(\frac{1}{n(A)}+\frac{1}{n(b)})}}$$

Where p is $$p=\frac{p(A)n(A)+p(B)n(B)}{n(A)+n(B)}$$

I've made the following computation: $$p=\frac{0.22*403+0.303*404}{403+404}=0.2614$$

$$z= \frac{0.303-0.22}{\sqrt{0.2614(1-0.2614)(\frac{1}{403}+\frac{1}{404})}}=2.6828$$

So, z more than 1.96, it means that we reject the null hipothesis. The proportions p(A) and p(B) are not equal.

But then I've computed the 95% confidence intervals by the following formulas (I've took them form https://onlinecourses.science.psu.edu/stat200/node/48):

$$low=P-1.96*\sqrt{\frac{P*(1-P)}{N}}$$ $$high=P+1.96*\sqrt{\frac{P*(1-P)}{N}}$$ Where P is proportion of smokers in some company and N is amount of employees in this company.

I've computed the interval for company A: $$low(A)=p(A)-1.96*\sqrt{\frac{p(A)(1-p(A))}{n(A)}}=0.22-1.96*\sqrt{\frac{0.22*0.78}{403}}=0.1796$$ $$high(A)=p(A)+1.96*\sqrt{\frac{p(A)(1-p(A))}{n(A)}}=0.22+1.96*\sqrt{\frac{0.22*0.78}{403}}=0.2604$$ So, for p(A) the CI is (0.1796;0.2696).

And finally I've computed the interval for the company B: $$low(B)=p(B)-1.96 \sqrt{{p(B)(1-p(B))}{n(B)}} =0.303-1.96 \sqrt{\frac{0.303 * 0.697}{404}}=0.2581$$ $$high(B)=p(B)+1.96*\sqrt{{p(B)(1-p(B))}{n(B)}} =0.303+1.96 \sqrt{\frac{0.303 * 0.697}{404}}=0.3477$$ For p(B) the confidence interval is (0.2581;0.3477).

And now we see that confidence intervals are intersect, but it contradicts the computations for z-test.

Finally I've used a web service for z-test and CI computing. The service drawed intersection of CI's and rejected the null hipothesis of z-test too.

Please, could you explain me what the cause of the contradiction?

added 12 characters in body
Source Link

I've got the problem with Z-test and confidence intervals. Z-test rejects null hipothesishypothesis (proportions are equal), but confidence intervals are intersect.

Let us consider 2 companies. The proportion of smokers in company A is p(A)=0.22. And the proportion of smokers in company B is p(B)=0.303. The amount of employees in company A is 403. And the amount of employees in company B is 404.

So, we have the folowing data:

p(A)=0.22
n(A)=403

p(B)=0.303
n(B)=404

Now let's apply the Z-test by the following forumula for proportions (I've took the formula from https://onlinecourses.science.psu.edu/stat414/node/268):

$$Z= \frac{p(B)-p(A)}{\sqrt{p(1-p)(\frac{1}{n(A)}+\frac{1}{n(b)})}}$$

Where p is $$p=\frac{p(A)n(A)+p(B)n(B)}{n(A)+n(B)}$$

I've made the following computation: $$p=\frac{0.22*403+0.303*404}{403+404}=0.2614$$

$$z= \frac{0.303-0.22}{\sqrt{0.2614(1-0.2614)(\frac{1}{403}+\frac{1}{404})}}=2.6828$$

So, z more than 1.96, it means that we reject the null hipothesis. The proportions p(A) and p(B) are not equal.

But then I've computed the 5%95% confidence intervals by the following formulas (I've took them form https://onlinecourses.science.psu.edu/stat200/node/48):

$$low=P-1.96*\sqrt{\frac{P*(1-P)}{N}}$$ $$high=P+1.96*\sqrt{\frac{P*(1-P)}{N}}$$ Where P is proportion of smokers in some company and N is amount of employees in this company.

I've computed the interval for company A: $$low(A)=p(A)-1.96*\sqrt{{p(A)(1-p(A))}{n(A)}}=0.22-1.96*sqrt{\frac{0.22*0.78}{403}}=0.1796$$$$low(A)=p(A)-1.96*\sqrt{\frac{p(A)(1-p(A))}{n(A)}}=0.22-1.96*\sqrt{\frac{0.22*0.78}{403}}=0.1796$$ $$high(A)=p(A)+1.96*\sqrt{{p(A)(1-p(A))}{n(A)}}=0.22+1.96*sqrt{\frac{0.22*0.78}{403}}=0.2604$$$$high(A)=p(A)+1.96*\sqrt{\frac{p(A)(1-p(A))}{n(A)}}=0.22+1.96*\sqrt{\frac{0.22*0.78}{403}}=0.2604$$ So, for p(A) the CI is (0.1796;0.2696).

And finally I've computed the interval for the company B: $$low(B)=p(B)-1.96*\sqrt{{p(B)(1-p(B))}{n(B)}} =0.303-1.96*sqrt{\frac{0.303*0.697}{404}}=0.2581$$$$low(B)=p(B)-1.96 \sqrt{{p(B)(1-p(B))}{n(B)}} =0.303-1.96 \sqrt{\frac{0.303 * 0.697}{404}}=0.2581$$ $$high(B)=p(B)+1.96*\sqrt{{p(B)(1-p(B))}{n(B)}} =0.303+1.96*sqrt{\frac{0.303*0.697}{404}}=0.3477$$$$high(B)=p(B)+1.96*\sqrt{{p(B)(1-p(B))}{n(B)}} =0.303+1.96 \sqrt{\frac{0.303 * 0.697}{404}}=0.3477$$ For p(B) the confidence interval is (0.2581;0.3477).

And now we see that confidence intervals are intersect, but it contradicts the computations for z-test.

Finally I've used a web service for z-test and CI computing. The service drawed intersection of CI's and rejected the null hipothesis of z-test too.

Please, could you explain me what the cause of the contradiction?

I've got the problem with Z-test and confidence intervals. Z-test rejects null hipothesis (proportions are equal), but confidence intervals are intersect.

Let us consider 2 companies. The proportion of smokers in company A is p(A)=0.22. And the proportion of smokers in company B is p(B)=0.303. The amount of employees in company A is 403. And the amount of employees in company B is 404.

So, we have the folowing data:

p(A)=0.22
n(A)=403

p(B)=0.303
n(B)=404

Now let's apply the Z-test by the following forumula for proportions (I've took the formula from https://onlinecourses.science.psu.edu/stat414/node/268):

$$Z= \frac{p(B)-p(A)}{\sqrt{p(1-p)(\frac{1}{n(A)}+\frac{1}{n(b)})}}$$

Where p is $$p=\frac{p(A)n(A)+p(B)n(B)}{n(A)+n(B)}$$

I've made the following computation: $$p=\frac{0.22*403+0.303*404}{403+404}=0.2614$$

$$z= \frac{0.303-0.22}{\sqrt{0.2614(1-0.2614)(\frac{1}{403}+\frac{1}{404})}}=2.6828$$

So, z more than 1.96, it means that we reject the null hipothesis. The proportions p(A) and p(B) are not equal.

But then I've computed the 5% confidence intervals by the following formulas (I've took them form https://onlinecourses.science.psu.edu/stat200/node/48):

$$low=P-1.96*\sqrt{\frac{P*(1-P)}{N}}$$ $$high=P+1.96*\sqrt{\frac{P*(1-P)}{N}}$$ Where P is proportion of smokers in some company and N is amount of employees in this company.

I've computed the interval for company A: $$low(A)=p(A)-1.96*\sqrt{{p(A)(1-p(A))}{n(A)}}=0.22-1.96*sqrt{\frac{0.22*0.78}{403}}=0.1796$$ $$high(A)=p(A)+1.96*\sqrt{{p(A)(1-p(A))}{n(A)}}=0.22+1.96*sqrt{\frac{0.22*0.78}{403}}=0.2604$$ So, for p(A) the CI is (0.1796;0.2696).

And finally I've computed the interval for the company B: $$low(B)=p(B)-1.96*\sqrt{{p(B)(1-p(B))}{n(B)}} =0.303-1.96*sqrt{\frac{0.303*0.697}{404}}=0.2581$$ $$high(B)=p(B)+1.96*\sqrt{{p(B)(1-p(B))}{n(B)}} =0.303+1.96*sqrt{\frac{0.303*0.697}{404}}=0.3477$$ For p(B) the confidence interval is (0.2581;0.3477).

And now we see that confidence intervals are intersect, but it contradicts the computations for z-test.

Finally I've used a web service for z-test and CI computing. The service drawed intersection of CI's and rejected the null hipothesis of z-test too.

Please, could you explain me what the cause of the contradiction?

I've got the problem with Z-test and confidence intervals. Z-test rejects null hypothesis (proportions are equal), but confidence intervals are intersect.

Let us consider 2 companies. The proportion of smokers in company A is p(A)=0.22. And the proportion of smokers in company B is p(B)=0.303. The amount of employees in company A is 403. And the amount of employees in company B is 404.

So, we have the folowing data:

p(A)=0.22
n(A)=403

p(B)=0.303
n(B)=404

Now let's apply the Z-test by the following forumula for proportions (I've took the formula from https://onlinecourses.science.psu.edu/stat414/node/268):

$$Z= \frac{p(B)-p(A)}{\sqrt{p(1-p)(\frac{1}{n(A)}+\frac{1}{n(b)})}}$$

Where p is $$p=\frac{p(A)n(A)+p(B)n(B)}{n(A)+n(B)}$$

I've made the following computation: $$p=\frac{0.22*403+0.303*404}{403+404}=0.2614$$

$$z= \frac{0.303-0.22}{\sqrt{0.2614(1-0.2614)(\frac{1}{403}+\frac{1}{404})}}=2.6828$$

So, z more than 1.96, it means that we reject the null hipothesis. The proportions p(A) and p(B) are not equal.

But then I've computed the 95% confidence intervals by the following formulas (I've took them form https://onlinecourses.science.psu.edu/stat200/node/48):

$$low=P-1.96*\sqrt{\frac{P*(1-P)}{N}}$$ $$high=P+1.96*\sqrt{\frac{P*(1-P)}{N}}$$ Where P is proportion of smokers in some company and N is amount of employees in this company.

I've computed the interval for company A: $$low(A)=p(A)-1.96*\sqrt{\frac{p(A)(1-p(A))}{n(A)}}=0.22-1.96*\sqrt{\frac{0.22*0.78}{403}}=0.1796$$ $$high(A)=p(A)+1.96*\sqrt{\frac{p(A)(1-p(A))}{n(A)}}=0.22+1.96*\sqrt{\frac{0.22*0.78}{403}}=0.2604$$ So, for p(A) the CI is (0.1796;0.2696).

And finally I've computed the interval for the company B: $$low(B)=p(B)-1.96 \sqrt{{p(B)(1-p(B))}{n(B)}} =0.303-1.96 \sqrt{\frac{0.303 * 0.697}{404}}=0.2581$$ $$high(B)=p(B)+1.96*\sqrt{{p(B)(1-p(B))}{n(B)}} =0.303+1.96 \sqrt{\frac{0.303 * 0.697}{404}}=0.3477$$ For p(B) the confidence interval is (0.2581;0.3477).

And now we see that confidence intervals are intersect, but it contradicts the computations for z-test.

Finally I've used a web service for z-test and CI computing. The service drawed intersection of CI's and rejected the null hipothesis of z-test too.

Please, could you explain me what the cause of the contradiction?

added 150 characters in body
Source Link
Loading
Source Link
Loading