Inference for Quantitative Variables 3/12/12 Single Mean, µ t-distribution Intervals and tests...

48
Inference for Quantitative Variables 3/12/12 • Single Mean, µ t-distribution • Intervals and tests Difference in means, µ 1 µ 2 • Distribution • Matched pairs • Correlation, • Distribution Section 6.4, 6.5, 6.6, 6.10, 6.11, 6.12, 6.13 Professor Kari Lock Morgan Duke University

Transcript of Inference for Quantitative Variables 3/12/12 Single Mean, µ t-distribution Intervals and tests...

Page 1: Inference for Quantitative Variables 3/12/12 Single Mean, µ t-distribution Intervals and tests Difference in means, µ 1 – µ 2 Distribution Matched pairs.

Inference for Quantitative Variables3/12/12

• Single Mean, µ• t-distribution• Intervals and tests• Difference in means, µ1 – µ2 • Distribution• Matched pairs• Correlation, • Distribution

Section 6.4, 6.5, 6.6, 6.10, 6.11, 6.12, 6.13Professor Kari Lock Morgan

Duke University

Page 2: Inference for Quantitative Variables 3/12/12 Single Mean, µ t-distribution Intervals and tests Difference in means, µ 1 – µ 2 Distribution Matched pairs.

• Homework 6 (due Monday, 3/19)

• Project 1 (due Thursday, 3/22)

To Do

Page 3: Inference for Quantitative Variables 3/12/12 Single Mean, µ t-distribution Intervals and tests Difference in means, µ 1 – µ 2 Distribution Matched pairs.

If the distribution of the sample statistic is normal:

A confidence interval can be calculated by

where z* is a N(0,1) percentile depending on the level of confidence.

A p-value is the area in the tail(s) of a N(0,1) beyond

Inference Using N(0,1)

*sample statistic z SE

sample statistic null value

SEz

Page 4: Inference for Quantitative Variables 3/12/12 Single Mean, µ t-distribution Intervals and tests Difference in means, µ 1 – µ 2 Distribution Matched pairs.

CLT for a MeanPopulation

Distribution of Sample Data

Distribution of Sample Means

n = 10

n = 30

n = 50

Frequency

0 1 2 3 4 5 6

0.0

1.5

3.0

1.0 2.0 3.0

Frequency

0 1 2 3 4 5

04

8

1.5 2.0 2.5 3.0

Frequency

0 2 4 6 8 12

010

25

1.4 1.8 2.2 2.6

x

0 2 4 6 8 10

Page 5: Inference for Quantitative Variables 3/12/12 Single Mean, µ t-distribution Intervals and tests Difference in means, µ 1 – µ 2 Distribution Matched pairs.

The standard error for a sample mean can be calculated by

SE of a Mean

SEn

Page 6: Inference for Quantitative Variables 3/12/12 Single Mean, µ t-distribution Intervals and tests Difference in means, µ 1 – µ 2 Distribution Matched pairs.

The standard deviation of the population is

a)

b) s

c)

Standard Deviation

n

Page 7: Inference for Quantitative Variables 3/12/12 Single Mean, µ t-distribution Intervals and tests Difference in means, µ 1 – µ 2 Distribution Matched pairs.

The standard deviation of the sample is

a)

b) s

c)

Standard Deviation

n

Page 8: Inference for Quantitative Variables 3/12/12 Single Mean, µ t-distribution Intervals and tests Difference in means, µ 1 – µ 2 Distribution Matched pairs.

The standard deviation of the sample mean is

a)

b) s

c)

Standard Deviation

n

Page 9: Inference for Quantitative Variables 3/12/12 Single Mean, µ t-distribution Intervals and tests Difference in means, µ 1 – µ 2 Distribution Matched pairs.

If n ≥ 30*, then

CLT for a Mean

,X Nn

*Smaller sample sizes may be sufficient for symmetric distributions, and 30 may not be sufficient for very skewed distributions or distributions with high outliers

Page 10: Inference for Quantitative Variables 3/12/12 Single Mean, µ t-distribution Intervals and tests Difference in means, µ 1 – µ 2 Distribution Matched pairs.

• We don’t know the population standard deviation , so estimate it with the sample standard deviation, s

Standard Error

SEn

SEs

n

Page 11: Inference for Quantitative Variables 3/12/12 Single Mean, µ t-distribution Intervals and tests Difference in means, µ 1 – µ 2 Distribution Matched pairs.

• Replacing with s changes the distribution of the z-statistic from normal to t

• The t distribution is very similar to the standard normal, but with slightly fatter tails to reflect this added uncertainty

t-distribution

Page 12: Inference for Quantitative Variables 3/12/12 Single Mean, µ t-distribution Intervals and tests Difference in means, µ 1 – µ 2 Distribution Matched pairs.

• The t-distribution is characterized by its degrees of freedom (df)

• Degrees of freedom are calculated based on the sample size

• The higher the degrees of freedom, the closer the t-distribution is to the standard normal

Degrees of Freedom

Page 13: Inference for Quantitative Variables 3/12/12 Single Mean, µ t-distribution Intervals and tests Difference in means, µ 1 – µ 2 Distribution Matched pairs.

t-distribution

Page 14: Inference for Quantitative Variables 3/12/12 Single Mean, µ t-distribution Intervals and tests Difference in means, µ 1 – µ 2 Distribution Matched pairs.

Aside: William Sealy Gosset

Page 15: Inference for Quantitative Variables 3/12/12 Single Mean, µ t-distribution Intervals and tests Difference in means, µ 1 – µ 2 Distribution Matched pairs.

t-distributionTo calculate area in the tail(s), or to find percentiles of a t-distribution, usehttp://surfstat.anu.edu.au/surfstat-home/tables/t.php

Page 16: Inference for Quantitative Variables 3/12/12 Single Mean, µ t-distribution Intervals and tests Difference in means, µ 1 – µ 2 Distribution Matched pairs.

Normality Assumption• Using the t-distribution requires an extra assumption: the data comes from a normal distribution

• Note: this assumption is about the original data, not the distribution of the statistic

• For large sample sizes we do not need to worry about this, because s will be a very good estimate of , and t will be very close to N(0,1)

• For small sample sizes (n < 30), we can only use the t-distribution if the distribution of the data is approximately normal

Page 17: Inference for Quantitative Variables 3/12/12 Single Mean, µ t-distribution Intervals and tests Difference in means, µ 1 – µ 2 Distribution Matched pairs.

Normality Assumption• One small problem: for small sample sizes, it is very hard to tell if the data actually comes from a normal distribution!

Population

x

0 2 4 6 8 10

Sample Data, n = 10

0 2 4 6 8 10 0 1 2 3 4 5 60.5 1.5 2.5 3.5

-2.0 -1.0 0.0 1.0 -0.5 0.5 1.0 1.5 2.0 -2 -1 0 1-4 -2 0 2 4

Page 18: Inference for Quantitative Variables 3/12/12 Single Mean, µ t-distribution Intervals and tests Difference in means, µ 1 – µ 2 Distribution Matched pairs.

Small Samples

• If sample sizes are small, only use the t-distribution if the data looks reasonably symmetric and does not have any extreme outliers.

• Even then, remember that it is just an approximation!

• In practice/life, if sample sizes are small, you should just use simulation methods (bootstrapping and randomization)

Page 19: Inference for Quantitative Variables 3/12/12 Single Mean, µ t-distribution Intervals and tests Difference in means, µ 1 – µ 2 Distribution Matched pairs.

Confidence Intervals

*sample statistic t SE

* s

X tn

df = n – 1

IF n is large or the data is normal

t* is found as the appropriate percentile on a t-distribution with n – 1 degrees of freedom

Page 20: Inference for Quantitative Variables 3/12/12 Single Mean, µ t-distribution Intervals and tests Difference in means, µ 1 – µ 2 Distribution Matched pairs.

Hypothesis Testing

sample statistic null value

SEt

0tXsn

The p-value is the area in the tail(s) beyond t in a t-distribution with n – 1 degrees of freedom,IF n is large or the data is normal

df = n – 1 0 0:H

Page 21: Inference for Quantitative Variables 3/12/12 Single Mean, µ t-distribution Intervals and tests Difference in means, µ 1 – µ 2 Distribution Matched pairs.

Chips Ahoy!

?

A group of Air Force cadets bought bags of Chips Ahoy! cookies from all over the country to verify this claim. They hand counted the number of chips in 42 bags.

1261.6, 1 1 7.6X s Source: Warner, B. & Rutledge, J. (1999). “Checking the Chips Ahoy! Guarantee,” Chance, 12(1).

Page 22: Inference for Quantitative Variables 3/12/12 Single Mean, µ t-distribution Intervals and tests Difference in means, µ 1 – µ 2 Distribution Matched pairs.

Chips Ahoy!

Can we use hypothesis testing to prove that there are 1000 chips in every bag? (“prove” = find statistically significant)

(a) Yes(b) No

Page 23: Inference for Quantitative Variables 3/12/12 Single Mean, µ t-distribution Intervals and tests Difference in means, µ 1 – µ 2 Distribution Matched pairs.

Chips Ahoy!

Can we use hypothesis testing to prove that the average number of chips per bag is 1000? (“prove” = find statistically significant)

(a) Yes(b) No

Page 24: Inference for Quantitative Variables 3/12/12 Single Mean, µ t-distribution Intervals and tests Difference in means, µ 1 – µ 2 Distribution Matched pairs.

Chips Ahoy!

Can we use hypothesis testing to prove that the average number of chips per bag is more than 1000? (“prove” = find statistically significant)

(a) Yes(b) No

Page 25: Inference for Quantitative Variables 3/12/12 Single Mean, µ t-distribution Intervals and tests Difference in means, µ 1 – µ 2 Distribution Matched pairs.

Chips Ahoy!

?

1) Are there more than 1000 chips in each bag, on average?

(a) Yes(b) No(c) Cannot tell from this data

2) Give a 99% confidence interval for the average number of chips in each bag.

1261.6, 117.6, 42X s n

Page 26: Inference for Quantitative Variables 3/12/12 Single Mean, µ t-distribution Intervals and tests Difference in means, µ 1 – µ 2 Distribution Matched pairs.

Chips Ahoy!0 : 1000

: 1000aH

H

0 1261.6 100014.4

117.642

Xt

sn

0p value > pt(14.4, df=41, lower.tail=FALSE) [1] 6.193956e-18

186.19 10

This provides extremely strong evidence that the average number of chips per bag of Chips Ahoy! cookies is significantly greater than 1000.

42 30n

1. State hypotheses:

2. Check conditions:

3. Calculate test statistic:

4. Compute p-value:

4. Interpret in context:

Page 27: Inference for Quantitative Variables 3/12/12 Single Mean, µ t-distribution Intervals and tests Difference in means, µ 1 – µ 2 Distribution Matched pairs.

Chips Ahoy!

*

117.61261.6 2.7

42

1212.6,1310.6

sX t

n

We are 99% confident that the average number of chips per bag of Chips Ahoy! cookies is between 1212.6 and 1310.6 chips.

42 30n 1. Check conditions:

2. Find t*:

4. Compute confidence interval:

4. Interpret in context:

* 2.7t

Page 28: Inference for Quantitative Variables 3/12/12 Single Mean, µ t-distribution Intervals and tests Difference in means, µ 1 – µ 2 Distribution Matched pairs.

t-distribution

Which of the following properties is/are necessary for to have a t-distribution?

a) the data is normalb) the sample size is largec) the null hypothesis is trued) a or be) d and c

0Xt

sn

Page 29: Inference for Quantitative Variables 3/12/12 Single Mean, µ t-distribution Intervals and tests Difference in means, µ 1 – µ 2 Distribution Matched pairs.

SE for Difference in Means

2 21 2

1 2

SEn n

df = smaller of n1 – 1 and n2 – 1

Page 30: Inference for Quantitative Variables 3/12/12 Single Mean, µ t-distribution Intervals and tests Difference in means, µ 1 – µ 2 Distribution Matched pairs.

CLT for Difference in Means

1 230 and *I 3 ,f 0nn

2 21 2

1 2 1 21 2

,n n

X X N

*Smaller sample sizes may be sufficient for symmetric distributions, and 30 may not be sufficient for skewed distributions

Page 31: Inference for Quantitative Variables 3/12/12 Single Mean, µ t-distribution Intervals and tests Difference in means, µ 1 – µ 2 Distribution Matched pairs.

t-distribution

• For a difference in means, the degrees of freedom for the t-distribution is the smaller of n1 – 1 and n2 – 1

• The test for a difference in means using a t-distribution is commonly called a t-test

Page 32: Inference for Quantitative Variables 3/12/12 Single Mean, µ t-distribution Intervals and tests Difference in means, µ 1 – µ 2 Distribution Matched pairs.

The Pygmalion Effect

Source: Rosenthal, R. and Jacobsen, L. (1968). “Pygmalion in the Classroom: Teacher Expectation and Pupils’ Intellectual Development.” Holt, Rinehart and Winston, Inc.

Teachers were told that certain children (chosen randomly) were expected to be “growth spurters,” based on the Harvard Test of Inflected Acquisition (a test that didn’t actually exist). These children were selected randomly.

The response variable is change in IQ over the course of one year.

Page 33: Inference for Quantitative Variables 3/12/12 Single Mean, µ t-distribution Intervals and tests Difference in means, µ 1 – µ 2 Distribution Matched pairs.

The Pygmalion Effect

n sControl Students 255 8.42 12.0“Growth Spurters” 65 12.22 13.3

X

Does this provide evidence that merely expecting a child to do well actually causes the child to do better?

(a) Yes(b) No

If so, how much better?

*s1 and s2 were not given, so I set them to give the correct p-value

Page 34: Inference for Quantitative Variables 3/12/12 Single Mean, µ t-distribution Intervals and tests Difference in means, µ 1 – µ 2 Distribution Matched pairs.

Pygmalion Effect0 1 2

1 2

: 0

: 0aH

H

1 2

2 2 2 21 2

1 2

12.22 8.420

13.3 1265 255

3.82.096

1.813

X Xt

s sn n

.02p value

We have evidence that positive teacher expectations significantly increase IQ scores in elementary school children.

30,6255 5 30

1. State hypotheses:

2. Check conditions:

3. Calculate t statistic:

4. Compute p-value:

5. Interpret in context:

1

2

: Mean IQ change for "growth spurters"

Mean IQ change for control stud ts: en

Page 35: Inference for Quantitative Variables 3/12/12 Single Mean, µ t-distribution Intervals and tests Difference in means, µ 1 – µ 2 Distribution Matched pairs.

Pygmalion Effect

From the paper:

“The difference in gains could be ascribed tochance about 2 in 100 times”

Page 36: Inference for Quantitative Variables 3/12/12 Single Mean, µ t-distribution Intervals and tests Difference in means, µ 1 – µ 2 Distribution Matched pairs.

Pygmalion Effect

We are 95% confident that telling teachers a student will be an intellectual “growth spurter” increases IQ scores by between 0.17 and 7.43 points on average, after 1 year.

1. Check conditions:

2. Find t*:

3. Compute the confidence interval:

4. Interpret in context:

* 1.9 298t

3.8 2 1.813 0.17,7.43

30,6255 5 30

95% CI

2 2* 1 2

1 21 2

s

n n

sX X t

Page 37: Inference for Quantitative Variables 3/12/12 Single Mean, µ t-distribution Intervals and tests Difference in means, µ 1 – µ 2 Distribution Matched pairs.

• A matched pairs experiment compares units to themselves or another similar unit, rather than just compare group averages

• Data is paired (two measurements on one unit, twin studies, etc.).

• Look at the difference in responses for each pair

Matched Pairs

Page 38: Inference for Quantitative Variables 3/12/12 Single Mean, µ t-distribution Intervals and tests Difference in means, µ 1 – µ 2 Distribution Matched pairs.

• Do pheromones (subconscious chemical signals) in female tears affect testosterone levels in men?

• Cotton pads had either real female tears or a salt solution that had been dripped down the same female’s face

• 50 men had a pad attached to their upper lip twice, once with tears and once without, order randomized.

• Response variable: testosterone level

Pheromones in Tears

Gelstein, et. al. (2011) “Human Tears Contain a Chemosignal," Science, 1/6/11.

Page 39: Inference for Quantitative Variables 3/12/12 Single Mean, µ t-distribution Intervals and tests Difference in means, µ 1 – µ 2 Distribution Matched pairs.

Why do a matched pairs experiment?

a) Decrease the standard deviation of the response

b) Increase the power of the test

c) Decrease the margin of error for intervals

d) All of the above

e) None of the above

Matched Pairs

Page 40: Inference for Quantitative Variables 3/12/12 Single Mean, µ t-distribution Intervals and tests Difference in means, µ 1 – µ 2 Distribution Matched pairs.

• Matched pairs experiments are particularly useful when responses vary a lot from unit to unit

• We can decrease standard deviation of the response (and so decrease standard error of the statistic) by comparing each unit to a matched unit

Matched Pairs

Page 41: Inference for Quantitative Variables 3/12/12 Single Mean, µ t-distribution Intervals and tests Difference in means, µ 1 – µ 2 Distribution Matched pairs.

• For a matched pairs experiment, we look at the difference between responses for each unit, rather than just the average difference between treatment groups

• Get a new variable of the differences, and do inference for the difference as you would for a single mean

Matched Pairs

Page 42: Inference for Quantitative Variables 3/12/12 Single Mean, µ t-distribution Intervals and tests Difference in means, µ 1 – µ 2 Distribution Matched pairs.

• The average difference in testosterone levels between tears and no tears was -21.7 pg/ml.

• The standard deviation of these differences was 46.5

• Average level before sniffing was 155 pg/ml.

• The sample size was 50 men

Pheromones in Tears

“pg” = picogram = 0.001 nanogram = 10-12 gram

• Do female tears lower male testosterone levels?

(a) Yes (b) No (c) ???

• By how much? Give a 95% confidence interval.

Page 43: Inference for Quantitative Variables 3/12/12 Single Mean, µ t-distribution Intervals and tests Difference in means, µ 1 – µ 2 Distribution Matched pairs.

Pheromones in Tears0 : 0

: 0d

a dH

H

0 21.73.3

6.58dXtSE

This provides strong evidence that female tears decrease testosterone levels in men, on average.

50 30n

1. State hypotheses:

2. Check conditions:

3. Calculate test statistic:

4. Compute p-value:

5. Interpret in context:

> pt(-3.3, df=49, lower.tail=TRUE) [1] 0.000903654

21.7, 46.5, 50d d nX s 46.5

6.5850

ds

nSE

Page 44: Inference for Quantitative Variables 3/12/12 Single Mean, µ t-distribution Intervals and tests Difference in means, µ 1 – µ 2 Distribution Matched pairs.

Pheromones in Tears

*dX t SE

We are 95% confident that female tears on a cotton pad on a man’s upper lip decrease testosterone levels between 8.54 and 34.86 pg/ml, on average.

50 30n 1. Check conditions:

2. Find t*:

3. Compute the confidence interval:

4. Interpret in context:

21.7 2 6.58 -34.86, -8.54

> qt(0.975 df=49) [1] 2.009575

*or 2t

21.76.58

d

SEX

Page 45: Inference for Quantitative Variables 3/12/12 Single Mean, µ t-distribution Intervals and tests Difference in means, µ 1 – µ 2 Distribution Matched pairs.

Correlation

21

2

rSE

n

df = n - 2

t-distribution

Page 46: Inference for Quantitative Variables 3/12/12 Single Mean, µ t-distribution Intervals and tests Difference in means, µ 1 – µ 2 Distribution Matched pairs.

Social Networks and the Brain• Is the size of certain regions of your brain correlated with the size of your social network?

• Social network size measured by many different variables, one of which was number of facebook friends. Brain size measured by MRI.

• The sample correlation between number of Facebook friends and grey matter density of a certain region of the brain (left middle temporal gyrus), based on 125 people, is r = 0.354. Is this significant? (a) Yes (b) No

Source: R. Kanai, B. Bahrami, R. Roylance and G. Ree (2011). “Online social network size is reflected in human brain structure,” Proceedings of the Royal Society B: Biological Sciences. 10/19/11.

Page 47: Inference for Quantitative Variables 3/12/12 Single Mean, µ t-distribution Intervals and tests Difference in means, µ 1 – µ 2 Distribution Matched pairs.

Social Networks and the Brain0 : 0

: 0aH

H

0 0.3544.20

0.084

rt

SE

This provides strong evidence that the size of the left middle temporal gyrus and number of facebook friends are positively correlated.

125 30n

1. State hypotheses:

2. Check conditions:

3. Calculate test statistic:

4. Compute p-value:

5. Interpret in context:

2

0.354

1 0.354

1250.0

284SE

r

> pt(4.2, df=123,lower.tail=FALSE) [1] 2.539729e-05

Page 48: Inference for Quantitative Variables 3/12/12 Single Mean, µ t-distribution Intervals and tests Difference in means, µ 1 – µ 2 Distribution Matched pairs.

Parameter Distribution Conditions Standard Error

ProportionNormal

All counts at least 10np ≥ 10, n(1 – p) ≥ 10

Difference in Proportions

NormalAll counts at least 10

n1p1 ≥ 10, n1(1 – p1) ≥ 10, n2p2 ≥ 10, n2(1 – p2) ≥ 10

Mean t, df = n – 1 n ≥ 30 or data normal

Difference in Means

t, df = smaller of n1 – 1, n2 – 1

n1 ≥ 30 or data normal, n2 ≥ 30 or data normal

Paired Diff. in Means

t, df = nd – 1 nd ≥ 30 or data normal

Correlationt, df = n – 2 n ≥ 30

(1 )p p

n

2

n

1 1

1

2 2

2

(1 ) (1 )p p p p

n n

2 21 2

1 2n n

2

1

d

n

21

2

r

n

pg 454