R/lmxy2.R

Defines functions lmxy2

Documented in lmxy2

#' Multiple LM
#'
#' Fit multiple LM fast, only returning the coefficients.
#'
#' @param X a matrix containing predictor values and 1 in first column.
#' @param y a vector (or single-column matrix) containing response values.
#'
#' @return Vector containing the coefficients.
#'
#' @seealso
#' \code{\link{lmxy1}}.
#'
#' @export

lmxy2 <- function(X, y)
{
  XtX <- crossprod(X,X)
  Xty <- crossprod(X,y)

  beta <- c(solve(XtX, Xty))

  beta
}
arnima-github/arni documentation built on Oct. 28, 2023, 6:18 p.m.