R/OLS_QR.R

Defines functions OLS_QR

Documented in OLS_QR

#' Solve OLS problem using QR decomposition
#'
#' @param X A n by d matrix
#' @param y A n by 1 column vector
#'
#' @export
OLS_QR <- function(X,y) {
  QR <- qr(X)
  Q <- qr.Q(QR)
  R <- qr.R(QR)
  beta <- backsolve(R,t(Q)%*%y)
  return(beta)
}
jcorrett/stats230.Rpackage documentation built on March 21, 2022, 5:36 a.m.