# STA 4210 solution for homework7

**Topics:**Normal distribution, Knitting, Confidence interval

**Pages:**13 (2089 words)

**Published:**October 31, 2014

Homework

For

Quiz

7

Dingke

Yin

5.24

>

X=matrix(c(1,1,1,1,1,1,4,1,2,3,3,4),nrow=6,ncol=2)

>

Y=matrix(c(16,5,10,15,13,22),nrow=6,ncol=1)

>

solve(t(X)%*%X)%*%t(X)%*%Y

[,1]

[1,]

0.4390244

[2,]

4.6097561

>

Y-‐X%*%solve(t(X)%*%X)%*%t(X)%*%Y

[,1]

[1,]

-‐2.87804878

[2,]

-‐0.04878049

[3,]

0.34146341

[4,]

0.73170732

[5,]

-‐1.26829268

[6,]

3.12195122

>

J=matrix(1,6,6)

>

E=Y-‐X%*%solve(t(X)%*%X)%*%t(X)%*%Y

>

t(E)%*%E

[,1]

[1,]

20.29268

>

t(Y)%*%(H-‐1/6*J)%*%Y

[,1]

[1,]

145.2073

>

1/4*t(E)%*%E

[,1]

[1,]

5.073171

>

5.073171*solve(t(X)%*%X)

[,1]

[,2]

[1,]

6.805473

-‐2.1035099

[2,]

-‐2.103510

0.7424153

>

P=matrix(c(1,4),nrow=2,ncol=1)

>

t(P)%*%solve(t(X)%*%X)%*%t(X)%*%Y

[,1]

[1,]

18.87805

>

5.073171*(1+t(P)%*%solve(t(X)%*%X)%*%P)

[,1]

[1,]

6.929209

s^2{b1}=0.7424153

s{b0,b1}=

-‐2.1035099

s{b0}=

2.608730

>

H=X%*%solve(t(X)%*%X)%*%t(X)

>

H

[,1]

[,2]

[,3]

[,4]

[,5]

[,6]

[1,]

0.36585366

-‐0.1463415

0.02439024

0.1951220

0.1951220

0.36585366

[2,]

-‐0.14634146

0.6585366

0.39024390

0.1219512

0.1219512

-‐0.14634146

[3,]

0.02439024

0.3902439

0.26829268

0.1463415

0.1463415

0.02439024

[4,]

0.19512195

0.1219512

0.14634146

0.1707317

0.1707317

0.19512195

[5,]

0.19512195

0.1219512

0.14634146

0.1707317

0.1707317

0.19512195

[6,]

0.36585366

-‐0.1463415

0.02439024

Please join StudyMode to read the full document