Lower tail test
An analyst is interested in the ability of workers to assess the difficulty of a test they have taken. This test was taken by a large group of workers, assuming normal distribution, with the average score= 78.5 and standard deviation 10. A random sample of 9 workers was asked to predict this average score. The average of these predictions was 74.5. Test at 5% significance level.
Since the average of the sample is less than population we apply lower tail test meaning that on average workers overrestimate the difficulty of the test and their predictions become less than 78.5 (Since the harder the test, the lower the score)
H0: Mu>= 78.5
H1: Mu<78.5
xbar<- 74.5 # sample mean
mu0 <- 78.5 # hypothesized value
sigma <- 10 # population standard deviation
n <- 9 # sample size
z = (xbar- mu0)/sigma/sqrt(n)
z # test statistic
## [1] -0.1333333
Compute critical value at 0.05 significance level
alpha<- 0.05
z.alpha<- qnorm(1-alpha)
-z.alpha #critical value
## [1] -1.644854
Since this is lower tail test we take the negative value of z value
The result tells us that test statistic value is not smaller than critical value so we can not reject the claim
Decision: Fail to reject H0 Conclusion: Fail to accept H1 Interpretation: There is no sufficient evidence to conclude that Mu is less than 78.5 with given sample. Therefore workers are not assumed to be capable of identifying the difficulty of the test. If we reject H0 we would conclude that workers are capable of identifying the difficulty of test
P-test We can find lower tail p-value of the test statistic. If it turns out to be less than 0.05 significance level then we can reject the null hypothesis
pval<- pnorm(z) # z is test statistic since sigma is known
pval
## [1] 0.4469649
Since 0.4469649 is not less than alpha= 0.05 we cannot reject null hypothesis which is same result found above.
Upper tail test
Assume that in a factory if a worker gives more than 5 breaks in a day then he or she get penalty cost. One branch of workers, analysts, want to know how likely that they (analysts) gonna pay penalty cost. Assume that standart deviation of workers is 0.4.
Analysts are 10 worker and they have on average 7 breaks in a day.
H0: Mu<= 5
H1: Mu>5
xbar<- 7 # sample mean
mu0 <- 5 # hypothesized value
sigma <- 0.4 # population standard deviation
n <- 10 # sample size
z = (xbar- mu0)/sigma/sqrt(n)
z # test statistic
## [1] 1.581139
alpha <- 0.10
z.alpha <- qnorm(1-alpha)
z.alpha # critical value
## [1] 1.281552
Since test statistic is bigger than critical value we can reject the H0
pval = pnorm(z, lower.tail=FALSE)
pval # upper tail p−value
## [1] 0.05692315
p-value is less than alpha which means we can reject H0
Decision: Reject H0 Conclusion: Accept H1 Interpretation: There is sufficient evidence to conclude that Mu is more than 5 with given sample. Since having more than 5 breaks means paying penalty cost, we conclude by saying that analysts on average will pay penalty cost
Two-tail test
Assume that in a large company, mean number of workers fired by a manager last year was 15. To predict whether this number differs this year, a sample of 30 managers are taken. In this sample 14 workers ,on average, are observed to be fired by a manager.Assume the population standard deviation is 2.5. At 0.05 significance level can we reject the null hypothesis that the mean workers fired does not differ from last year?
H0: Mu= Mu0=15 H1: Mu=!Mu0= 15
xbar = 14 # sample mean
mu0 = 15 # hypothesized value
sigma = 2.5 # pop standard deviation
n = 30 # sample size
z = (xbar-mu0)/(sigma/sqrt(n))
z # test statistic
## [1] -2.19089
Critical Values at 0.05 sl
alpha = .05
z.half.alpha = qnorm(1-alpha/2) #since two tail test take z.alpha/2
c(-z.half.alpha, z.half.alpha) # create vector
## [1] -1.959964 1.959964
Since test statistic does not lie between the critical values -1.959964 and 1.959964, with this significance level we can reject the hypothesis that the mean number of workers fired by a manager stays same this year.
P-value Solution
pval = 2*pnorm(z) # lower tail
pval # two−tailed p−value
## [1] 0.02845974
Since the are is less than significance level we reject the H0.
Comments