One-Proportion Z-Test

The One proportion Z-test is used to compare an observed proportion to a theoretical one, when there are only two categories.

TASK 1: Test whether the proportion of am = 0 cars, having cyl = 8 is equal to 60%

counts

##      cyl
## am     4  6  8 Sum
##   0    3  4 12  19
##   1    8  3  2  13
##   Sum 11  7 14  32

Proportions

##    cyl
## am      4     6     8
##   0 15.79 21.05 63.16
##   1 61.54 23.08 15.38
  • H0a: The proportion of cars am = 0, having cyl = 8 is equal to 60%

  • H1a: The proportion of cars am = 0, having cyl = 8 is not equal to 60%

## 
##  1-sample proportions test without continuity correction
## 
## data:  12 out of 19, null probability 0.6
## X-squared = 0.078947, df = 1, p-value = 0.7787
## alternative hypothesis: true p is not equal to 0.6
## 95 percent confidence interval:
##  0.4103953 0.8085049
## sample estimates:
##         p 
## 0.6315789

The p-value of the test is 0.7787, which is greater than the significance level alpha = 0.05. We can conclude that the proportion of cars am = 0, having cyl = 8 is equal to 60%

TASK 2: Test whether the proportion of am = 0 cars, having cyl = 8 is equal to 35%

  • H0a: The proportion of cars am = 0, having cyl = 8 is equal to 35%

  • H1a: The proportion of cars am = 0, having cyl = 8 is not equal to 35%

## 
##  1-sample proportions test with continuity correction
## 
## data:  12 out of 19, null probability 0.35
## X-squared = 5.4419, df = 1, p-value = 0.01966
## alternative hypothesis: true p is not equal to 0.35
## 95 percent confidence interval:
##  0.3863271 0.8276998
## sample estimates:
##         p 
## 0.6315789

The p-value of the test is 0.01966, which is less than the significance level alpha = 0.05. We can conclude that the proportion of cars am = 0, having cyl = 8 is not equal to 35%.

Two-Proportions Z-Test

The two-proportions z-test is used to compare two observed proportions.

TASK 3: Compare the proportions of 4 and 8 cyl cars having automatic transmission (am = 0)

H0: The proportion of automatic transmission (am = 0) among 4-cylinder cars (cyl = 4) is the same as the proportion of automatic transmission (am = 0) among 8-cylinder cars (cyl = 8)

  • If p-value > 0.05, we FAIL TO REJECT the Null Hypothesis H0

  • If p-value < 0.05, we REJECT the Null Hypothesis H0

## 
##  2-sample test for equality of proportions with continuity correction
## 
## data:  c(3, 12) out of c(11, 14)
## X-squared = 6.5003, df = 1, p-value = 0.01079
## alternative hypothesis: two.sided
## 95 percent confidence interval:
##  -0.9863121 -0.1825191
## sample estimates:
##    prop 1    prop 2 
## 0.2727273 0.8571429

The p-value of the test is 0.01079 , which is less than the significance level alpha = 0.05. We can conclude that the proportion of automatic transmission (am = 0) among 4-cylinder cars (cyl = 4) is not the same as the proportion of automatic transmission (am = 0) among 8-cylinder cars (cyl = 8)