Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

##Part 3 (i):

Null hypothesis: P(X>42.5) = 0.4


Alternatives:
P(X>42.5) != 0.4
P(X>42.5) > 0.4
P(X>42.5) < 0.4
##Part 3 (ii):

x = c(41.5, 50.7, 36.6, 37.3, 34.2, 45.0, 48.0, 43.2, 47.7, 42.2, 43.2, 44.6, 48.4, 46.4, 46.8, 39.2, 37
x = ifelse(x > 42.5, 1, 0)
N = sum(x)
n = length(x)
phat = N/n
z= sqrt(n)*(phat-0.4) / sqrt(0.4*(1-0.4))

#two sided test with function:


prop.test(N,n,p = 0.4, alternative = c("two.sided"), correct = FALSE)

##
## 1-sample proportions test without continuity correction
##
## data: N out of n, null probability 0.4
## X-squared = 0.28161, df = 1, p-value = 0.5956
## alternative hypothesis: true p is not equal to 0.4
## 95 percent confidence interval:
## 0.2841317 0.6245204
## sample estimates:
## p
## 0.4482759
#two sided test with formula:
2 * pnorm(-z)

## [1] 0.5956484
#greater than test with function:
prop.test(N,n,p = 0.4, alternative = c("greater"), correct = FALSE)

##
## 1-sample proportions test without continuity correction
##
## data: N out of n, null probability 0.4
## X-squared = 0.28161, df = 1, p-value = 0.2978
## alternative hypothesis: true p is greater than 0.4
## 95 percent confidence interval:
## 0.3073468 1.0000000
## sample estimates:
## p
## 0.4482759
#greater than test with formula:
1-pnorm(z)

## [1] 0.2978242

1
#less than test with function:
prop.test(N,n,p = 0.4, alternative = c("less"), correct = FALSE)

##
## 1-sample proportions test without continuity correction
##
## data: N out of n, null probability 0.4
## X-squared = 0.28161, df = 1, p-value = 0.7022
## alternative hypothesis: true p is less than 0.4
## 95 percent confidence interval:
## 0.0000000 0.5980325
## sample estimates:
## p
## 0.4482759
#less than test with formula:
pnorm(z)

## [1] 0.7021758
#I'm not sure if this is necessary since the question just says to run the tests, but in all 3
#cases, we fail to reject the null hypothesis for alpha = .05.

##Part 3 (iii)
The possible shortcoming with the above is that it’s a binomial approximation of normal instead of a
approximately normal data set, so it’s more of an approximation of a Z test than an actual Z test, which
might make it inaccurate.

You might also like