Means for Small Samples) Hypothesis Testing What is a hypothesis test: • A formal way to statistically test a theoretical assumption based on the data we have.
• Key concepts: • Null hypothesis H0 : The prediction we usually get information if rejecting
• Alternative Hypothesis H1
• Significance level α : The probability of rejecting Ho
when it is true (Type I error, false positive) Hypothesis Testing Why do we need it? • Is there a significant difference between two populations?
• Is there a significant relationship between two
variables?
• Is the mean bigger , smaller or different from a
given value? Hypothesis Testing A simple example • We will examine the steps of hypothesis testing through a general example:
• Assume we have n data from two different
populations A and B,
,…, with sample mean and,
,…, with sample mean
Hypothesis Testing A simple Example: • We are interested to know whether there are significant differences between the two populations or not. • To answer this question, we need to perform a statistical test. Hypothesis Testing A simple Example: • Step 1: Identify our hypothesis.
Ho: As equal to Bs (no differences)
H1: otherwise Hypothesis Testing A simple Example: • Step 2: We need a statistic that will represent our question. • An example could be: T=-| • If As where identical to Bs T would be zero.
• The bigger T is, the more far away are As from Bs
Hypothesis Testing A simple example:
• We need to calculate T for our data. We will denote
the specific value of T for our data as .
• Step 3: We need the distribution of T (which we view
as a random variable) under the null hypothesis.
We will assume that we know this distribution and we
will denote it as . Hypothesis Testing A simple example:
• Step 4: Measure how likely it is to observe the value
under the null hypothesis.
• If it is very unlikely to observe it under the null
assumption, then we have evidence that As are not the same as Bs.
• In other words we need to calculate the probability to
observe something more extreme than what we observed under the null assumption. Hypothesis Testing A simple example:
• This probability is called the p-value and we can
write:
P(T≥)
Remember we know the value . T is a random variable
and in order to calculate the p-value the only thing we need is to know its distribution. Hypothesis Testing A simple Example: • Step 5: Set a significance level e.g.: a=0.01
If a>p-value then reject the null hypothesis Ho
If we reject it means we have evidence that As are not the same with Bs
If we don’t reject, then we say that there is not enough
evidence to reject the assumption that As are same as Bs Hypothesis Testing Example: One sample t-test for the mean • We use this test when we want to compare a mean () to a specific value (). • In other words, Ho: μ= vs H1: μ different from
• The statistic used is of the form:
T= Where s is the standard deviation and n the no of data points. • It follows under the null, a t distribution with n-1 degrees of freedom Hypothesis Testing Numerical Example: • Assume we have a 20 observations of the weights of a product in grams. The mean of this sample is 8.059576 • The standard deviation is 0.3190233 • The question we want to answer : Is the mean statistically different from 7.82? (answer for α=0.01)
• In other words, Step 1: identify the hypothesis
Ho: μ=7.82 vs H1:μ different from 7.82 Hypothesis Testing Numerical Example: • Step 2: Calculate the statistic T= = =3.358424 ≈3.4
• Step 3:Identify the distribution of t under null:
t distribution with 20-1=19 degrees of freedom
• Step 4:Calculate the p-value
P(t≥)=1-P(t<3.4)=.. Find P(t<3.4) using Tables for Student -t distribution Hypothesis Testing Hypothesis Testing Numerical Example:
• From the Table we see that P(t<3.4)=0.9985
• The p-value is: 1-0.9985=0.0015
α=0.01>p-value=0.0015 so we reject Ho
That means that the mean seems to be significantly