inmoose.edgepy.adjustedProfileLik

inmoose.edgepy.adjustedProfileLik(dispersion, y, design, offset, weights=None, adjust=True, start=None, get_coef=False)

Compute adjusted profile log-likelihoods for the dispersion parameters of genewise negative binomial GLMs.

For each row of data, compute the adjusted profile log-likelihood for the dispersion parameter of the negative binomial GLM. The adjusted log likelihood is described by McCarthy et al. (2012) [2] and is based on the method of Cox and Reid (1987) [1].

The adjusted profile likelihood is an approximation to the log-likelihood function, conditional on the estimated values of the coefficients in the NB log-linear models. The conditions likelihood approach is a technique for adjusting the likelihood function to allow for the fact that nuisance parameters have to be estimated in order to evaluate the likelihood. When estimating the dispersion, the nuisance parameters are the coefficients in the log-linear models.

This implementation calls the LAPACK library to perform the Cholesky decomposition during adjustment estimation.

The purpose of start and get_coef is to allow hot-starting for multiple calls to adjustedProfileLik, when only dispersion is altered. Specifically, the returned GLM coefficients from one call with get_coef=True can be used as the start values for the next call.

The weights argument is interpreted in terms of averages. Each value of y is assumed to be the average of n i.i.d NB counts, where n is given by the weight. This assumption can be generalized to fractional weights.

Parameters:
  • dispersion (float or array) – vector of dispersions

  • y (matrix) – matrix of counts

  • design (matrix) – design matrix

  • offset (matrix or vector or float) – matrix of same shape as y giving offsets for the log-linear models. Can also be scalar or a vector of length y.shape[1], in which case it is broadcasted to the same shape as y.

  • weights (matrix, optional) – numeric matrix giving observation weights

  • adjust (bool, optional) – if True then Cox-Reid adjustment is made to the log-likelihood. if False then the log-likelihood is returned without adjustment.

  • start (matrix, optional) – numeric matrix of starting values for the GLM coefficients, to be passed to glmFit().

  • get_coef (bool, optional) – specifying whether fitted GLM coefficients should be returned

Returns:

  • array – vector of adjusted profile log-likelihood values is returned containing one element for each row of y.

  • matrix (only if get_coef is True) – the matrix of fitted GLM coefficients

References