stat3008 assignment 2 solutions (2010 – 2011 … ex2 solutions.pdf ·  · 2012-01-30stat3008...

5
STAT3008 Assignment 2 Solutions (2010 – 2011 Semester 2) Q1. Problem 2.1 2.1.1 R Codes: library(alr3) data(htwt) plot(htwt) With only 10 points, it is hard to determine whether a simple linear regression is enough or not. 2.1.2 R Codes: library(alr3) data(htwt) plot(htwt) fit=lm(Wt~Ht,data=htwt) #Fit the regression line abline(fit) average=mean(htwt) #Compute the means s=(10-1)*cov(htwt) #cov() computes the sample covariance matrix s #Display Sxx,Syy,Sxy average #Display the means

Upload: phunghuong

Post on 18-Apr-2018

225 views

Category:

Documents


3 download

TRANSCRIPT

Page 1: STAT3008 Assignment 2 Solutions (2010 – 2011 … Ex2 Solutions.pdf ·  · 2012-01-30STAT3008 Assignment 2 Solutions (2010 – 2011 Semester 2) Q1. ... R Codes: library(alr3) data(htwt)

STAT3008 Assignment 2 Solutions

(2010 – 2011 Semester 2) Q1. Problem 2.1 2.1.1 R Codes: library(alr3) data(htwt) plot(htwt)

With only 10 points, it is hard to determine whether a simple linear regression is enough or not. 2.1.2 R Codes: library(alr3) data(htwt) plot(htwt) fit=lm(Wt~Ht,data=htwt) #Fit the regression line abline(fit) average=mean(htwt) #Compute the means s=(10-1)*cov(htwt) #cov() computes the sample covariance matrix s #Display Sxx,Syy,Sxy average #Display the means

type_ok_login
Typewritten Text
type_ok_login
Typewritten Text
type_ok_login
Typewritten Text
type_ok_login
Typewritten Text
type_ok_login
Text Box
STAT3008 Exercise 2 Solutions (2011 - 2012 2nd Semester)
Page 2: STAT3008 Assignment 2 Solutions (2010 – 2011 … Ex2 Solutions.pdf ·  · 2012-01-30STAT3008 Assignment 2 Solutions (2010 – 2011 Semester 2) Q1. ... R Codes: library(alr3) data(htwt)

summary(fit) #Display the summary of the fitted model

Using R, we have 165.52x = , 59.47y = , 472.076SXX = , 731.961SYY = ,

274.786SXY = . 0 36.8759β = − and 1 0.5821β = .

2.1.3 R Codes: summary(fit) #Display the summary of the fitted model vcov(fit) #Display the variance-covariance matrix of the estimates

Using the above commands, we get

0( ) 64.4728se β = ,

1( ) 0.3892se β = and

2 28.456 71.502σ = = . Also,

0

1

4156.7419 25.070025.0700 0.1515

Covβ

β

− = −

.

2.1.4 R Codes: anova(fit) #Display the anova table of the fitted model We can get from the results that 2.237F statistic− = and 0.1731p value− = . Therefore, there is no strong evidence that the slope is significant.

Page 3: STAT3008 Assignment 2 Solutions (2010 – 2011 … Ex2 Solutions.pdf ·  · 2012-01-30STAT3008 Assignment 2 Solutions (2010 – 2011 Semester 2) Q1. ... R Codes: library(alr3) data(htwt)

Q2. 2.3 2.3.1

α is the value of ( | )E Y X x= .

2.3.2 2

1 1

2 2 21 1

( , ) ( ( ))

( ) 2 ( )( ) ( )i i

i i i i

RSS y x x

y y x x x x

α β α β

α β α β

= − − −

= − − − − + −

∑∑ ∑ ∑

And also, ( )( ) ( ) ( )0

i i i i iy x x y x x x xSXY SXY

α α− − = − − −

= − =∑ ∑ ∑

Therefore, 2 21 1 1( , ) ( ) 2iRSS y SXY SXXα β α β β= − − +∑

2 ( ) 0iRSS y

yα α

αα

α=

∂= − − =

=

1 1

11

1

2 2 0RSS SXY SXX

SXYSXX

β β

ββ

β

=

∂= − + =

=

2.3.3

2

( ) ( )Var Var ynσα = = ,

2

1( ) ( )SXYVar VarSXX SXX

σβ = =

Q3. 2.4.1 R Codes: library(alr3) data(heights) model1=lm(Dheight~Mheight,data=heights) summary(model1) anova(model1)

From the above commands, we can get 2 22.27 5.1529σ = = , 0 29.917β = ,

1 0.542β = ,

0( ) 1.623se β = and

1( ) 0.026se β = . 2 0.241R = means 0.241 of the

variability of the data is explained by the model. The ANOVA table shows that

Page 4: STAT3008 Assignment 2 Solutions (2010 – 2011 … Ex2 Solutions.pdf ·  · 2012-01-30STAT3008 Assignment 2 Solutions (2010 – 2011 Semester 2) Q1. ... R Codes: library(alr3) data(htwt)

435F statistic− = with 162 10p value −− =< × . F-test suggests that 1β is significant

or 1 0β ≠ . Q4. a)

Since 0 1i i iy x eβ β= + + ……(1)

0 1i i iy n x eβ β= + +∑ ∑ ∑

Then 0 1y x eβ β= + + ……(2)

(1)-(2), 0 1 0 1( ) ( )i i iy y x e x eβ β β β− = + + − + +

As a result, 1( ) ( )i i iy y x x e eβ− = − + −

b)

ie ’s are i.i.d. with ( ) 0iE e = and 2( )iVar e σ= . Thus, 2 2( )iE e σ= and

2 2( )iE e nσ=∑ .

Also, ( ) 0E e = and 2( ) /Var e nσ= . Thus, 2 2( ) /E e nσ= .

2 2 2 21 1( ) ( ) ( ) 2 ( )( )i i i i iy y x x e e e e x xβ β− = − + − + − −

2 2 2 21 1( ) ( ) ( ) 2 ( )( )i i i i iy y x x e e e e x xβ β− = − + − + − −∑ ∑ ∑ ∑

2 2 2 21 1[ ( ) ] ( ) ( ) 2 ( )[ ( )]i i i i iE y y x x E e e x x E e eβ β− = − + − + − −∑ ∑ ∑ ∑

( ) 0iE e e− =

22 2

22

222

22 2

( ) ( 2 )

( ) ( ) 2 ( )

2 ( )

1

i i i

i i

i

E e e E e e ee

E e E e E eeeE

n nn

n n

σσ

σσ σ

− = + −

= + −

= + −

−= − =

Therefore, 2 2 2 21[ ( ) ] ( ) ( 1)i iE y y x x nβ σ− = − + −∑ ∑

Page 5: STAT3008 Assignment 2 Solutions (2010 – 2011 … Ex2 Solutions.pdf ·  · 2012-01-30STAT3008 Assignment 2 Solutions (2010 – 2011 Semester 2) Q1. ... R Codes: library(alr3) data(htwt)

c)

0 1 iiy xβ β= +

1 1( ) iiy y x xβ β= − +

1 1( )i i iiy y y y x xβ β− = − − −

1( ) ( )i i iiy y y y x xβ− = − − −

22 2 21 1( ) ( ) ( ) 2 ( )( )i i i i iiy y y y x x x x y yβ β− = − + − − − −

22 2 21 1( ) ( ) ( ) 2 ( )( )i i i i iiy y y y x x x x y yβ β− = − + − − − −∑ ∑ ∑ ∑

22 2 2 21 1 2

( )( )( ) ( ) ( ) 2 ( )

( )i i

i i i iii

x x y yy y y y x x x x

x xβ β

− −− = − + − − × −

−∑∑ ∑ ∑ ∑∑

2 22 2 2 21 1( ) ( ) ( ) 2 ( )i i i iiy y y y x x x xβ β− = − + − − −∑ ∑ ∑ ∑

22 2 21( ) ( ) ( )i i iiy y y y x xβ− = − − −∑ ∑ ∑

d) From the results of (c), we get

22 2 21[ ( ) ] [ ( ) ] ( ) ( )i i iiE y y E y y E x xβ− = − − −∑ ∑ ∑

From the results of (b) and

22 2 2 21 1 1 12

( ) ( ) [ ( )]( )i

E Var Ex xσβ β β β= + = +−∑

,

22 2 2 2 2 2

1 12[ ( ) ] [ ( ) ( 1) ] [ ] ( )

( )i i iii

E y y x x n x xx xσβ σ β− = − + − − + −−∑ ∑ ∑∑

2 2 2 2 2 2 21 1[ ( ) ] ( ) ( 1) ( )i i iiE y y x x n x xβ σ σ β− = − + − − − −∑ ∑ ∑

2 2[ ( ) ] ( 2)i iE y y n σ− = −∑

Therefore,

22 2( )

[ ]2

i iy yE

nσ σ

−= =

−∑ .