Z - TEST and T Test
Z - TEST and T Test
Procedure:
P1=P2 P1≠P2 OR P1>P2 OR P1<P2
If sample proportions are p1 and p2 then test
statistic is
Where P= Q=1-P
If Z lies in (-1.96, 1.96) at 5% level of
significance, then accept
Otherwise reject
OR If p value < 0.05 R , other wise Accept
Example:
A company is introducing a new plan of work in their
two branches at Mumbai and Kolkata. In Mumbai out of
40 workers 35 are in favour of new plan. In Kolkata out of
35 workers 10 are against the new plan. Test whether
workers in both the branches are in favour of new plan.
Workers in both the branches are in favour of new plan.
Workers in both the branches are not in favour of new
plan.
Given: , ,P= =0.8,Q=0.2 and Z== 1.74
1.74 lies in (-1.96,1.96) at 5% level of significance. Accept
Conclusion: Workers at both the branches are in favour
of new plan.
two-proportions z-test in R
The R functions prop.test() can be used as follow:
prop.test(x, n, p = NULL, alternative = , correct =)
• x: a vector of counts of successes
• n: a vector of count trials
• correct: a logical indicating whether Yates’ continuity
correction should be applied or not by taking TRUE
or FLASE
• alterative=“two.sided or less or greater”
NOTE
1) The formula of z-statistic is valid only when sample size (n) is large
enough. should be ≥ 5.
2) By default, the function prop.test() used the Yates continuity
correction, which is really important if either the expected
successes or failures is < 5. If you don’t want the correction, use
the additional argument correct = FALSE in prop.test() function. The
default value is TRUE. (This option must be set to FALSE to make
the test mathematically equivalent to the uncorrected z-test of a
proportion.)
3) The function returns:
• the value of Pearson’s chi-squared test statistic.
• a p-value
• a 95% confidence intervals
• an estimated probability of success
Example in R
IN R
result <- prop.test(x = c(490, 400), n = c(500, 500))
# Printing the results
result
Example 3
Random samples of 400 men and 600 women
were asked whether they would like to have a
flyover near their residence. 200 men and 325
women were in favour of the proposal. Test the
hypothesis that proportions of men and women
in favour of the proposal are same .
Example 4
Before an increase in excise duty on tea, 800 out
of a sample of 1 ,000 persons were found to be
tea drinkers. After increase in excise duty 800
people were tea drinkers in a sample of 1200
people. whether there is a significant decrease
in the consumption of tea after the increase in
excise duty .
Example 5
A company is considering two different television
advertisements for promotion of a new product.
Management believed that the advertisement A is more
effective than advertisement B.
Two test market areas with, virtually identical consumer
characteristics are selected; A is used in one area and B in
other area. In a random sample of 60 customers who saw A,
18 tried the product. In another random sample of 100
customers who saw B, 22 tried the product. Does this
indicate that advertisement A is more effective than
advertisement
t – TEST(Student’s t test)
Test for single mean
Procedure: µ=µ0
H1 µ≠µ0 is two tailed test
H1 µ<µ0 is one tailed test(lower tailed test)
H1 µ>µ0 is one tailed test(upper tailed test)
If sample mean is then test statistic is t=
Conclusion:
If t< critical value at 5% level of significance with n-1 df, then
accept
Otherwise reject .
OR
If p< α (level of significant ) then reject H 0 ,otherwise accept H0
IN R
We have the potato yield (in kg) from 12 different farms are 21.5,
24.5, 18.5, 17.2, 14.5, 23.2, 22.1, 20.5, 19.4, 18.1, 24.1, 18.5. We
know that the standard potato yield for the given variety is µ=20.Test
if the potato yield from these farms is significantly better than the
standard yield.
The potato yield from these farms is same as the standard yield.
The potato yield from these farms is significantly better than the
standard yield.
IN R
x=c(21.5, 24.5, 18.5, 17.2, 14.5, 23.2, 22.1, 20.5, 19.4, 18.1, 24.1,
18.5)
t.test(x,mu=20,altrnative=“greater”)
CONCLUSION: p value=0.4223>0.05,Accept .Therefore ,the potato
yield from these farms is same as the standard yield.
Example 3