logitcomp: Link function for composite sampling designs with an...

View source: R/logitcomp.R

logitcompR Documentation

Link function for composite sampling designs with an underlying logistic model.

Description

This link function is applicable to composite sampling designs. The assumption is that there exists an underlying binomially-distributed response Z that follows a logistic regression model, but we only observe Y = I(Z > 0). Thus log[E(Y/m)/(1-E(Y/m))] = \eta, which implies that E(Y) = 1 - (1 - \pi)^m where \pi = E(Y/m) = 1/(1 + exp(\eta)) and so the link function for Y is \eta = log((1-\pi)^(-1/m) - 1).

Usage

logitcomp(m)

Details

The argument m specifies the number of trials for Y. This can be a scalar or a variable in the data frame, but if it is the latter then it is necessary explicitly specify the data frame (see example below).

See Also

logitexp

Examples

library(dplyr)

d <- data.frame(m = sample(c(25,50,100,400), 100, replace = TRUE)) %>% 
  mutate(x = seq(-2, 2, length = n())) %>% 
  mutate(y = rbinom(n(), m, plogis(qlogis(0.05) + x/5)))

# Model for underlying binomially-distributed response Z.
m <- glm(cbind(y, m - y) ~ x, family = binomial, data = d)
summary(m)$coefficients

d <- d %>% mutate(y = as.numeric(y > 0))

# Model for Y = I(Z > 0). 
m <- glm(y ~ x, family = binomial(link = logitcomp(d$m)), data = d)
summary(m)$coefficients

trobinj/trtools documentation built on Jan. 28, 2024, 3:20 a.m.