Alice took a test with 100 Yes/No questions (a very long one!). Alice received the tests results and she got 55 questions correctly.
The Professor wants to understand if Alice was randomly guessing the answers on the test or if Alice actually studied for the exam.
If \(p\) is the probability for Alice to answer the question correctly then
\(H_0: p = 0.5\) and \(H_a: p>0.5.\)
It is a one-sided alternative.
\(z_{obs} = \frac{55/100 - 0.5}{\sqrt{0.5(1-0.5)/100}}=1\)
p-value\(=P(Z>z_{obs}) = 0.1587\)
No, p-value>0.05.
As we fail to reject \(H_0\), there is not enough evidence to say that Alice was not randomly guessing.
\(z_{obs} = \frac{60/100 - 0.5}{\sqrt{0.5(1-0.5)/100}}=2\)
p-value\(=P(Z>z_{obs}) = 0.0228 < 0.05\)
We can reject \(H_0\) in favor of \(H_a\), so we are 95% confident that Alice has studied.
Average salary in Google is 250K.
Elon Musk wants to check if the average salary in Twitter is the same as in Google.
If \(\mu\) is the average salary in Twitter then
\(H_0: \mu = 100\) and \(H_a: \mu\neq100.\)
It is a two-sided alternative.
salary
## [1] 189.8 205.8 235.9 286.2 180.3 284.8 291.7 249.1 244.4 159.3 180.9 176.5
## [13] 253.1 207.6 265.5 224.7 257.6 298.8 207.0 266.6 290.2 181.8 247.8 168.8
## [25] 190.1 207.9 152.0 207.4 280.5 201.1
He computed the mean of this sample:
mean(salary)
## [1] 226.44
In addition, an insider shared that the population variance of the salary in Twitter is \(6000\).
What is the value of the test statistic?
If the variance is known we can use Normal approximation (like in confidence intervals).
\(z_{obs}=\frac{226.44 - 250}{\sqrt{6000/30}}=-1.666\)
p-value\(=P(|Z|>|z_{obs}|) = 2 \cdot 0.0475 = 0.095\)
No, p-value>0.05.
As we fail to reject \(H_0\), there is not enough evidence to say that there is a difference between Google and Twitter in average salaries.
Yes, as p-value<0.1 we could reject the \(H_0\) with 90% confidence and conclude that the average salaries in Google and Twitter are different.
var(salary)
## [1] 1961.936
What is the value of the test statistic in this case?
If the variance is unknown we use t approximation.
\(t_{obs}=\frac{226.44 - 250}{\sqrt{1961.936/30}}=-2.913\)
From the t-distribution table we infer that p-value\(=P(|T|>|t_{obs}|)\) is smaller than 0.01.
So we can reject the null hypothesis at significance level 0.05.