| Title: | Methods for Fitting Binomial Models with the Generalized Complementary Log-Log Function |
|---|---|
| Description: | Functionality for fitting a flexible link function in binomial regression based on a latent negative-binomial count. The original link function was proposed by Aranda-Ordaz (1981)<doi:10.1093/biomet/68.2.357>, and motivation via a negative-binomial latent count by van der Veen and Hui (in prep). |
| Authors: | Bert van der Veen [aut, cre], Francis K.C. Hui [aut] |
| Maintainer: | Bert van der Veen <[email protected]> |
| License: | GPL (>= 2) |
| Version: | 1.0 |
| Built: | 2026-10-27 20:25:04 UTC |
| Source: | https://github.com/cran/gcloglog |
This function is used with "family" functions in "glm" type modeling functions.
make.gcloglog(phi)make.gcloglog(phi)
phi |
value for the dispersion parameter the link is evaluated for. |
An object of class "link-glm, a list with (amongst others) the components:
Link function function(mu) for fixed phi
Inverse link function function(eta) for fixed phi
variance function
Derivative function(eta)
function(eta)TRUE
function(mu) that ensures 0<p<1
the name for the link gcloglog(phi)
Bert van der Veen
van der Veen and Hui (2025). In prep.
# Define logit link via gcloglog library(gcloglog) gcloglog1 <- make.gcloglog(1) # Fit logistic regression with gcloglog x <- rnorm(100) b1 = 2.3 b0 = 0.1 eta = b0+b1*x y = rbinom(length(x), 1, plogis(eta)) data <- data.frame(y = y,x = x) model <- glm(y~x, family = binomial(link = gcloglog1), data = data)# Define logit link via gcloglog library(gcloglog) gcloglog1 <- make.gcloglog(1) # Fit logistic regression with gcloglog x <- rnorm(100) b1 = 2.3 b0 = 0.1 eta = b0+b1*x y = rbinom(length(x), 1, plogis(eta)) data <- data.frame(y = y,x = x) model <- glm(y~x, family = binomial(link = gcloglog1), data = data)
This function takes a model object, estimates a parameter phi that controls the shape of the link function, and performs further profiling for retrieving a confidence interval. The implementation heavily borrows from tmbprofile in the TMB package.
## S3 method for class 'gcloglog' profile( model, CI = TRUE, alpha = 0.05, plot = TRUE, h = 0.02, ytol = 2, ystep = 0.1, maxit = 100, adaptive = TRUE, trace = TRUE, warmstart = TRUE, ... )## S3 method for class 'gcloglog' profile( model, CI = TRUE, alpha = 0.05, plot = TRUE, h = 0.02, ytol = 2, ystep = 0.1, maxit = 100, adaptive = TRUE, trace = TRUE, warmstart = TRUE, ... )
model |
a model object which accepts a family argument (should correspond to "binomial") with a link function. The model should have corresponding |
CI |
logical, defaults to |
alpha |
the confidence level, defaults to 0.05. |
plot |
logical, defaults to |
h |
initial adaptive stepsize. |
ytol |
Adjusts the range of the likelihood values. |
ystep |
Adjusts the reoslution of the likelihood profile. |
maxit |
Maximum number of iterations for the adaptive algorithm. |
adaptive |
logical, defaults to |
trace |
logical, defaults to |
warmstart |
logical, defaults to |
... |
other arguments passed to |
The final model inherits from class "gcloglog", so that its vcov,
summary, and confint return standard errors that account for the
estimation of phi; vcov(..., correct = FALSE) and
summary(..., correct = FALSE) give those conditional on phi. confint
defaults to Wald confidence intervals from the corrected covariance; method = "profile"
(and "boot" for glmer fits) are other options conditional on phi.
For a glm, the corrected asymptotic covariance is the naive covariance conditional
on the estimated link shape, plus a rank-one update, which follows from the
joint information of the coefficients and log(phi). For a glmer fit, it
is the fixed-effect block of the inverse of the joint Hessian of the
Laplace-approximated log-likelihood in the random-effect parameters (lme4's theta),
the fixed effects, and log(phi), obtained by finite differences
(hessian). Random-effect parameters at their boundary (a
singular fit) are held fixed.
The correction does not apply when the estimate of phi is at the boundary phi = 0,
where the fit is equivalent to cloglog regression (detected as the fit not improving
on the log-likelihood of the cloglog link at the same parameter estimates by more
than 1e-5), or when the joint information is not positive definite. In those cases
the standard errors are conditional on phi, with a warning from vcov and
confint, and a note in the printed summary.
A list including the optimisation results, CI, and final model fit.
Bert van der Veen
van der Veen and Hui (2025). In prep.
# Define logit link via gcloglog library(gcloglog) gcloglog1 <- make.gcloglog(1) # Profile the gcloglog link x <- rnorm(100) b1 = 2.3 b0 = 0.1 eta = b0+b1*x y = rbinom(length(x), 1, plogis(eta)) data <- data.frame(y = y,x = x) model <- glm(y~x, family = binomial(link = gcloglog1), data = data) res <- profile.gcloglog(model) final.model <- res$final.model summary(final.model) # standard errors account for the estimate of phi confint(final.model) summary(final.model) # conditional on the estimate of phi vcov(final.model, correct = FALSE) # conditional on the estimate of phi# Define logit link via gcloglog library(gcloglog) gcloglog1 <- make.gcloglog(1) # Profile the gcloglog link x <- rnorm(100) b1 = 2.3 b0 = 0.1 eta = b0+b1*x y = rbinom(length(x), 1, plogis(eta)) data <- data.frame(y = y,x = x) model <- glm(y~x, family = binomial(link = gcloglog1), data = data) res <- profile.gcloglog(model) final.model <- res$final.model summary(final.model) # standard errors account for the estimate of phi confint(final.model) summary(final.model) # conditional on the estimate of phi vcov(final.model, correct = FALSE) # conditional on the estimate of phi
This function takes a model object with a family argument, and estimates a parameter phi that controls the shape of the link function.
## S3 method for class 'glm' profile.phi( model, y, optimizer = nlminb, optControl = list(iter.max = 500, eval.max = 500), optArgs = list(lower = log(1.400882e-08)), warmstart = TRUE, ... ) ## S3 method for class 'merMod' profile.phi( model, y, optimizer = bobyqa, optControl = list(maxit = 500), optArgs = NULL, warmstart = TRUE, ... ) ## Default S3 method: profile.phi( model, y, optimizer = bobyqa, optControl = list(maxit = 500), optArgs = NULL, ... ) profile.phi(model, ...)## S3 method for class 'glm' profile.phi( model, y, optimizer = nlminb, optControl = list(iter.max = 500, eval.max = 500), optArgs = list(lower = log(1.400882e-08)), warmstart = TRUE, ... ) ## S3 method for class 'merMod' profile.phi( model, y, optimizer = bobyqa, optControl = list(maxit = 500), optArgs = NULL, warmstart = TRUE, ... ) ## Default S3 method: profile.phi( model, y, optimizer = bobyqa, optControl = list(maxit = 500), optArgs = NULL, ... ) profile.phi(model, ...)
model |
a model object which accepts a family argument (should correspond to "binomial") with a link function. The model should have corresponding |
y |
response variable. |
optimizer |
numerical optimisation routine used to estimate phi. Must accept the starting value, objective function, gradient, and control arugments (in that order). Defaults to |
optControl |
control arguments passed to optimizer. |
optArgs |
other arguments passed on to the optimizer as a list. |
warmstart |
logical, defaults to |
... |
other arguments passed to |
The optimisation results of the profiling, with log(phi) as the estimated parameter.
Bert van der Veen
van der Veen and Hui (2025). In prep.
# Define logit link via gcloglog library(gcloglog) gcloglog1 <- make.gcloglog(1) # Fit logistic regression with gcloglog x <- rnorm(100) b1 = 2.3 b0 = 0.1 eta = b0+b1*x y = rbinom(length(x), 1, plogis(eta)) data <- data.frame(y = y,x = x) model <- glm(y~x, family = binomial(link = gcloglog1), data = data) # Find optimal link shape by profiling phi res <- profile.phi(model, y = model.response(model.frame(model))) exp(res$optr$par) # extract phi# Define logit link via gcloglog library(gcloglog) gcloglog1 <- make.gcloglog(1) # Fit logistic regression with gcloglog x <- rnorm(100) b1 = 2.3 b0 = 0.1 eta = b0+b1*x y = rbinom(length(x), 1, plogis(eta)) data <- data.frame(y = y,x = x) model <- glm(y~x, family = binomial(link = gcloglog1), data = data) # Find optimal link shape by profiling phi res <- profile.phi(model, y = model.response(model.frame(model))) exp(res$optr$par) # extract phi