#' 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)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.