{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

# STA5106_FRADE_HW3 - STA5106 Dr Srivastava Homework 3 Jaime...

This preview shows pages 1–5. Sign up to view the full content.

STA5106: Dr. Srivastava Homework 3 Jaime Frade 1. multilinreg.m OUTPUT >> x = [3 3 3 1; 2 1 2 1; 1 3 3 1; 3 2 2 3; 1 3 2 1] x = 3 3 3 1 2 1 2 1 1 3 3 1 3 2 2 3 1 3 2 1 >> y = [52;28;44;48;40] y = 22 14 20 25 17 >> bhat = multilinreg(x,y) m1 = 0.999999999999974 1.999999999999997 3.000000000000015 4.000000000000004 bhat = 0.999999999999997 1.999999999999995 3.000000000000004 4.000000000000003

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
STA5106: Dr. Srivastava Homework 3 Jaime Frade CODE %generates upper trangular matrix, then calls backsub function to get least %squares estimated values, the betas. Also takes reflection matrix from %zero vector returned from house program. function m = multilinreg(x,y) [m,n] = size(x); V=zeros(m,1); for i=1:n, V(i:m,1) = house(x(i:m,i)); x(i:m,i:n) = rowhouse(x(i:m,i:n),V(i:m,1)); beta = -2*V(i:m,1)'*y(i:m,1)/(V(i:m,1)'*V(i:m,1)); y(i:m,1) = y(i:m,1)+ beta*V(i:m,1); end m=backsub(x,y); %can test by using built-in function m1 = inv((x'*x))*x'*y 3.
STA5106: Dr. Srivastava Homework 3 Jaime Frade OUTPUT %to display variables >> load hw3c_dat.mat >> whos Name Size Bytes Class Attributes X 200x100 160000 double y 200x1 1600 double (a) (i) Find the sample covariance matrix C OUTPUT >>covariance = Cov(X) (ii) Compute the singular value decomposition (SVD) of C to obtain the orthogonal matrix U ([U,S,V] = svd(X) produces a diagonal matrix S of the same dimension as X, with nonnegative diagonal elements in decreasing order, and unitary matrices U and V so that

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### Page1 / 5

STA5106_FRADE_HW3 - STA5106 Dr Srivastava Homework 3 Jaime...

This preview shows document pages 1 - 5. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online