R/gradf_func.R

Defines functions gradf_func

Documented in gradf_func

#' Gradient function for linear regression
#' @param x coeffcient vector (matrix)
#' @param AtA cross-product of design matrix
#' @param Atb cross-product of design matrix and response vector
#' @return the gradient matrix with respect to A, b, and x
#' @details This function returns the gradient for linear regression formula
#' @examples
#' set.seed(1)
#' x <- stats::rnorm(10)
#' A <- matrix(stats::rnorm(200), 20, 10)
#' b <- stats::rnorm(20)
#' AtA <- t(A) %*% A
#' Atb <- t(A) %*% b
#' gradf_func(x, AtA, Atb)
#' @export

gradf_func <- function(x, AtA, Atb){
    return(AtA %*% x - Atb)
}
kevinbai92/LSvarEstimate documentation built on May 8, 2020, 1:04 a.m.