242
Final Examination • Thursday, April 30, 4:00 – 7:00 • Location: here, Hanes 120

Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

Embed Size (px)

Citation preview

Page 1: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

Final Examination

• Thursday, April 30, 4:00 – 7:00

• Location: here, Hanes 120

Page 2: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

Final Examination

• Thursday, April 30, 4:00 – 7:00

• Location: here, Hanes 120

• Suggested Study Strategy: Rework HW

Page 3: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

Final Examination

• Thursday, April 30, 4:00 – 7:00

• Location: here, Hanes 120

• Suggested Study Strategy: Rework HW

• Out of Class Review Session?

Page 4: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

Final Examination

• Thursday, April 30, 4:00 – 7:00

• Location: here, Hanes 120

• Suggested Study Strategy: Rework HW

• Out of Class Review Session?

• No, personal Q-A much better use of time

Page 5: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

Final Examination

• Thursday, April 30, 4:00 – 7:00

• Location: here, Hanes 120

• Suggested Study Strategy: Rework HW

• Out of Class Review Session?

• No, personal Q-A much better use of time

• Thus, instead offer extended Office Hours

Page 6: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

Final Examination

Extended Office Hours

Monday, April 27, 8:00 – 11:00

Tuesday, April 28, 12:00 – 2:30

Wednesday, April 29, 1:00 – 5:00

Thursday, April 30, 8:00 – 1:00

Page 7: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

Last Time

• Comparing Scatterplots

• Measuring Strength of Relationship– Correlation

• Two Sample Inference– Paired Sampling– Independent Sampling

Page 8: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

Reading In Textbook

Approximate Reading for Today’s Material:

Pages 110-135, 560-574

Approximate Reading for Next Class:

None, review only

Page 9: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

2 Sample Measurement Error

Easy Case: Paired Differences

Have Treatment 1:

Treatment 2:

nXXX ,,, 21

nYYY ,,, 21

Page 10: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

2 Sample Measurement Error

Easy Case: Paired Differences

Have Treatment 1:

Treatment 2:

Hard case: 2 different (unmatched) samples

nXXX ,,, 21

nYYY ,,, 21

Page 11: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

2 Sample Measurement Error

Easy Case: Paired Differences

Have Treatment 1:

Treatment 2:

Hard case: 2 different (unmatched) samples

nXXX ,,, 21

nYYY ,,, 21

XnXXX ,,, 21

YnYYY ,,, 21

Page 12: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

2 Sample Measurement Error

Easy Case: Paired Differences

Have Treatment 1:

Treatment 2:

Hard case: 2 different (unmatched) samples

different!

nXXX ,,, 21

nYYY ,,, 21

XnXXX ,,, 21

YnYYY ,,, 21

Page 13: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

2 Sample Measurement Error

Hard case: 2 different (unmatched) samples

Page 14: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

2 Sample Measurement Error

Hard case: 2 different (unmatched) samples

Notes:

• There are several variations

Page 15: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

2 Sample Measurement Error

Hard case: 2 different (unmatched) samples

Notes:

• There are several variations

• For Hypo. Testing, EXCEL works well

Page 16: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

2 Sample Measurement Error

Hard case: 2 different (unmatched) samples

Notes:

• There are several variations

• For Hypo. Testing, EXCEL works well

• Variations well labelled in TTEST

Page 17: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

2 Sample Measurement Error

Hard case: 2 different (unmatched) samples

Main Ideas:

Page 18: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

2 Sample Measurement Error

Hard case: 2 different (unmatched) samples

Main Ideas:

Data:

XnXXX ,,, 21

YnYYY ,,, 21

Page 19: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

2 Sample Measurement Error

Hard case: 2 different (unmatched) samples

Main Ideas:

Data:

Sample Averages:

XnXXX ,,, 21

YnYYY ,,, 21

Page 20: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

2 Sample Measurement Error

Hard case: 2 different (unmatched) samples

Main Ideas:

Data:

Sample Averages:

XnXXX ,,, 21

YnYYY ,,, 21

X

XX

nNX

,~

Y

YY

nNY

,~

Page 21: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

2 Sample Measurement Error

Hard case: 2 different (unmatched) samples

Base inference on:

YX

Page 22: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

2 Sample Measurement Error

Hard case: 2 different (unmatched) samples

Base inference on:

Probability Theory (can show):

YX

Page 23: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

2 Sample Measurement Error

Hard case: 2 different (unmatched) samples

Base inference on:

Probability Theory (can show):

YX

Y

Y

X

XYX nn

NYX22

,~

Page 24: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

2 Sample Measurement Error

Hard case: 2 different (unmatched) samples

Probability Theory (can show):

Y

Y

X

XYX nn

NYX22

,~

Page 25: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

2 Sample Measurement Error

Hard case: 2 different (unmatched) samples

Probability Theory (can show):

Assumptions

Y

Y

X

XYX nn

NYX22

,~

Page 26: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

2 Sample Measurement Error

Hard case: 2 different (unmatched) samples

Probability Theory (can show):

Assumptions:

• Xs & Ys Independent

Y

Y

X

XYX nn

NYX22

,~

Page 27: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

2 Sample Measurement Error

Hard case: 2 different (unmatched) samples

Probability Theory (can show):

Assumptions:

• Xs & Ys Independent

• Otherwise based on Law of Averages

Y

Y

X

XYX nn

NYX22

,~

Page 28: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

2 Sample Measurement Error

Step towards statistical inference:

2 sample Z statistic

1,0~22

N

nn

YX

Y

Y

X

X

YX

Page 29: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

2 Sample Measurement Error

Step towards statistical inference:

2 sample Z statistic

• Just do standardization (usual idea)

1,0~22

N

nn

YX

Y

Y

X

X

YX

Page 30: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

2 Sample Measurement Error

Step towards statistical inference:

2 sample Z statistic

• Just do standardization (usual idea)

• Handle unknown s.d.s???

1,0~22

N

nn

YX

Y

Y

X

X

YX

Page 31: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

2 Sample Measurement Error

For unknown s.d.s, use usual approx:

For 2 sample t statistic

Y

Y

X

X

YX

ns

ns

YX22

YYXX ss ,

Page 32: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

2 Sample Measurement Error

2 sample t statistic:

Y

Y

X

X

YX

ns

ns

YX22

Page 33: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

2 Sample Measurement Error

2 sample t statistic:

Probability Distribution

Y

Y

X

X

YX

ns

ns

YX22

Page 34: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

2 Sample Measurement Error

2 sample t statistic:

Probability Distribution:

• 2 sample version of t distribution

Y

Y

X

X

YX

ns

ns

YX22

Page 35: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

2 Sample Measurement Error

2 sample t statistic:

Probability Distribution:

• 2 sample version of t distribution

• Well modelled by EXCEL using TTEST

Y

Y

X

X

YX

ns

ns

YX22

Page 36: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

2 Sample Measurement Error

2 sample t statistic:

Probability Distribution:

• 2 sample version of t distribution

• Well modelled by EXCEL using TTEST

• Use this for Hypothesis Testing

Y

Y

X

X

YX

ns

ns

YX22

Page 37: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

2 Sample Measurement Error

Variations on TTest

Page 38: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

2 Sample Measurement Error

Variations on TTest: Argument “Type”

1. Paired (simple case above)

Page 39: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

2 Sample Measurement Error

Variations on TTest: Argument “Type”

1. Paired (simple case above)

2. Two sample, equal variance

(studied below)

Page 40: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

2 Sample Measurement Error

Variations on TTest: Argument “Type”

1. Paired (simple case above)

2. Two sample, equal variance

(studied below)

3. Two sample, unequal variance

(version derived above)

Page 41: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

2 Sample Measurement Error

Variations on TTest: Argument “Type”

2. Two sample, equal variance

Page 42: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

2 Sample Measurement Error

Variations on TTest: Argument “Type”

2. Two sample, equal variance

Main Idea: when

• Can find an “improved estimate”

YX

Page 43: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

2 Sample Measurement Error

Variations on TTest: Argument “Type”

2. Two sample, equal variance

Main Idea: when

• Can find an “improved estimate”

• By “pooling data”

YX

Page 44: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

2 Sample Measurement Error

Variations on TTest: Argument “Type”

2. Two sample, equal variance

Main Idea: when

• Can find an “improved estimate”

• By “pooling data”

• i.e. use combined

YX

YXs

Page 45: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

2 Sample Measurement Error

Variations on TTest: Argument “Type”

2. Two sample, equal variance

Main Idea: when

• Can find an “improved estimate”

• By “pooling data”

• i.e. use combined

• Won’t use in this class

YX

YXs

Page 46: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

2 Separate SamplesE.g. Old Textbook 7.32:

b. Do separate sample Hypo test,

Class Example 15, Part 3http://www.stat-or.unc.edu/webspace/courses/marron/UNCstor155-2009/ClassNotes/Stor155Eg15.xls

Page 47: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

2 Separate SamplesE.g. Old Textbook 7.32:

b. Do separate sample Hypo test,

Class Example 15, Part 3http://www.stat-or.unc.edu/webspace/courses/marron/UNCstor155-2009/ClassNotes/Stor155Eg15.xls

Page 48: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

2 Separate SamplesE.g. Old Textbook 7.32:

b. Do separate sample Hypo test,

Class Example 15, Part 3http://www.stat-or.unc.edu/webspace/courses/marron/UNCstor155-2009/ClassNotes/Stor155Eg15.xls

Use type = 3 (don’t know common variance)

Page 49: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

2 Separate SamplesE.g. Old Textbook 7.32:

b. Do separate sample Hypo test,

Class Example 15, Part 3http://www.stat-or.unc.edu/webspace/courses/marron/UNCstor155-2009/ClassNotes/Stor155Eg15.xls

P-value = 3.95 x 10-6

Page 50: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

2 Separate SamplesE.g. Old Textbook 7.32:

b. Do separate sample Hypo test,

Class Example 15, Part 3http://www.stat-or.unc.edu/webspace/courses/marron/UNCstor155-2009/ClassNotes/Stor155Eg15.xls

P-value = 3.95 x 10-6

Interpretation: very strong evidence

Page 51: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

2 Separate SamplesE.g. Old Textbook 7.32:

b. Do separate sample Hypo test,

Class Example 15, Part 3http://www.stat-or.unc.edu/webspace/courses/marron/UNCstor155-2009/ClassNotes/Stor155Eg15.xls

P-value = 3.95 x 10-6

Interpretation: very strong evidence

either yes-no or gray level

Page 52: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

2 Separate SamplesSuggested HW:

7.81, 7.82

Page 53: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

2 Sample Hypo Testing

Comparison of Paired vs. Unmatched Cases

Notes:

• Can always use unmatched procedure

– Just ignore matching…

• Advantage to pairing???

Page 54: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

2 Sample Hypo Testing

Comparison of Paired vs. Unmatched Cases

• Advantage to Pairing???

• Recall previous example:

Old Textbook 7.32

– Matched Paired P-value = 1.87 x 10-5

– Unmatched P-value = 3.95 x 10-6

• Unmatched better!?! (can happen)

Page 55: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

2 Sample Hypo Testing

Comparison of Paired vs. Unmatched Cases

• Advantage to Pairing???

Happens when “variation of diff’s”, ,

is smaller than “full sample variation”

I.e.

(whether this happens depends on data)

D

Y

Y

X

XD nn

22

Page 56: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

Paired vs. Unmatched SamplingClass Example 29:

A new drug is being tested that should boost white

blood cell count following chemo-therapy. For

a set of 4 patients, it was not administered (as

a control) for the 1st round of chemotherapy,

and then the new drug was tried after the 2nd

round of chemotherapy. White blood cell

counts were measured one week after each

round of chemotherapy.

Page 57: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

Paired vs. Unmatched Sampling

Class Example 29:

The resulting white blood cell counts were:

Patient 1 33 35

Patient 2 26 27

Patient 3 36 39

Patient 4 28 30

Page 58: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

Paired vs. Unmatched Sampling

Class Example 29:

Does the new drug seem to reduce white

blood cell counts well enough to be

studied further?

• Seems to be some improvement

• But is it statistically significant?

• Only 4 patients…

Page 59: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

Paired vs. Unmatched Sampling

Let: = Average Blood c’nts w/out drug

= Average Blood c’nts with drug

Set up:

(want strong evidence of improvement)

YX

YXA

YX

H

H

:

:0

Page 60: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

Paired vs. Unmatched Sampling

Class Example 29:http://stat-or.unc.edu/webspace/postscript/marron/Teaching/stor155-2007/Stor155Eg29.xls

Results:

• Matched Pair P-val = 0.00813

– Very strong evidence of improvement

• Unmatched P-val = 0.295

– Not statistically significant

Page 61: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

Paired vs. Unmatched Sampling

Class Example 29:http://stat-or.unc.edu/webspace/postscript/marron/Teaching/stor155-2007/Stor155Eg29.xls

Conclusions:

• Paired Sampling can give better results

• When diff’ing reduces variation

• Often happens for careful matching

Page 62: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

Paired Sampling Visualization

Page 63: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

Paired Sampling Visualization

Page 64: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

Paired Sampling Visualization

Page 65: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

Paired Sampling Visualization

Page 66: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

Paired Sampling Visualization

Page 67: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

Paired Sampling Visualization

Page 68: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

Paired Sampling Visualization

Page 69: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

Paired Sampling Visualization

Page 70: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

Paired Sampling Visualization

Page 71: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

Paired Sampling Visualization

Page 72: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

Paired Sampling Visualization

Page 73: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

Paired Sampling Visualization

Page 74: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

Paired Sampling Visualization

Page 75: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

Paired Sampling Visualization

Page 76: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

Paired Sampling Visualization

Page 77: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

Paired Sampling Visualization

Page 78: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

Paired Sampling Visualization

Page 79: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

Paired Sampling Visualization

Page 80: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

Paired Sampling Visualization

Page 81: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

2 Sample ProportionsIn text Section 8.2

• Skip this

• Ideas are only slight variation of above

• Basically mix & Match of 2 sample

ideas, and proportion methods

• If you need it (later), pull out text

• Covered on exams to extent it is in HW

Page 82: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

Research Corner

Example of High Dimensional Visualization

Page 83: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

Research Corner

Example of High Dimensional Visualization:

Microarray Analysis

Page 84: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

Research Corner

Example of High Dimensional Visualization:

Microarray Analysis

For a biological tissue sample

(e.g. tumor from a cancer biopsy))

Page 85: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

Research Corner

Example of High Dimensional Visualization:

Microarray Analysis

For a biological tissue sample

simultaneously measure “gene expression”

(activity level)

Page 86: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

Research Corner

Example of High Dimensional Visualization:

Microarray Analysis

For a biological tissue sample

simultaneously measure “gene expression”

over all human genes

(~38,000)

Page 87: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

Research Corner

Example of High Dimensional Visualization:

Microarray Analysis

For a biological tissue sample

simultaneously measure “gene expression”

over all human genes

Data set considered here:

Breast Cancer, ~2500 genes

Page 88: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

Research Corner

Page 89: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

Research Corner

Page 90: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

Research Corner

Page 91: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

Research Corner

Page 92: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

Research Corner

Page 93: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

Research Corner

Page 94: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

Research Corner

Page 95: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

Research Corner

Page 96: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

Research Corner

Page 97: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

Research Corner

Page 98: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

Research Corner

Page 99: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

Section 2.3: Linear Regression

Idea:

Fit a line to data in a scatterplot

Page 100: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

Section 2.3: Linear Regression

Idea:

Fit a line to data in a scatterplot

• To learn about basic structure

Page 101: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

Section 2.3: Linear Regression

Idea:

Fit a line to data in a scatterplot

• To learn about basic structure

• To model data

Page 102: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

Section 2.3: Linear Regression

Idea:

Fit a line to data in a scatterplot

• To learn about basic structure

• To model data

• To provide prediction of new values

Page 103: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

Linear Regression

Recall some basic geometry

Page 104: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

Linear Regression

Recall some basic geometry:A line

Page 105: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

Linear Regression

Recall some basic geometry:A line is described by an equation:

y = mx + b

Page 106: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

Linear Regression

Recall some basic geometry:A line is described by an equation:

y = mx + b

Really {(x,y} : y = mx + b} “set of all ordered pairs such that y = mx + b”

Page 107: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

Linear Regression

Recall some basic geometry:A line is described by an equation:

y = mx + b

m = slope

Page 108: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

Linear Regression

Recall some basic geometry:A line is described by an equation:

y = mx + b

m = slope m

Page 109: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

Linear Regression

Recall some basic geometry:A line is described by an equation:

y = mx + b

m = slope m

b = y intercept

Page 110: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

Linear Regression

Recall some basic geometry:A line is described by an equation:

y = mx + b

m = slope m

b = y intercept b

Page 111: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

Linear Regression

Recall some basic geometry:A line is described by an equation:

y = mx + b

m = slope m

b = y intercept b

Varying m & b gives a family of lines

Page 112: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

Linear Regression

Recall some basic geometry:A line is described by an equation:

y = mx + b

m = slope m

b = y intercept b

Varying m & b gives a family of lines,Indexed by parameters m & b

Page 113: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

Basics of Lines

Textbook’s notation:

Y = b0 + b1x .

Page 114: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

Basics of Lines

Textbook’s notation:

Y = b0 + b1x = b1x + b0.

Page 115: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

Basics of Lines

Textbook’s notation:

Y = b0 + b1x = b1x + b0.

b1 = m (above) = slope

Page 116: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

Basics of Lines

Textbook’s notation:

Y = b0 + b1x = b1x + b0.

b1 = m (above) = slope

b0 = b (above) = y-intercept

Page 117: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

Basics of Lines

Suggested HW (to review line ideas):

C24: Fred keeps his savings in his mattress. He begins with $500 from his mother, and adds $100 each year. His total savings y, after x years are given by the equation:

y = 500 + 100 x

(a) Draw a graph of this equation.

Page 118: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

Basics of LinesC24: (cont.)

(b) After 20 years, how much will Fred have?

($2500)

(c) If Fred adds $200 instead of $100 each year to his initial $500, what is the equation that describes his savings after x years? (y = 500 + 200 x)

Page 119: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

Linear Regression

Approach:

Given a scatterplot of data:

),(),...,,( 11 nn yxyx

Page 120: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

Linear Regression

Approach:

Given a scatterplot of data:

),(),...,,( 11 nn yxyx

Page 121: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

Linear Regression

Approach:

Given a scatterplot of data:

Find b0 & b1

),(),...,,( 11 nn yxyx

Page 122: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

Linear Regression

Approach:

Given a scatterplot of data:

Find b0 & b1

(i.e. choose a line)

),(),...,,( 11 nn yxyx

Page 123: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

Linear Regression

Approach:

Given a scatterplot of data:

Find b0 & b1

(i.e. choose a line)

to best fit the data

),(),...,,( 11 nn yxyx

Page 124: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

Linear Regression

Approach:

Given a scatterplot of data:

Find b0 & b1

(i.e. choose a line)

to best fit the data

),(),...,,( 11 nn yxyx

Page 125: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

Linear Regression - Approach

),( 11 yx),( 22 yx

),( 33 yx

Page 126: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

Linear Regression - Approach

Given a line, y = b1x + b0

),( 11 yx),( 22 yx

),( 33 yx

Page 127: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

Linear Regression - Approach

Given a line, y = b1x + b0, indexed by b0 & b1

),( 11 yx),( 22 yx

),( 33 yx

Page 128: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

Linear Regression - Approach

Given a line, y = b1x + b0, indexed by b0 & b1

Define residuals

),( 11 yx),( 22 yx

),( 33 yx

Page 129: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

Linear Regression - Approach

Given a line, y = b1x + b0, indexed by b0 & b1

Define residuals = data Y – Y on line

),( 11 yx),( 22 yx

),( 33 yx

Page 130: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

Linear Regression - Approach

Given a line, y = b1x + b0, indexed by b0 & b1

Define residuals = data Y – Y on line

= Yi – (b1xi + b0)

),( 11 yx),( 22 yx

),( 33 yx

Page 131: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

Linear Regression - Approach

Given a line, y = b1x + b0, indexed by b0 & b1

Define residuals = data Y – Y on line

= Yi – (b1xi + b0)

Now choose b0 & b1

),( 11 yx),( 22 yx

),( 33 yx

Page 132: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

Linear Regression - Approach

Given a line, y = b1x + b0, indexed by b0 & b1

Define residuals = data Y – Y on line

= Yi – (b1xi + b0)

Now choose b0 & b1 to make these “small”

),( 11 yx),( 22 yx

),( 33 yx

Page 133: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

Linear Regression - Approach

Make Residuals > 0, by squaring

Least Squares: adjust b0 & b1 to

minimize the Sum of Squared Errors

21

01 )(

n

iii bxbySSE

Page 134: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

Linear Regression - Approach

JAVA Demo, by David Lane at Rice U.http://www.ruf.rice.edu/~lane/stat_sim/reg_by_eye/index.html

Page 135: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

Linear Regression - Approach

JAVA Demo, by David Lane at Rice U.http://www.ruf.rice.edu/~lane/stat_sim/reg_by_eye/index.html

• Applet gives us scatterplot with data

(Appears to be

randomly generated)

Page 136: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

David Lane Demo AppletRaw Data

Page 137: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

Linear Regression - Approach

JAVA Demo, by David Lane at Rice U.http://www.ruf.rice.edu/~lane/stat_sim/reg_by_eye/index.html

• Applet gives us scatterplot with data

• Try drawing lines (to min MSE)

Page 138: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

David Lane Demo Applet(Deliberately dumb) hand-drawn line

Page 139: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

David Lane Demo Applet(Deliberately dumb) hand-drawn line

Measure Fit (bad) by Mean Square Error

Page 140: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

Linear Regression - Approach

JAVA Demo, by David Lane at Rice U.http://www.ruf.rice.edu/~lane/stat_sim/reg_by_eye/index.html

• Applet gives us scatterplot with data

• Try drawing lines (to min MSE)

• Experiment with intercepts, b0

Page 141: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

David Lane Demo Applet(Hopefully better) hand-drawn line

Page 142: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

David Lane Demo Applet(Hopefully better) hand-drawn line

Yes! Improved (smaller) MSE

Page 143: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

David Lane Demo AppletBest choice of b0?

Page 144: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

David Lane Demo AppletBest choice of b0?

Try to vertically center, i.e. b0 = Avg(Ys)

Page 145: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

David Lane Demo AppletManual attempt at b0 = Avg(Ys)

Page 146: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

David Lane Demo AppletManual attempt at b0 = Avg(Ys)

As expected: improved MSE

Page 147: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

Linear Regression - Approach

JAVA Demo, by David Lane at Rice U.http://www.ruf.rice.edu/~lane/stat_sim/reg_by_eye/index.html

• Applet gives us scatterplot with data

• Try drawing lines (to min MSE)

• Experiment with intercepts, b0

• And slopes, b1

Page 148: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

David Lane Demo AppletNext try to allow slope, while maintaining

intercept

Page 149: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

David Lane Demo AppletNext try to allow slope, while maintaining

intercept (so go through center)

Page 150: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

David Lane Demo AppletSlope which direction?

(apparent small downward trend?)

Page 151: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

David Lane Demo AppletMake an attempt

Page 152: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

David Lane Demo AppletMake an attempt: Worse MSE!?!

Page 153: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

David Lane Demo AppletMake an attempt: Worse MSE!?!

Perhaps too steep? Try less…

Page 154: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

David Lane Demo AppletNext attempt

Page 155: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

David Lane Demo AppletNext attempt: Improved MSE!

Page 156: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

David Lane Demo AppletCould try to fine tune more,

but let’s look at best possible next

Page 157: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

David Lane Demo AppletCould try to fine tune more,

but let’s look at best possible next

Page 158: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

David Lane Demo AppletCould try to fine tune more,

but let’s look at best possible next

Page 159: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

David Lane Demo AppletOur center point (intercept) was off

(too high)

Page 160: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

David Lane Demo AppletBut our slope looks pretty good

Page 161: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

Linear Regression - Approach

JAVA Demo, by David Lane at Rice U.http://www.ruf.rice.edu/~lane/stat_sim/reg_by_eye/index.html

• Applet gives us scatterplot with data

• Try drawing lines (to min MSE)

• Experiment with intercepts, b0

• And slopes, b1

• Guess the correlation, r?

Page 162: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

David Lane Demo AppletNext try to guess correlation

Page 163: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

David Lane Demo AppletNext try to guess correlation:

Answer

Page 164: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

David Lane Demo AppletTry Another Data Set

(using)

Page 165: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

David Lane Demo Applet• Clearly slopes upwards

• Apparently stronger correlation

Page 166: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

David Lane Demo Applet• Clearly slopes upwards

• Apparently stronger correlation

Page 167: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

David Lane Demo Applet• Clearly slopes upwards

• Apparently stronger correlation

Page 168: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

Linear Regression - Approach

Given a line, y = b1x + b0, indexed by b0 & b1

Define residuals = data Y – Y on line

= Yi – (b1xi + b0)

Now choose b0 & b1 to make these “small”

),( 11 yx),( 22 yx

),( 33 yx

Page 169: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

Linear Regression - Approach

Make Residuals > 0, by squaring

Least Squares: adjust b0 & b1 to

minimize the Sum of Squared Errors

21

01 )(

n

iii bxbySSE

Page 170: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

Linear Regression - Approach

Make Residuals > 0, by squaring

Least Squares: adjust b0 & b1 to

minimize the Sum of Squared Errors

(How to Compute?)

21

01 )(

n

iii bxbySSE

Page 171: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

Least Squares

Can Show: (math beyond this course)

Page 172: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

Least Squares

Can Show: (math beyond this course)

Least Squares Fit Line

Page 173: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

Least Squares

Can Show: (math beyond this course)

Least Squares Fit Line:

• Passes through the point ),( yx

Page 174: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

Least Squares

Can Show: (math beyond this course)

Least Squares Fit Line:

• Passes through the point

• Has Slope:

),( yx

x

y

s

srb

Page 175: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

Least Squares

Can Show: (math beyond this course)

Least Squares Fit Line:

• Passes through the point

• Has Slope:

(correction factor uses correlation, r)

),( yx

x

y

s

srb

Page 176: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

Least Squares

Can Show: (math beyond this course)

Least Squares Fit Line:

• Passes through the point

• Has Slope:

(correction factor uses correlation, r)

(think r = 0, and r < 0)

),( yx

x

y

s

srb

Page 177: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

Least Squares in Excel

• Could compute manually

Page 178: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

Least Squares in Excel

• Could compute manually

(using formulas for sX, sY &

r)

Page 179: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

Least Squares in Excel

• Could compute manually

• But EXCEL provides useful summaries

Page 180: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

Least Squares in Excel

• Could compute manually

• But EXCEL provides useful summaries:

– INTERCEPT (computes y-intercept b0)

Page 181: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

Least Squares in Excel

• Could compute manually

• But EXCEL provides useful summaries:

– INTERCEPT (computes y-intercept b0)

– SLOPE (computes slope b1)

Page 182: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

Least Squares in Excel

Suggested

HW: 2.59 a, b

Page 183: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

Least Squares in Excel

• Could compute manually

• But EXCEL provides useful summaries:

– INTERCEPT (computes y-intercept b0)

– SLOPE (computes slope b1)

Additional trick: To draw overlay fit line

Page 184: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

Least Squares in Excel

• Could compute manually

• But EXCEL provides useful summaries:

– INTERCEPT (computes y-intercept b0)

– SLOPE (computes slope b1)

Additional trick: To draw overlay fit line

(to existing data plot)

Page 185: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

Least Squares in Excel

• Could compute manually

• But EXCEL provides useful summaries:

– INTERCEPT (computes y-intercept b0)

– SLOPE (computes slope b1)

Additional trick: To draw overlay fit line, – Right click a data point

Page 186: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

Least Squares in Excel

• Could compute manually

• But EXCEL provides useful summaries:

– INTERCEPT (computes y-intercept b0)

– SLOPE (computes slope b1)

Additional trick: To draw overlay fit line, – Right click a data point

– Choose: “Add Trendline” from menu

Page 187: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

Least Squares in Excel

Suggested

HW: 2.59 c

Page 188: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

And now for something completely different

Can you guess the phrase,that these pictures intend to convey?

Requires:“Thinking Outside the Box”

Also Called:“Lateral Thinking”

Page 189: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

And now for something completely different

Page 190: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

And now for something completely different

Egg Plant

Page 191: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

And now for something completely different

Page 192: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

And now for something completely different

Pool Table

Page 193: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

And now for something completely different

Page 194: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

And now for something completely different

Hole Milk

Page 195: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

And now for something completely different

Page 196: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

And now for something completely different

Tap Dancers

Page 197: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

Linear Regression - Insight

Another Demo, by Charles Stanton, CSUSBhttp://www.math.csusb.edu/faculty/stanton/m262/regress

Page 198: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

Linear Regression - Insight

Another Demo, by Charles Stanton, CSUSBhttp://www.math.csusb.edu/faculty/stanton/m262/regress

What University?

Page 199: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

Linear Regression - Insight

Another Demo, by Charles Stanton, CSUSBhttp://www.math.csusb.edu/faculty/stanton/m262/regress

What University?

California State University

Page 200: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

Linear Regression - Insight

Another Demo, by Charles Stanton, CSUSBhttp://www.math.csusb.edu/faculty/stanton/m262/regress

What University?

California State University

San Bernardino

Page 201: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

Linear Regression - Insight

Another Demo, by Charles Stanton, CSUSBhttp://www.math.csusb.edu/faculty/stanton/m262/regress

• Now we choose data

Page 202: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

Linear Regression - Insight

Another Demo, by Charles Stanton, CSUSBhttp://www.math.csusb.edu/faculty/stanton/m262/regress

• Now we choose data

• Applet draws fit line

Page 203: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

Linear Regression - Insight

Another Demo, by Charles Stanton, CSUSBhttp://www.math.csusb.edu/faculty/stanton/m262/regress

• Now we choose data

• Applet draws fit line

• Study quality of fit, using Residual Plot

Page 204: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

Diagnostic for Linear Regression

Recall Normal Quantile plot shows “how well

normal curve fits a data set”

Page 205: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

Diagnostic for Linear Regression

Recall Normal Quantile plot shows “how well

normal curve fits a data set”

Useful visual assessment of how well the

regression line fits data

Page 206: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

Diagnostic for Linear Regression

Recall Normal Quantile plot shows “how well

normal curve fits a data set”

Useful visual assessment of how well the

regression line fits data is:

Residual Plot

Page 207: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

Diagnostic for Linear Regression

Recall Normal Quantile plot shows “how well

normal curve fits a data set”

Useful visual assessment of how well the

regression line fits data is:

Residual Plot

Just Plot of Residuals (on Y axis),

versus X’s (on X axis)

Page 208: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

Charles Stanton Demo AppletAdd point by clicking

(no line yet…)

Page 209: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

Charles Stanton Demo AppletAdd point by clicking, and another

Page 210: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

Charles Stanton Demo AppletAdd point by clicking, and another

Applet draws line

Page 211: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

Charles Stanton Demo AppletAdd point by clicking, and another

Applet draws line, and gives equation

Page 212: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

Charles Stanton Demo AppletAdd point by clicking, and another

Applet draws line, and gives equation

And plots residuals

Page 213: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

Charles Stanton Demo AppletNow add another point

(goal: very close to line)

Page 214: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

Charles Stanton Demo AppletNow add another point

Equation similar, (but not exact)

Page 215: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

Charles Stanton Demo AppletNow add another point

Residuals now non-0

Page 216: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

Charles Stanton Demo AppletNow add another point

Residuals now non-0

& Magnify relative differences

Page 217: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

Charles Stanton Demo AppletNow add more points along line

Residuals magnify differences

Page 218: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

Charles Stanton Demo AppletNow add more points along line

Residuals magnify differences

(note change of scale)

Page 219: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

Charles Stanton Demo AppletNow add more points along line

Major players clearly stand out

Page 220: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

Charles Stanton Demo AppletOutliers have a drastic impact

Page 221: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

Charles Stanton Demo AppletOutliers have a drastic impact

Poor fit to data along previous line

Page 222: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

Charles Stanton Demo AppletOutliers have a drastic impact

Poor fit to data along previous line

(shows up clearly)

Page 223: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

Charles Stanton Demo AppletMisfit shows up clearly

Especially nonlinear relationships

Page 224: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

Charles Stanton Demo AppletMisfit shows up clearly

Especially nonlinear relationships

(even when hard to see in scatterplot)

Page 225: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

Linear Regression - Insight

Another Demo, by Charles Stanton, CSUSBhttp://www.math.csusb.edu/faculty/stanton/m262/regress

• Now we choose data

• Applet draws fit line

• Study quality of fit, using Residual Plot

Page 226: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

Linear Regression - Insight

Another Demo, by Charles Stanton, CSUSBhttp://www.math.csusb.edu/faculty/stanton/m262/regress

• Now we choose data

• Applet draws fit line

• Study quality of fit, using Residual Plot

• Useful visual diagnostic

Page 227: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

Linear Regression - Insight

Another Demo, by Charles Stanton, CSUSBhttp://www.math.csusb.edu/faculty/stanton/m262/regress

• Now we choose data

• Applet draws fit line

• Study quality of fit, using Residual Plot

• Useful visual diagnostic

(Good at highlighting problems)

Page 228: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

Residual Diagnostic Plot

Toy Examples:http://www.stat-or.unc.edu/webspace/courses/marron/UNCstor155-2009/ClassNotes/Stor155Eg19.xls

1. Generate Data to follow a line

• Residuals seem to be randomly distributed

• No apparent structure

• Residuals seem “random”

• Suggests linear fit is a good model for data

Page 229: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

Residual Diagnostic Plot

Toy Examples:http://www.stat-or.unc.edu/webspace/courses/marron/UNCstor155-2009/ClassNotes/Stor155Eg19.xls

2. Generate Data to follow a Parabola

• Shows systematic structure

• Pos. – Neg. – Pos. suggests data follow a

curve (not linear)

• Suggests that line is a poor fit

Page 230: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

Residual Diagnostic Plot

Example from text: problem 2.74http://stat-or.unc.edu/webspace/postscript/marron/Teaching/stor155-2007/Stor155Eg15.xls

Study (for runners), how Stride Rate

depends on Running Speed

(to run faster, need faster strides)

a. & b. Scatterplot & Fit line

c. & d. Residual Plot & Comment

Page 231: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

Residual Diagnostic Plot E.g.http://stat-or.unc.edu/webspace/postscript/marron/Teaching/stor155-2007/Stor155Eg15.xls

a. & b. Scatterplot & Fit line

• Linear fit looks very good

• Backed up by correlation ≈ 1

• “Low noise” because data are averaged

(over 21 runners)

Page 232: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

Residual Diagnostic Plot E.g.http://stat-or.unc.edu/webspace/postscript/marron/Teaching/stor155-2007/Stor155Eg15.xls

c. & d. Residual Plot & Comment

• Systematic structure: Pos. – Neg. – Pos.

• Not random, but systematic pattern

• Suggests line can be improved

(as a model for these data)

• Residual plot provides “zoomed in view”

(can’t see this in raw data)

Page 233: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

Residual Diagnostic Plot

Suggested HW 2.87

Page 234: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

Effect of a Single Data Point

Suggested HW: 2.102

Page 235: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

Least Squares Prediction

Idea: After finding a & b (i.e. fit line)

For new x, predict new value of y,

Using b x + a

I. e. “predict by point on the line”

Page 236: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

Least Squares Prediction

EXCEL Prediction: revisit examplehttp://stat-or.unc.edu/webspace/postscript/marron/Teaching/stor155-2007/Stor155Eg14.xls

EXCEL offers two functions:

• TREND

• FORECAST

They work similarly, input raw x’s and y’s

(careful about order!)

Page 237: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

Least Squares Prediction

Caution: prediction outside range of data is called “extrapolation”

Dangerous, since small errors are magnified

Page 238: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

Least Squares Prediction

Suggested HW:

2.67a, b,

2.75 (hint, use Least Squares formula above, since don’t have raw data)

Page 239: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

Interpretation of r squared

Recall correlation measures

“strength of linear relationship”

is “fraction of variation explained by line”

for “good fit”

for “very poor fit”

measures “signal to noise ratio”

1

2r

0

r

2r

Page 240: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

Interpretation of r squaredRevisit

http://stat-or.unc.edu/webspace/postscript/marron/Teaching/stor155-2007/Stor155Eg13.xls

(a, c, d) “data near line”high signal to noise ratio

(b) “noisier data”low signal to noise ratio

(c) “almost pure noise”nearly no signal

197.02 r

58.02 r

003.02 r

Page 241: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

Interpretation of r squared

Suggested HW:

2.67 c

Page 242: Final Examination Thursday, April 30, 4:00 – 7:00 Location: here, Hanes 120

Statistical Inference

Show

Excel Output