Toy R function for solving ordinary least squares by singular value decomposition
问题 I'm trying to write a functions for multiple regression analysis ( y = Xb + e ) using a singular value decomposition for matrices. y and X must be the input and regression coefficients vector b , the residual vector e and variance accounted for R2 as output. Beneath is what I have so far and I'm totally stuck. The labels part of the weight also gives me an error. What is this labels part? Can anybody give me some tips to help me proceed? Test <- function(X, y) { x <- t(A) %*% A duv <- svd(x)