R/mc_derivative_cholesky.R

Defines functions mc_derivative_cholesky

Documented in mc_derivative_cholesky

#' @title Derivatives of the Cholesky decomposition
#' @author Wagner Hugo Bonat
#'
#' @description This function compute the derivative of the Cholesky
#'     decomposition.
#'
#' @param derivada A matrix.
#' @param inv_chol_Sigma A matrix.
#' @param chol_Sigma A matrix.
#' @return A list of matrix.
#' @keywords internal
#' @details It is an internal function.

mc_derivative_cholesky <- function(derivada, inv_chol_Sigma,
                                   chol_Sigma) {
    faux <- function(derivada, inv_chol_Sigma, chol_Sigma) {
        t1 <- inv_chol_Sigma %*% derivada %*% t(inv_chol_Sigma)
        t1 <- tril(t1)
        diag(t1) <- diag(t1)/2
        output <- chol_Sigma %*% t1
        return(output)
    }
    list_D_chol <- lapply(derivada, faux,
                          inv_chol_Sigma = inv_chol_Sigma,
                          chol_Sigma = chol_Sigma)
    return(list_D_chol)
}

Try the mcglm package in your browser

Any scripts or data that you put into this service are public.

mcglm documentation built on Sept. 16, 2022, 1:06 a.m.