Question: x

x<-c(10,20,25,30,35,45) y<-c(13,16,14,18,16,19) x0 <- c(1,1,1,1,1,1) X<-data.frame(list(x0=x0,x=x)) X<-as.matrix(X) n<-nrow(X) p<-ncol(X) X #Computing the b vector b <- solve(t(X)%*%X)%*%t(X)%*%y b #inverse of transpose matrix C <- solve(t(X)%*%X) C #Compute H Matrix H = X%*%solve((t(X)%*%X))%*%t(X) # can compute H using C H = X%*%C%*%t(X) round(H,2) # Compute the predicted values yhat=X%*%solve((t(X)%*%X))%*%t(X)%*%y # compute predicted values using H yhat= H%*%y yhat

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Mathematics Questions!