1 of 39

LECTURE 4

CONFIDENCE INTERVALS

HYPOTHESIS TESTING

ONE SAMPLE HYPOTHESIS TESTS (Z & t)

WHAT IS THE P-VALUE?

2 of 39

Z-score: How many standard deviations a value is from the mean

  • Find Z-score associated with random variable value of interest

  • Find probabilities associated with that Z-score

3 of 39

4 of 39

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).

5 of 39

Statistical Inference

Trying to understand something about population distributions using observations from a random sample.

6 of 39

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.

7 of 39

Area

= α/2

Area

= α/2

Confidence Interval (shaded area = 95%, unshaded = 5%)

95% confidence interval

8 of 39

Example: Unknown Population Mean, Known Population Variance/SD

9 of 39

What if I DON’T KNOW the population SD?

10 of 39

11 of 39

t-distribution confidence interval:

12 of 39

df = n – 1

http://www.sjsu.edu/faculty/gerstman/StatPrimer/t-table.pdf

13 of 39

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.

14 of 39

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?

15 of 39

The Null Hypothesis: Usually feels like the least newsworthy outcome…

  • Stick with the status quo
  • The claim is true
  • No significant effect
  • No significant difference
  • No significant association

The Alternative Hypothesis: Usually feels like the more newsworthy thing (it’s NOT…)

  • The status quo is wrong
  • The claim is false
  • Significant effect
  • Significant difference
  • Significant association

16 of 39

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.

17 of 39

WALKING THROUGH A HYPOTHESIS TEST

  • You are told that the mean weight for a population of wild pigs 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.

  • You (miraculously) know that the population standard deviation (𝞂) is 28 lbs.

  • Do you have enough evidence to reject the claim about wild pig weight?

18 of 39

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)

19 of 39

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

20 of 39

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

21 of 39

μ

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

22 of 39

μ

-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.

23 of 39

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...

24 of 39

So what is the p-value given that the Z-statistic associated with our sample is ± 1.56?

25 of 39

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?

26 of 39

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:

  1. Think that is unlikely enough to have occurred by random chance that you would instead think that the null hypothesis is false?

  • Decide that there is a fairly high probability of getting our sample mean (or something more extreme) if the claim is true, concluding that we don’t have enough evidence to reject the null hypothesis?

27 of 39

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.

28 of 39

μ

-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.

29 of 39

For a two-sided test, what is ZCritical for a significance level of 0.05?

30 of 39

μ

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).

31 of 39

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

32 of 39

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.

  1. Define the null and alternative hypothesis

  • Choose a significance level

  • Calculate the Z-statistic for your sample

  • What is the critical Z-value for the significance level?

  • Draw a sketch of of the distribution with Zsample and Zcritical values indicated

  • Find the p-value associated with your sample

  • Make a decision about the null hypothesis

33 of 39

Now you’ll use the sample standard deviation (s)

34 of 39

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

35 of 39

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.

36 of 39

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.

37 of 39

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

38 of 39

μ

-tCritical

+tCritical

α

TWO-SIDED

(α split in 2-tails)

ONE-SIDED

(α all in one tail)

39 of 39

GOOD TABLE/BAD TABLE

SAME DATA. TWO TABLES.