Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started