R/F_getDevMat.R

Defines functions getDevMat

Documented in getDevMat

#' ACalculate the matrix of deviance residuals
#'
#'@param X the data matrix
#'@param thetaMat the matrix of dispersions
#'@param mu the matrix of means
#'
#'@return The matrix of deviance residuals
getDevMat = function(X, thetaMat, mu) {
    tmpMat = suppressWarnings(sqrt(2 * (X *
        log(X/mu) - (X + thetaMat) * log((1 +
        X/thetaMat)/(1 + mu/thetaMat)))) *
        sign(X - mu))
    tmpMat[X == 0] = -sqrt((2 * thetaMat *
        log(1 + mu/thetaMat))[X == 0])
    # zero observations are always smaller
    # than the mean
    tmpMat[is.na(tmpMat)] = 0  #Correct for numerical/real NAs
    tmpMat
}

Try the RCM package in your browser

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

RCM documentation built on Nov. 8, 2020, 5:22 p.m.