negbin: Negative binomial family with an estimated (or fixed)...

View source: R/internal_family.R

negbinR Documentation

Negative binomial family with an estimated (or fixed) dispersion

Description

A family object for negative binomial responses, for use as the family argument of cf_glm_hv and cf_dglm_hv. With theta = NULL (default) the dispersion parameter \theta (variance \mu + \mu^2/\theta) is estimated by maximum likelihood: it is re-estimated on the training samples after the initial GLM and after every accepted spatial scale, so that it reflects the over-dispersion that remains once the multiscale spatial process is modeled. A numeric theta keeps the dispersion fixed (equivalent to MASS::negative.binomial(theta), which is also accepted).

Usage

negbin(theta = NULL, link = "log")

Arguments

theta

NULL (estimate) or a positive number (fixed).

link

Link function: "log" (default), "sqrt" or "identity".

Value

An object of class "family". The fitted value of \theta is stored in family$theta of the family returned in mod_hv$other$family (and mod$other$family).

See Also

cf_glm_hv, cf_dglm_hv

Examples

set.seed(1)
n      <- 300
coords <- cbind(runif(n), runif(n))
y      <- rnbinom(n, size = 2, mu = exp(1 + sin(4 * coords[, 1])))
mod_hv <- cf_glm_hv(y = y, coords = coords, family = negbin())
mod_hv$other$family$theta   # estimated dispersion


spCF documentation built on Oct. 5, 2026, 5:07 p.m.