Skip to contents

Extract the fitted log likelihood, parameter-count information criteria, coefficient matrix or criterion sample size from L0glm.fit() and L0nnpois() models, including the special families.

Usage

# S3 method for class 'L0glm_fit'
logLik(object, ..., mu_floor = 0)

# S3 method for class 'L0glm_fit'
nobs(object, ...)

# S3 method for class 'L0glm_fit'
coef(object, ...)

GIC(object, ...)

# S3 method for class 'L0glm_fit'
GIC(object, ..., mu_floor = 0)

EBIC(object, ...)

# S3 method for class 'L0glm_fit'
EBIC(object, ..., mu_floor = 0)

MBIC(object, ...)

# S3 method for class 'L0glm_fit'
MBIC(object, ..., mu_floor = 0)

Arguments

object

A model returned by L0glm.fit() or L0nnpois().

...

Further arguments. stats::AIC() and stats::BIC() also accept several fitted models for comparison.

mu_floor

Nonnegative scoring-only floor for positive-family means. The default, zero, requests the exact score at the fitted means.

Value

logLik() returns an object of class logLik, with df and nobs attributes. Each criterion returns a numeric score; coef() returns a sparse matrix; nobs() returns the criterion sample size.

Details

logLik() evaluates the unpenalized likelihood at the returned coefficients, using the original prior observation weights and offsets. The adaptive-ridge penalty is not part of this value. No additional likelihood pass is performed when fitting ordinary GLMs or native Poisson models; the score is calculated when requested.

The logLik object's df attribute is a model parameter count, not the effective degrees of freedom of a ridge smoother. Nonzero coefficients and all mandatory coefficient dimensions are counted, along with one nuisance parameter for each estimated dispersion or NB theta. Known dispersions and fixed NB theta do not add a nuisance parameter. Gaussian estimated dispersion is profiled as weighted RSS divided by the number of positive-weight observations in each channel. Estimated Gamma and inverse-Gaussian dispersion use the same deviance-based family$aic convention as the existing package metrics, which need not equal the jointly maximized likelihood. For quasipoisson, the Poisson log-likelihood kernel is divided by the fitted dispersion. The regular criterion names report the corresponding quasi-information criteria; logLik() marks the value with quasi=TRUE. Use a common dispersion when comparing candidate models. Quasibinomial likelihood criteria are unavailable.

Multinomial grouped selection counts \(K-1\) parameters per active row for \(K\) categories. Ungrouped CLR selection counts nonzero entries minus active rows, imposing the zero-sum constraint. Mandatory rows count \(K-1\) parameters. Cox uses the Breslow partial log likelihood; its unspecified baseline hazard is not counted in these partial-likelihood criteria.

With \(d\) the parameter count, the scores are $$\mathrm{AIC}=-2\ell+2d,\qquad \mathrm{BIC}=-2\ell+d\log n,$$ $$\mathrm{GIC}=-2\ell+d\log p\log\log n.$$ EBIC() and MBIC() use the penalties documented in information_criteria. Here \(p\) is the original selectable predictor count, excluding mandatory terms and using at least one in logarithms. Ordinary multichannel GLMs count coefficient entries, so GIC() is distinct from a row-count grouped-selection objective. These scores describe the returned fit; penalized or incompletely converged fits need not maximize likelihood on their selected support.

nobs() reports the sample size used by the criteria. Existing conventions are retained: the number of design rows for ordinary GLMs; positive-weight rows for NB and multinomial; and weighted event count for Cox. Special-family criterion sample sizes are bounded below by two. Independent multichannel responses use the number of observations, rather than observations times channels, in the complexity penalty.

The usual stats::AIC() and stats::BIC() methods obtain their values through logLik(), including its df and nobs attributes. coef() returns the sparse coefficient matrix on the original scale and with the original coefficient dimensions.

Examples

set.seed(7)
X <- matrix(rnorm(240), 60, 4)
y <- 2 * X[, 1] + rnorm(60)
fit <- L0glm.fit(X, y, lambda = "gic", parallelize = FALSE)
logLik(fit)
c(AIC = AIC(fit), BIC = BIC(fit), GIC = GIC(fit),
  EBIC = EBIC(fit), MBIC = MBIC(fit))
coef(fit)