JShen W13Tute

Embed Size (px)

Citation preview

  • 8/2/2019 JShen W13Tute

    1/17

    SummaryExam Tips

    Matrix ManipulationRegression

    Jon Shen Week 13 Tutorials

    1st June 2010

    Jon Shen Week 13 Tutorials

    http://find/http://goback/
  • 8/2/2019 JShen W13Tute

    2/17

    SummaryExam Tips

    Matrix ManipulationRegression

    Summary

    Multiple Regression: Fit y = 0 + 1x1 + 2x2 + . . . to data For example, x1 = x, x2 = x

    2

    or x1 = ex, x2 = ln x, x3 = x

    5

    The equation is linear in the coefficients Know how to:

    Express a given linear model in matrix-vector form; * Obtain least squares estimates if given relevant matrices; Determine E[] and Var[]; * Hypothesis tests: i = c for some constant c; * Determine confidence intervals for i; Calculate R2 and adjusted R2; Construct an ANOVA table for the regression; Interpret the coefficients * Determine a confidence intervals for the mean Y value or a

    prediction interval for the individual Y value corresponding to

    a given x value (see PASS questions);Jon Shen Week 13 Tutorials

    http://find/
  • 8/2/2019 JShen W13Tute

    3/17

    SummaryExam Tips

    Matrix ManipulationRegression

    Consultation

    Week 13: 4-5pm today in Quad2061

    Week 13: 6pm+ today?

    Week 13: Thursday 11-1 via email / www.scriblink.com Stuvac/Exam period: email - slow reply before June 17th

    Exam period: 17/18th June: In person consultation at uniQuad2061 (email to arrange appointment)

    Exam period: 17/18th June: Online consultation via email /www.scriblink.com

    [email protected]

    Jon Shen Week 13 Tutorials

    http://www.scriblink.com/http://www.scriblink.com/http://www.scriblink.com/http://www.scriblink.com/http://find/
  • 8/2/2019 JShen W13Tute

    4/17

    SummaryExam Tips

    Matrix ManipulationRegression

    Preparation

    1. FORMULA BOOK! Know whats in here.

    2. Starting point: lecture slides and tutorial problems

    3. Revise class quizzes! (Quiz 1 Q5 and Quiz 2 Q4...)

    4. Past Quizzes/Final exams

    5. PASS questions - extra revision

    6. IAA papers - even more revision http://www.actuaries.org.uk/students/exams/

    preparing/exam_papers 2005-2009 - CT3 (most relevant) 2000-2004 - Subject 101 1997-1999 - Subject C

    Jon Shen Week 13 Tutorials

    S

    http://www.actuaries.org.uk/students/exams/preparing/exam_papershttp://www.actuaries.org.uk/students/exams/preparing/exam_papershttp://www.actuaries.org.uk/students/exams/preparing/exam_papershttp://www.actuaries.org.uk/students/exams/preparing/exam_papershttp://find/
  • 8/2/2019 JShen W13Tute

    5/17

    SummaryExam Tips

    Matrix ManipulationRegression

    Technique

    1. READ THE QUESTION

    Understand what is being asked - highlight key words2. Demonstrate that you understand the material

    If short on time, indicate how you would attempt to solve theproblem

    3. Do questions you are most confident with first, and look at

    the number of marks allocated

    Jon Shen Week 13 Tutorials

    S

    http://find/http://goback/
  • 8/2/2019 JShen W13Tute

    6/17

    SummaryExam Tips

    Matrix ManipulationRegression

    Properties

    Multiplication:

    a b

    c d

    across

    f g

    h k

    down=

    af+ bh ag + bkcf+ dh cg + dk

    Differentiation:

    TXTY = XTY and

    (XTY)T = XTY

    TXTX = 2XTX

    Expectation: If B is random and A is non-random, then E[AB] = AE[B] Var[AB] = AVar[B]AT

    Jon Shen Week 13 Tutorials

    Summary

    http://find/
  • 8/2/2019 JShen W13Tute

    7/17

    SummaryExam Tips

    Matrix ManipulationRegression

    Example 1Example 2Example 3

    Linear Model

    Consider the model y =

    30 + 1x + 2x21. Is this a linear model? If not, explain how you can transform

    it into a linear model.

    2. Write the (transformed) model in matrix form.

    Jon Shen Week 13 Tutorials

    Summary

    http://find/http://goback/
  • 8/2/2019 JShen W13Tute

    8/17

    SummaryExam Tips

    Matrix ManipulationRegression

    Example 1Example 2Example 3

    Linear Model - Solution

    1. y3 = 0 + 1x + 2x2

    2. Y = X + where

    Y =

    y31

    y32

    .

    .

    .y3n

    , X =

    1 x1 x21

    1 x2 x22

    . . .

    . . .

    1 xn x2n

    , =

    012

    , =

    12.

    .

    .n

    ,

    Jon Shen Week 13 Tutorials

    Summary

    http://find/http://goback/
  • 8/2/2019 JShen W13Tute

    9/17

    SummaryExam Tips

    Matrix ManipulationRegression

    Example 1Example 2Example 3

    and ANOVA Table

    You decide to fit the model from the previous slide to data. Youhave 103 data points and are given that

    (X

    T

    X)

    1

    = 10

    638580 2237 1040

    2237 230 341040 34 223 andXTY =

    7651.7291333.6053992.96

    .

    Also

    123

    i=1 y2

    i = 501813.55,

    123

    i=1 y2

    i = 500881.11, y = 62.21.

    a) Determine the least squares estimates .b) Construct an ANOVA table for this model, and hence calculatethe R2 and adjusted R2.

    Jon Shen Week 13 Tutorials

    SummaryE l 1

    http://find/
  • 8/2/2019 JShen W13Tute

    10/17

    SummaryExam Tips

    Matrix ManipulationRegression

    Example 1Example 2Example 3

    and ANOVA Table - Solution

    a) = (XTX)1XTYUsing matrix multiplication:

    = 10

    638580 2237 10402237 230 341040 34 223

    7651.72

    91333.6053992.96= 106

    38580 7651.72 2237 91333.60 1040 53992.962237 7651.72 + 230 91333.60 34 53992.96

    1040

    7651.72

    34

    91333.60 + 223

    53992.96

    = 106

    347374162054069.72

    977298.88

    =

    34.7374162.05406972

    0.97729888

    =

    01

    2

    Jon Shen Week 13 Tutorials

    SummaryE l 1

    http://find/
  • 8/2/2019 JShen W13Tute

    11/17

    SummaryExam Tips

    Matrix ManipulationRegression

    Example 1Example 2Example 3

    and ANOVA Table - Solution

    b) N.B. The notation used here is slightly different from thenotation used in calculating ANOVA tables elsewhere.SST =

    123

    i=1 y2

    i n(y)2 = 501813.5512362.212 = 25793.2057SSR = y

    2

    i

    n(y)2 = 500881.11

    123

    62.212 = 24860.7657

    There are 123 data points and 3 regression parameters (s)Hence, the total degrees of freedom is 123 - 1 = 122, and theregression degrees of freedom is 3 - 1 = 2.This gives us the following entries in the table:

    Source df SS MS = SS/df F-StatRegression 2 24860.7657 25793.2057

    2= 12896.60285 ?

    Error ? ? ?

    Total 122 25793.2057

    Jon Shen Week 13 Tutorials

    SummaryExample 1

    http://find/
  • 8/2/2019 JShen W13Tute

    12/17

    yExam Tips

    Matrix ManipulationRegression

    Example 1Example 2Example 3

    and ANOVA Table - Solution

    b) We can fill in the second row of the table:122 - 2 = 120

    25793.2057 - 24860.7657 = 932.44932.44

    120= 7.7703

    Source df SS MS = SS/df F-Stat

    Regression 2 24860.7657 12896.60285 ?

    Error 120 932.44 7.7703Total 122 25793.2057

    Jon Shen Week 13 Tutorials

    SummaryExample 1

    http://find/
  • 8/2/2019 JShen W13Tute

    13/17

    Exam TipsMatrix Manipulation

    Regression

    Example 1Example 2Example 3

    and ANOVA Table - Solution

    b) Finally, you can calculate the F-statistic:12896.60285

    7.7703= 1659.723244

    Source df SS MS = SS/df F-StatRegression 2 24860.7657 12896.60285 1659.723244

    Error 120 932.44 7.7703

    Total 122 25793.2057

    R2

    =SSR

    SST =24860.7657

    25793.2057 = 0.963849395

    R2a = 1MSESSTn1

    = 1 122 7.770325793.2057

    = 0.963247042

    Jon Shen Week 13 Tutorials

    SummaryExample 1

    http://find/
  • 8/2/2019 JShen W13Tute

    14/17

    Exam TipsMatrix Manipulation

    Regression

    Example 1Example 2Example 3

    Hypothesis Testing and Confidence Interval

    From the previous slides, you have calculated

    =

    34.742.050.98

    , (XTX)1 = 106

    38580 2237 10402237 230 34

    1040

    34 223

    You have also constructed the ANOVA table

    Source df SS MS = SS/df F-Stat

    Regression 2 24860.77 12896.60 1659.72

    Error 120 932.44 7.77Total 122 25793.21

    a) Determine a 95% confidence interval for 2.b) Test the hypothesis H0 : 1 = 2 against H1 : 1 > 2 at 1%

    significance.Jon Shen Week 13 Tutorials

    SummaryE Ti

    Example 1

    http://find/
  • 8/2/2019 JShen W13Tute

    15/17

    Exam TipsMatrix Manipulation

    Regression

    Example 1Example 2Example 3

    Hypothesis Testing and Confidence Interval - Solution

    We need estimates of Var[1] and Var[2].From slide 8, Var[] = 2(XTX)1.

    2

    is unknown, so we estimate this with s2

    = MSE = 7.77 fromthe ANOVA table.

    Then our estimate is 7.77 10638580 2237 10402237 230 341040 34 223

    In particular, we want Var[1] = 7.77 106 230 = 0.0017871and Var[2] = 7.77 106 223 = 0.00173271

    Jon Shen Week 13 Tutorials

    SummaryE Ti

    Example 1

    http://find/
  • 8/2/2019 JShen W13Tute

    16/17

    Exam TipsMatrix Manipulation

    Regression

    pExample 2Example 3

    Hypothesis Testing and Confidence Interval - Solution

    a) We have2 2Var[2] tnp = t1233 = t120

    Then

    Pr1.98 2 2Var[2] 1.98

    = 0.95

    Pr1.98

    0.98

    2

    0.00173271 1.98 = 0.95

    Pr(0.89758085 2 1.06241915) = 0.95

    So a 95% confidence interval for 2 is (0.89758085, 1.06241915)

    Jon Shen Week 13 Tutorials

    SummaryExam Tips

    Example 1

    http://find/
  • 8/2/2019 JShen W13Tute

    17/17

    Exam TipsMatrix Manipulation

    Regression

    pExample 2Example 3

    Hypothesis Testing and Confidence Interval - Solution

    b) H0 : 1 = 2 against Ha : 1 > 2Under the null, the test statistic is

    1 2Var[1] = 2.05 20.0017871 = 0.002113705

    This is a one-sided test. The 99th quantile for a t120 distribution is2.358. The observed value of 0.002113705 is less than thetheoretical value of 2.358, so fail to reject the null as there isinsufficient evidence to suggest that 1 is significantly differentfrom two.

    Jon Shen Week 13 Tutorials

    http://find/