R/sumGradients.R

Defines functions sumGradients

### Sum the observation-wise gradient
sumGradients <- function( gr, nParam ) {

   if( !is.null(dim(gr))) {
      gr <- colSums(gr)
   } else {
      ## ... or vector if only one parameter
      if( nParam == 1 && length( gr ) > 1 ) {
         gr <- sum(gr)
      }
   }
   return( gr )
}

Try the maxLik package in your browser

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

maxLik documentation built on May 29, 2024, 2:32 a.m.