Learn R Programming

VGAM (version 0.8-2)

cenpoisson: Censored Poisson Family Function

Description

Family function for a censored Poisson response.

Usage

cenpoisson(link = "loge", earg = list(), imu = NULL)

Arguments

link
Link function applied to the mean. See Links for more choices.
earg
Extra argument optionally used by the link function. See Links for more information.
imu
Optional initial value. See CommonVGAMffArguments for more information.

Value

  • An object of class "vglmff" (see vglmff-class). The object is used by modelling functions such as vglm and vgam.

Warning

As the response is discrete, care is required with Surv, especially with "interval" censored data because of the (start, end] format. See the examples below. The examples have y < L as left censored and y >= U (formatted as U+) as right censored observations, therefore L <= y="" <="" u<="" code=""> is for uncensored and/or interval censored observations. Consequently the input must be tweaked to conform to the (start, end] format.

Details

Often a table of Poisson counts has an entry J+ meaning $\ge J$. This family function is similar to poissonff but handles such censored data. The input requires SurvS4. Only a univariate response is allowed. The Newton-Raphson algorithm is used.

References

See survival for background.

See Also

SurvS4, poissonff, Links.

Examples

Run this code
# Example 1: right censored data
set.seed(123); U = 20
y = rpois(n <- 100, exp(3))
cy = pmin(U, y)
rcensored = (y >= U)
table(cy)
table(rcensored)
status = ifelse(rcensored, 0, 1)
table(ii <- print(SurvS4(cy, status)))  # Check; U+ means >= U
fit = vglm(SurvS4(cy, status) ~ 1, cenpoisson, trace=TRUE)
coef(fit, mat=TRUE)
table(print(fit@y))  # Another check; U+ means >= U


# Example 2: left censored data
L = 15
cy = pmax(L, y)
lcensored = (y <  L)   # Note y < L, not cy == L or y <= L
table(cy)
table(lcensored)
status = ifelse(lcensored, 0, 1)
table(ii <- print(SurvS4(cy, status, type="left")))  # Check
fit = vglm(SurvS4(cy, status, type="left") ~ 1, cenpoisson, trace=TRUE)
coef(fit, mat=TRUE)


# Example 3: interval censored data
Lvec = rep(L, len=n); Uvec = rep(U, len=n)
icensored = Lvec <= y & y < Uvec  # Neither lcensored or rcensored
table(icensored)
status = rep(3, n)                    # 3 means interval censored
status = ifelse(rcensored, 0, status) # 0 means right censored
status = ifelse(lcensored, 2, status) # 2 means left  censored
# Have to adjust Lvec and Uvec because of the (start, end] format:
Lvec[icensored] = Lvec[icensored] - 1
Uvec[icensored] = Uvec[icensored] - 1
Lvec[lcensored] = Lvec[lcensored]  # Remains unchanged
Lvec[rcensored] = Uvec[rcensored]  # Remains unchanged
table(ii <- print(SurvS4(Lvec, Uvec, status, type="interval")))  # Check

fit = vglm(SurvS4(Lvec, Uvec, status, type="interval") ~ 1,
           cenpoisson, trace=TRUE)
coef(fit, mat=TRUE)
table(print(fit@y))  # Another check


# Example 4: Add in some uncensored observations
index = (1:n)[icensored]
index = head(index, 4)
status[index] = 1 # actual or uncensored value
Lvec[index] = y[index]
table(ii <- print(SurvS4(Lvec, Uvec, status, type="interval")))  # Check

fit = vglm(SurvS4(Lvec, Uvec, status, type="interval") ~ 1,
           cenpoisson, trace=TRUE, crit="c")
coef(fit, mat=TRUE)
table(print(fit@y))  # Another check

Run the code above in your browser using DataLab