logitexp | R Documentation |
This is a link function proposed by Schaffer (2004) for discrete time survival modeling. Let T
be the number of discrete time units until an event (e.g., days), and assume that for a given unit the hazard function P(T > t | T \ge t) = \pi
for all t
(i.e., the probability of surviving time unit t
is \pi
). Then the probability of survived e
time units is \pi^e
. Assume a logistic regression model for survival on a given day so that \pi = 1/(1 + exp(-\eta))
. Let Y
be the number of observational units out of m
that survive an exposure of e
time units. Then the inverse link function is E(Y/m) = 1/(1 + exp(-\eta))^e
, and the link function is [\log(E(Y/m)^{1/e}/(1 - E(Y/m)^{1/e})] = \eta
.
logitexp(exposure = 1)
The argument exposure
specifies the number of time units. To be consistent with the motivation given above this should be a positive integer.
The code for this link function is also given as an example in the documentation for family
.
Schaffer, T. L. (2004). A unified approach to analyzing nest success. The Auk, 121(2), 526-540.
logitcomp
library(dplyr)
set.seed(123)
d <- data.frame(x = seq(0, 3, length = 100)) %>%
mutate(days = sample(1:10, n(), replace = TRUE)) %>%
mutate(y = rbinom(n(), 1, plogis(x)^days))
m <- glm(y ~ x, data = d,
family = binomial(link = logitexp(exposure = d$days)))
# The logitcomp link function can be used to model the probability
# of not surviving. The following produces the same estimates except
# for a reversal of sign.
m <- glm(1 - y ~ x, data = d,
family = binomial(link = logitcomp(m = d$days)))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.