LECTURE 4
CONFIDENCE INTERVALS
HYPOTHESIS TESTING
ONE SAMPLE HYPOTHESIS TESTS (Z & t)
WHAT IS THE P-VALUE?
Z-score: How many standard deviations a value is from the mean
THE CENTRAL LIMIT THEOREM
The Central Limit Theorem: Regardless of the underlying shape of a population, when repeated samples of equal size are taken from the population and a parameter (e.g. mean) is calculated for each sample, the distribution of that parameter will be normal (especially as sample size n increases to > 30).
Statistical Inference
Trying to understand something about population distributions using observations from a random sample.
CONFIDENCE INTERVALS
Example: We calculate a confidence interval for mean alligator length (n = 35), finding a 90% confidence interval of [8.2, 12.4] ft.
That means that if we took a bunch of sets of samples (all n = 35), then 90% of the time, the calculated mean would fall within this range.
Area
= α/2
Area
= α/2
Confidence Interval (shaded area = 95%, unshaded = 5%)
95% confidence interval
Example: Unknown Population Mean, Known Population Variance/SD
What if I DON’T KNOW the population SD?
t-distribution confidence interval:
df = n – 1
http://www.sjsu.edu/faculty/gerstman/StatPrimer/t-table.pdf
http://www.sjsu.edu/faculty/gerstman/StatPrimer/t-table.pdf
df = n – 1
Practice Problem
You are measuring the body temperature of otters. Assume that the body temperature is normally distributed for the entire population. You are only able to sample body temperatures for 15 otters, finding a sample mean of 100.4 ºF with a standard deviation of 0.6 ºF. Calculate the 90% confidence interval.
Tell your neighbor what the outcome means in a sentence.
INTRODUCTION TO HYPOTHESIS TESTING
The basic system for hypothesis testing
(1) You (or someone) state a hypothesis/claim.
(2) You collect data to test that hypothesis/claim.
(3) Based on the data you collect, you ask yourself: do I have enough evidence to make me think that the null hypothesis/claim is wrong? Or do I lack evidence to dispute it?
The Null Hypothesis: Usually feels like the least newsworthy outcome…
The Alternative Hypothesis: Usually feels like the more newsworthy thing (it’s NOT…)
That does NOT mean that you should go looking for ways to update your analysis so that you reject the null hypothesis!
Your job:
- Ask a research question
- Choose appropriate method to answer it
- Perform analysis
- Clearly report results
A result of ‘no significant difference,’ ‘no significant effect,’ etc. is still an important and interesting result.
WALKING THROUGH A HYPOTHESIS TEST
NULL HYPOTHESIS:
The claim is correct.
Null hypothesis is: the mean weight of wild pigs IS 130 lbs.
Alternative hypothesis: the mean weight IS NOT 130 lbs.
130
158
102
186
74
Pig Weight (lbs)
We took a sample from the wild pig population (n = 30) and found a mean of 122 lbs.
130
158
102
186
74
Pig Weight (lbs)
μ
x
130
158
102
186
74
Pig Weight (lbs)
μ
x
Then we ask: What is the probability that IF the null hypothesis is true, we would have found a sample mean (for n = 30) that is at least as far from the claimed mean by random chance by sampling from that population?
x
μ
To answer that we:
Calculate a Z-statistic associated with our sample mean…
...and using that we can find the probability of getting a mean value at least ± Z away from the claim mean by random chance.
-Z
+Z
μ
-Z
+Z
If we add these two probabilities, what we find is the total probability that we could have found a sample mean at least that different from the claimed mean by random chance, if the null hypothesis is true.
THAT PROBABILITY IS THE P-VALUE.
Calculating the Z-statistic:
For our example: Z = (122 – 130)/(28/√30) = -1.56
μ
-Z = -1.56
+Z = 1.56
...we know how to find this probability...
So what is the p-value given that the Z-statistic associated with our sample is ± 1.56?
INTERPRETING THE P-VALUE
You are testing a claim that mean wild pig weight is 130 lbs.
You question that claim. To test, you find the weights of 30 random wild pigs, and calculate a sample mean of 122 lbs. Do you have enough evidence to reject the claim about wild pig weight?
We found p = 0.1188.
What does that mean?
THEN WE MAKE A DECISION
So knowing that if the null hypothesis is true, there is a 11.9% chance we could have taken a sample from that population and found our sample mean or something more different from the claim by random chance, do you:
WELL…HOW UNLIKELY WOULD OUR SAMPLE NEED TO BE TO REJECT THE NULL?
The cut-off value below which you’ll decide to reject the null hypothesis is called the significance level, alpha (α).
Most common significance level: α = 0.05
If p < α, then we have enough evidence to reject the null hypothesis.
If p > α, then we retain the null hypothesis.
μ
-ZCritical
+ZCritical
α/2
α/2
We could also find the critical values of Z (ZCritical) that would be the cut-off point for rejecting the null hypothesis.
If Zsample is beyond that critical value, then we know we would reject the null even if we didn’t know the exact p-value.
For a two-sided test, what is ZCritical for a significance level of 0.05?
μ
Zcritical
= -1.96
Zcritical
= +1.96
α/2
α/2
Zsample
= +1.56
Zsample
= -1.56
Because our sample Z-statistic is not beyond the critical Z-value, we know that our p-value > 0.05, so we would decide to retain the null hypothesis (even if we didn’t know the exact p-value).
RECAP
(TWO-SIDED, ONE-SAMPLE TEST, POPULATION SD KNOWN)
1. STATE NULL and ALTERNATIVE HYPOTHESIS
2. DECIDE ON SIGNIFICANCE LEVEL
3. CALCULATE Z-STATISTIC FOR SAMPLE
4. DETERMINE P-VALUE (FROM Z-TABLE)
5. COMPARE P-VALUE TO SIGNIFICANCE LEVEL
6. DECIDE WHETHER YOU WILL RETAIN OR REJECT THE NULL
EXAMPLE PROBLEM:
You read a report stating that the mean length of acorns in Los Padres National Forest is 3.6 cm. You question that claim. To test, you randomly sample 40 acorns, finding a sample mean of 3.3 cm.
The population SD (σ) is 0.7 cm.
Now you’ll use the sample standard deviation (s)
OTHERWISE IT’S THE SAME PROCESS. Now you’ll compare the your sample t-value with the critical t-value to decide whether p will be greater or less than the significance level.
http://www.sjsu.edu/faculty/gerstman/StatPrimer/t-table.pdf
EXAMPLE:
A news outlet claims that the mean starting salary for new UCSB graduates is $42,000/yr.
You collect a random sample for 41 recent UCSB grads, finding a mean salary of $44,300/yr with a standard deviation of $6,300/yr.
Make a decision about the news outlet’s claim.
SO FAR: Two-Sided Tests
When we have an alternative hypothesis with no directionality, we perform a two-sided test.
SOMETIMES our alternative hypothesis is directional.
For example: A claim states that mean pig weight is 130 lbs. You think that the true mean weight is greater than 130 lbs.
Then we will do a one-sided test.
EXAMPLE:
A lobbyist claims that the mean monthly cost of health insurance in California is $122. You think that the actual mean cost is greater. To test the claim, you randomly sample 40 Californians, finding a mean cost of $131 with a standard deviation of $18.
What do you conclude?
NULL: Mean monthly cost is NOT greater than $122
ALTERNATIVE: Mean monthly cost IS greater than $122
μ
-tCritical
+tCritical
α
TWO-SIDED
(α split in 2-tails)
ONE-SIDED
(α all in one tail)
GOOD TABLE/BAD TABLE
SAME DATA. TWO TABLES.