Learn R Programming

popEpi (version 0.3.1)

relpois_ag: Excess hazard Poisson model

Description

Estimate a Poisson Piecewise Constant Excess Hazards Model

Usage

relpois_ag(formula, data, d.exp, offset = NULL, breaks = NULL, subset = NULL, piecewise = TRUE, ...)

Arguments

formula
a formula with the counts of events as the response. Passed on to glm. May contain usage of the offset() function instead of supplying the offset for the Poisson model via the argument offset.
data
an aggre object (an aggregated data set; see as.aggre and aggre)
d.exp
the counts of expected cases. Mandatory. E.g. d.exp = EXC_CASES, where EXC_CASES is a column in data.
offset
the offset for the Poisson model, supplied as e.g. offset = log(PTIME), where PTIME is a subject-time variable in data. Not mandatory, but almost always should be supplied.
breaks
optional; a numeric vector of [a,b) breaks to specify survival intervals over the follow-up time; if NULL, the existing breaks along the mandatory time scale mentioned in formula are used
subset
a logical vector or condition; e.g. subset = sex == 1; limits the data before estimation
piecewise
logical; if TRUE, and if any time scale from data is used (mentioned) in the formula, the time scale is transformed into a factor variable indicating intervals on the time scale. Otherwise the time scale left as it is, usually a numeric variable. E.g. if formula = counts ~ TS1*VAR1, TS1 is transformed into a factor before fitting model.
...
any other argument passed on to glm such as control or weights

Value

A relpois object created using a custom Poisson family construct.

See Also

lexpand, poisson, glm

Examples

Run this code
## use the simulated rectal cancer cohort
sr <- copy(sire)
sr$agegr <- cut(sr$dg_age, c(0,45,60,Inf), right=FALSE)

## usable straight away after splitting
fb <- c(0,3/12,6/12,1,2,3,4,5)
x <- lexpand(sr, birth = bi_date, entry = dg_date,
             exit = ex_date, status=status %in% 1:2,
             breaks = list(fot=fb), 
             pophaz=popmort, pp = FALSE,
             aggre = list(agegr, fot))
             
rpm <- relpois_ag(formula = from0to1 ~ fot + agegr,  data = x,
                  d.exp = d.exp, offset = log(pyrs))
summary(rpm)
 
## the usual functions for handling glm models work
rpm2 <- update(rpm, . ~ fot*agegr)
anova(rpm, rpm2, test="LRT")
AIC(rpm, rpm2)

Run the code above in your browser using DataLab