| Title: | General Class of Models for Recurrent Event Data |
|---|---|
| Description: | Parameter estimation for the general class of semiparametric models for recurrent event data proposed by Peña and Hollander (2004, <ISBN:978-1-4020-7737-6>). The model incorporates an effective age function encoding the impact of interventions after each event occurrence, the effect of accumulating event occurrences, a link function for possibly time-dependent covariates, and optional gamma frailties to induce dependence among inter-event times. It also fits the extension for cancer relapses of González et al. (2005) <doi:10.1002/sim.2410>. Estimation is performed by profile likelihood, with an expectation-maximization algorithm for the frailty model, and the package provides descriptive, diagnostic and predictive tools for the fitted models. |
| Authors: | Dolors Pelegri-Siso [aut, cre] (ORCID: <https://orcid.org/0000-0002-5993-3003>), Juan R. González [aut], Elizabeth H. Slate [aut], Edsel A. Peña [aut] |
| Maintainer: | Dolors Pelegri-Siso <[email protected]> |
| License: | GPL (>= 2) |
| Version: | 2.0.0 |
| Built: | 2026-10-13 13:08:21 UTC |
| Source: | https://github.com/isglobal-brge/gcmrec |
Adds a new row with a censored time equal to 0 for those subjects whose
end of follow-up coincides with the last occurrence (i.e. whose last
record is an event). Survr() requires every subject to have exactly
one censored record.
addCenTime(datin, id = 1, time = 2, event = 3)addCenTime(datin, id = 1, time = 2, event = 3)
datin |
Data frame containing id, time and event variables; other covariates are allowed and are copied to the added row. |
id, time, event
|
Column positions of the id, time and event
variables in |
A data frame with an added row (censored time equal to 0) for those subjects whose end of follow-up coincides with the last occurrence.
# The second subject has no censored record: its follow-up ends at the # last event dat <- data.frame( id = c(1, 1, 2, 2), time = c(5, 3, 7, 4), event = c(1, 0, 1, 1) ) addCenTime(dat)# The second subject has no censored record: its follow-up ends at the # last event dat <- data.frame( id = c(1, 1, 2, 2), time = c(5, 3, 7, 4), event = c(1, 0, 1, 1) ) addCenTime(dat)
Compares nested gcmrec models with a likelihood ratio test. The
typical use is to ask whether there is real event accumulation (is
different from 1?) or whether a covariate is worth
keeping.
## S3 method for class 'gcmrec' anova(object, ..., test = "Chisq") ## S3 method for class 'anova.gcmrec' print(x, digits = 4, ...)## S3 method for class 'gcmrec' anova(object, ..., test = "Chisq") ## S3 method for class 'anova.gcmrec' print(x, digits = 4, ...)
object |
An object of class |
... |
Ignored; kept for compatibility with the generic. |
test |
Ignored; kept for compatibility with the generic. |
x |
An object of class |
digits |
Number of significant digits. |
Given a single model, the test compares it against the same model with
(that is, : occurrences carry no
effect), refitting it internally. Given two or more models, they are
compared in sequence, each against the previous one, in increasing
order of complexity.
A data frame of class anova.gcmrec with the log-likelihood,
degrees of freedom, chi-square statistic and p-value of each
comparison.
For print, invisibly x.
A likelihood ratio test is only meaningful for nested models fitted to the same data, so the following are checked and refused:
all the models must have the same number of subjects and records.
models must share the effective age
scale, that is, the same s, typeEffage, effageData and
cancer. A perfect repair fit and a minimal repair one are not
nested and cannot be tested against each other.
the covariates of each model must be a subset of those of the next one.
the log-likelihood of a frailty fit is conditional
on the estimated frailties and is not on the same scale as that of
a fit without them, so the two cannot be compared. Judge the
frailties from and its jackknife standard error instead.
Comparing two frailty models with each other is allowed but only approximate, since each is conditional on its own estimated frailties; a warning is issued.
data(readmission) mod <- gcmrec(Survr(id, time, event) ~ as.factor(dukes), data = readmission, s = 3000) # Is there event accumulation? (alpha = 1 against alpha free) anova(mod) # Is sex worth adding to the model? mod2 <- gcmrec(Survr(id, time, event) ~ as.factor(dukes) + sex, data = readmission, s = 3000) anova(mod, mod2)data(readmission) mod <- gcmrec(Survr(id, time, event) ~ as.factor(dukes), data = readmission, s = 3000) # Is there event accumulation? (alpha = 1 against alpha free) anova(mod) # Is sex worth adding to the model? mod2 <- gcmrec(Survr(id, time, event) ~ as.factor(dukes) + sex, data = readmission, s = 3000) anova(mod, mod2)
Generic that converts the supported input formats of gcmrec() and
graph.caltimes() into the canonical data.frame layout with id,
time and event columns. New input formats can be supported by
adding methods to this generic.
as_gcmrec_data(data, ...) ## S3 method for class 'data.frame' as_gcmrec_data(data, ...) ## S3 method for class 'list' as_gcmrec_data(data, ...) ## Default S3 method: as_gcmrec_data(data, ...)as_gcmrec_data(data, ...) ## S3 method for class 'data.frame' as_gcmrec_data(data, ...) ## S3 method for class 'list' as_gcmrec_data(data, ...) ## Default S3 method: as_gcmrec_data(data, ...)
data |
The data in one of the supported formats. |
... |
Additional arguments passed to methods. |
Currently supported inputs:
data.frame (including tibbles and data.tables): returned as is.
Legacy list format with elements n and subject (see
List.to.Dataframe()): converted to a data frame. Any other list is
returned unchanged so it can be used as a variable environment for
the model formula, as in base R modelling functions.
A data.frame (or the original object when no conversion
applies).
data(hydraulic) head(as_gcmrec_data(hydraulic))data(hydraulic) head(as_gcmrec_data(hydraulic))
Extract coefficients from a gcmrec model
## S3 method for class 'gcmrec' coef(object, ...)## S3 method for class 'gcmrec' coef(object, ...)
object |
An object of class |
... |
Ignored; kept for compatibility with the generic. |
Named vector of estimated parameters. With
rhoFunc = "alpha to k" the first element is .
Fits the general semiparametric model for recurrent events proposed by Peña and Hollander (2004). This class of models incorporates an effective age function which encodes the changes that occur after each event occurrence (such as the impact of an intervention), allows for the modelling of the impact of accumulating event occurrences on the unit, admits a link function in which the effect of possibly time-dependent covariates is incorporated, and allows the incorporation of unobservable frailty components which induce dependence among the inter-event times for each unit.
gcmrec( formula, data, effageData = NULL, s, Frailty = FALSE, alphaSeed, betaSeed, xiSeed, tol = 10^(-6), maxit = 100, rhoFunc = "alpha to k", typeEffage = "perfect", maxXi = "Newton-Raphson", se = "Information matrix", cancer = NULL, keep.data = TRUE )gcmrec( formula, data, effageData = NULL, s, Frailty = FALSE, alphaSeed, betaSeed, xiSeed, tol = 10^(-6), maxit = 100, rhoFunc = "alpha to k", typeEffage = "perfect", maxXi = "Newton-Raphson", se = "Information matrix", cancer = NULL, keep.data = TRUE )
formula |
A formula object with a |
data |
A data frame containing the variables named in the formula,
including |
effageData |
Optional list with effective age information per
subject (elements |
s |
A selected calendar time. |
Frailty |
Logical. If |
alphaSeed, betaSeed, xiSeed
|
Initial values for |
tol |
Tolerance of the maximization procedures. |
maxit |
Maximum number of iterations of the maximization procedures. |
rhoFunc |
Function |
typeEffage |
Effective age model: |
maxXi |
Maximization method for the marginal likelihood of
|
se |
Standard error estimation: |
cancer |
Optional character vector with the response achieved after
each treatment for the cancer model of González et al. (2005), coded
|
keep.data |
Keep the prepared data in the fitted object? It lets
|
Estimation with frailties is implemented using an
expectation-maximization (EM) algorithm. The marginal likelihood for
is maximized either by Newton-Raphson or by Brent's method,
re-parameterizing to avoid negative estimates.
Iteration terminates when successive values of
differ by no more than tol. Estimation under the frailty model can be
slow for large data sets.
An object of class gcmrec with components including coef
(estimated and ), var (covariance matrix),
loglik, Xi and frailties (frailty model only), Lambda and
Survival (baseline estimates at the distinct effective ages
diseff). Methods are provided for print(), summary(), plot(),
lines(), coef(), vcov() and logLik().
Peña, E. and Hollander, M. (2004). Models for recurrent events in reliability and survival analysis. In Mathematical Reliability: An Expository Perspective (Chapter 6, pp. 105–123). Kluwer Academic Publishers.
González, J.R., Peña, E. and Slate, E. (2005). Modelling intervention effects after cancer relapses. Statistics in Medicine, 24(24), 3959–3975.
Gail, M., Santner, T. and Brown, C. (1980). An analysis of comparative carcinogenesis experiments based on multiple times to tumor. Biometrics, 36, 255–266.
Survr(), addCenTime(), graph.caltimes()
data(readmission) # Perfect repair model with rho(k; alpha) = alpha^k mod <- gcmrec(Survr(id, time, event) ~ as.factor(dukes), data = readmission, s = 3000) mod # Minimal repair model mod.min <- gcmrec(Survr(id, time, event) ~ as.factor(dukes), data = readmission, s = 3000, typeEffage = "min") # Legacy list format converted internally data(hydraulic) gcmrec(Survr(id, time, event) ~ covar.1 + covar.2, data = hydraulic, s = 4753) # Model with frailties (EM algorithm) mod.fra <- gcmrec(Survr(id, time, event) ~ as.factor(dukes), data = readmission, s = 3000, Frailty = TRUE) # Cancer model with effective age given by treatment response data(lymphoma) mod.can <- gcmrec(Survr(id, time, event) ~ as.factor(distrib), data = lymphoma, s = 1000, cancer = lymphoma$effage)data(readmission) # Perfect repair model with rho(k; alpha) = alpha^k mod <- gcmrec(Survr(id, time, event) ~ as.factor(dukes), data = readmission, s = 3000) mod # Minimal repair model mod.min <- gcmrec(Survr(id, time, event) ~ as.factor(dukes), data = readmission, s = 3000, typeEffage = "min") # Legacy list format converted internally data(hydraulic) gcmrec(Survr(id, time, event) ~ covar.1 + covar.2, data = hydraulic, s = 4753) # Model with frailties (EM algorithm) mod.fra <- gcmrec(Survr(id, time, event) ~ as.factor(dukes), data = readmission, s = 3000, Frailty = TRUE) # Cancer model with effective age given by treatment response data(lymphoma) mod.can <- gcmrec(Survr(id, time, event) ~ as.factor(distrib), data = lymphoma, s = 1000, cancer = lymphoma$effage)
Gets or sets the maximum number of threads used by the parallel parts of the package, currently the jackknife standard errors, which refit the model once per subject.
gcmrecThreads(n)gcmrecThreads(n)
n |
Maximum number of threads, or |
By default the package lets OpenMP decide, which means it honours the
OMP_NUM_THREADS environment variable. Set this option to cap the
number of threads regardless of that variable, for instance when
running inside a shared machine or a job scheduler.
If the package was built without OpenMP support (which is the case with the default compiler on macOS), the computation runs sequentially and this setting has no effect.
The current setting, invisibly when it is being changed.
NULL means "let OpenMP decide".
gcmrecThreads() # current setting old <- gcmrecThreads(2) gcmrecThreads(old) # restoregcmrecThreads() # current setting old <- gcmrecThreads(2) gcmrecThreads(old) # restore
Recurrence times simulated under the minimal repair model with
probability of perfect repair equal to 0.6, including the generated
effective age information. Useful as an example of the effageData
argument of gcmrec().
GeneratedDataGeneratedData
A list in the legacy gcmrec format (elements n, paramlist
and subject), where each subject includes the effective age
components intercepts, slopes, lastperrep, perrepind,
effagebegin and effage.
data(GeneratedData) temp <- List.to.Dataframe(GeneratedData) head(temp)data(GeneratedData) temp <- List.to.Dataframe(GeneratedData) head(temp)
Draws one row per subject with a segment covering its follow-up, a point at each recurrence and a marker at the end of follow-up. It is the first look you should take at recurrent event data: it shows at a glance how many subjects recur, how often, and whether the events cluster early or late.
graph.caltimes( data, var = NULL, effageData = NULL, sortevents = c("followup", "events", "none"), width = 2, lines = TRUE, max.subjects = 300, ... )graph.caltimes( data, var = NULL, effageData = NULL, sortevents = c("followup", "events", "none"), width = 2, lines = TRUE, max.subjects = 300, ... )
data |
A data frame with |
var |
Optional variable used to colour the subjects, of the same
length as |
effageData |
Optional effective age information; recurrences with
|
sortevents |
How to order the subjects along the vertical axis:
|
width |
Size of the plotting symbols. |
lines |
Draw the follow-up segment of each subject? |
max.subjects |
Maximum number of subjects to draw. With more, a
random sample of this size is taken (with a message), since the chart
becomes unreadable beyond a few hundred rows. |
... |
Ignored; kept for compatibility with earlier versions. |
A ggplot object.
mcf() for the cumulative view of the same data.
data(readmission) graph.caltimes(readmission[readmission$id %in% 1:40, ]) # Coloured by a covariate, ordered by number of events graph.caltimes(readmission[readmission$id %in% 1:40, ], var = readmission$sex[readmission$id %in% 1:40], sortevents = "events")data(readmission) graph.caltimes(readmission[readmission$id %in% 1:40, ]) # Coloured by a covariate, ordered by number of events graph.caltimes(readmission[readmission$id %in% 1:40, ], var = readmission$sex[readmission$id %in% 1:40], sortevents = "events")
Hydraulic load-haul-dump (LHD) subsystems used in moving ore and rock in underground mines in Sweden. The data set provides the calendar times (in hours), excluding repair or down times, of the successive failures of 6 such systems during the two-year development phase.
hydraulichydraulic
A list in the legacy gcmrec format, with elements n (number of
systems) and subject (a list with k, tau, caltimes,
gaptimes, effective age components and covariates for each system).
Use List.to.Dataframe() or pass it directly to gcmrec(), which
converts it via as_gcmrec_data().
Kumar, D. and Klefsjö, B. (1992). Reliability analysis of hydraulic systems of LHD machines using the power law process model. Reliability Engineering and System Safety, 35, 217–224.
data(hydraulic) head(List.to.Dataframe(hydraulic))data(hydraulic) head(List.to.Dataframe(hydraulic))
Test for a survival recurrent object
is.Survr(x)is.Survr(x)
x |
An R object. |
TRUE if x inherits from class Survr.
is.Survr(Survr(id = c(1, 1), time = c(5, 3), event = c(1, 0)))is.Survr(Survr(id = c(1, 1), time = c(5, 3), event = c(1, 0)))
[Deprecated]
Adds the baseline curve of a fitted model to an open base graphics
plot. Since version 2.0 plot.gcmrec() returns a ggplot object, so
lines() can no longer add a curve to it. Use plotBaseline() with a
list of models instead, which draws all of them on the same axes with a
legend.
## S3 method for class 'gcmrec' lines(x, type.plot = "survival", ...)## S3 method for class 'gcmrec' lines(x, type.plot = "survival", ...)
x |
An object of class |
type.plot |
Curve to add: |
... |
Further graphical parameters passed to |
Invisibly, x.
plotBaseline(), the recommended replacement.
data(readmission) mod.per <- gcmrec(Survr(id, time, event) ~ as.factor(dukes), data = readmission, s = 3000, typeEffage = "perfect") mod.min <- gcmrec(Survr(id, time, event) ~ as.factor(dukes), data = readmission, s = 3000, typeEffage = "minimal") # Recommended: both curves in one call plotBaseline(list(perfect = mod.per, minimal = mod.min))data(readmission) mod.per <- gcmrec(Survr(id, time, event) ~ as.factor(dukes), data = readmission, s = 3000, typeEffage = "perfect") mod.min <- gcmrec(Survr(id, time, event) ~ as.factor(dukes), data = readmission, s = 3000, typeEffage = "minimal") # Recommended: both curves in one call plotBaseline(list(perfect = mod.per, minimal = mod.min))
Converts a data set in the legacy list format (elements n and
subject, where each subject holds k, tau, gaptimes and a
covariate matrix; see the hydraulic and GeneratedData data sets)
into a data frame with columns id, time, event and covar.*.
List.to.Dataframe(data)List.to.Dataframe(data)
data |
A list with elements |
A data frame with one row per recurrence plus the censoring time of each subject.
data(hydraulic) head(List.to.Dataframe(hydraulic))data(hydraulic) head(List.to.Dataframe(hydraulic))
Extract the log-likelihood from a gcmrec model
## S3 method for class 'gcmrec' logLik(object, ...)## S3 method for class 'gcmrec' logLik(object, ...)
object |
An object of class |
... |
Ignored; kept for compatibility with the generic. |
An object of class logLik. For frailty models it is the
partial log-likelihood conditional on the estimated frailties.
Cancer relapse times after first treatment in patients diagnosed with low grade lymphoma.
lymphomalymphoma
A data frame with 112 rows and 9 columns:
identifier of each subject, repeated for each recurrence
inter-occurrence or censoring time
censoring status: 1 for each relapse, 0 for the last (censored) record of each subject
which relapse
delay between first symptom and date of first treatment
age at diagnosis
gender: 1: Males, 2: Females
lesions involved at diagnosis: 0: Single, 1: Localized, 2: More than one nodal site, 3: Generalized
response achieved after the treatment at each relapse:
"CR" complete remission, "PR" partial remission, "SD" stable
disease or null response. Used as the cancer argument of
gcmrec()
González, J.R., Peña, E. and Slate, E. (2005). Modelling intervention effects after cancer relapses. Statistics in Medicine, 24(24), 3959–3975.
Servitje, O., Gallardo, F., Estrach, T. et al. (2002). Primary cutaneous marginal zone B-cell lymphoma. British Journal of Dermatology, 147, 1147–1158.
data(lymphoma) head(lymphoma)data(lymphoma) head(lymphoma)
Estimates the mean cumulative function (MCF), that is, the expected number of events accumulated by a subject up to each time. It is the Nelson-Aalen estimator adapted to recurrent events, and it answers the question "how many events does an average subject accumulate?" without assuming any model.
mcf(data, group = NULL, level = 0.95) ## S3 method for class 'mcf' print(x, ...) ## S3 method for class 'mcf' plot(x, conf.int = TRUE, ...)mcf(data, group = NULL, level = 0.95) ## S3 method for class 'mcf' print(x, ...) ## S3 method for class 'mcf' plot(x, conf.int = TRUE, ...)
data |
A data frame with |
group |
Optional grouping variable of length |
level |
Confidence level of the pointwise interval. |
x |
An object of class |
... |
Ignored; kept for compatibility with the generic. |
conf.int |
Draw the confidence band? |
The estimator adds, at each event time , the number of events
observed at divided by the number of subjects still under
follow-up, and the pointwise variance is accumulated in the same way.
Use it before modelling: comparing the MCF of two groups shows whether
their event burden really differs, and its shape suggests whether the
risk grows or falls with time.
An object of class mcf: a data frame with columns time,
estimate, lower, upper, n.risk, n.event and, if group was
given, group. It has plot() and print() methods.
For print, invisibly x.
graph.caltimes() for the individual view of the same data.
data(readmission) # Overall event burden m <- mcf(readmission) m plot(m) # Does it differ by tumour stage? m.dukes <- mcf(readmission, group = readmission$dukes) plot(m.dukes)data(readmission) # Overall event burden m <- mcf(readmission) m plot(m) # Does it differ by tumour stage? m.dukes <- mcf(readmission, group = readmission$dukes) plot(m.dukes)
Plots the estimated baseline survivor function or the baseline
cumulative hazard of a fitted gcmrec() model as a step function over
the effective age, with a pointwise confidence band.
## S3 method for class 'gcmrec' plot(x, type.plot = "survival", conf.int = TRUE, level = 0.95, ...)## S3 method for class 'gcmrec' plot(x, type.plot = "survival", conf.int = TRUE, level = 0.95, ...)
x |
An object of class |
type.plot |
Curve to plot: |
conf.int |
Draw the confidence band? |
level |
Confidence level of the band. |
... |
Ignored; kept for compatibility with the generic. |
The band is built from the Aalen variance of the cumulative hazard,
transformed to the log scale for the hazard and to the log-log scale
for the survivor function, so that the limits stay positive and inside
respectively (the default transformation of
survival::survfit()).
A ggplot object, which can be further styled with the usual
ggplot2 syntax.
plotBaseline() to compare several models, plotPredict()
for covariate-specific curves.
data(readmission) mod <- gcmrec(Survr(id, time, event) ~ as.factor(dukes), data = readmission, s = 3000) plot(mod) plot(mod, type.plot = "hazard", level = 0.99) # It is a ggplot, so it can be restyled plot(mod) + ggplot2::labs(title = "Colorectal cancer readmissions")data(readmission) mod <- gcmrec(Survr(id, time, event) ~ as.factor(dukes), data = readmission, s = 3000) plot(mod) plot(mod, type.plot = "hazard", level = 0.99) # It is a ggplot, so it can be restyled plot(mod) + ggplot2::labs(title = "Colorectal cancer readmissions")
Draws the baseline survivor or cumulative hazard functions of two or more fitted models on the same axes, which is the natural way to see what an assumption (for instance perfect versus minimal repair) changes.
plotBaseline(models, type.plot = "survival", conf.int = FALSE, level = 0.95)plotBaseline(models, type.plot = "survival", conf.int = FALSE, level = 0.95)
models |
A named list of |
type.plot |
Curve to plot: |
conf.int |
Draw confidence bands? Off by default, since overlapping bands are hard to read. |
level |
Confidence level of the bands. |
A ggplot object.
data(readmission) mod.per <- gcmrec(Survr(id, time, event) ~ as.factor(dukes), data = readmission, s = 3000, typeEffage = "perfect") mod.min <- gcmrec(Survr(id, time, event) ~ as.factor(dukes), data = readmission, s = 3000, typeEffage = "minimal") plotBaseline(list(perfect = mod.per, minimal = mod.min))data(readmission) mod.per <- gcmrec(Survr(id, time, event) ~ as.factor(dukes), data = readmission, s = 3000, typeEffage = "perfect") mod.min <- gcmrec(Survr(id, time, event) ~ as.factor(dukes), data = readmission, s = 3000, typeEffage = "minimal") plotBaseline(list(perfect = mod.per, minimal = mod.min))
Draws the exponentiated covariate coefficients of a fitted gcmrec()
model with their confidence intervals, on a logarithmic axis with a
reference line at 1. This is the figure that usually accompanies the
table returned by summary.gcmrec().
plotForest( x, level = 0.95, labels = NULL, sort = FALSE, title = "Hazard ratios", subtitle = NULL )plotForest( x, level = 0.95, labels = NULL, sort = FALSE, title = "Hazard ratios", subtitle = NULL )
x |
An object of class |
level |
Confidence level of the intervals. |
labels |
Optional named character vector to relabel the
covariates: |
sort |
Order the covariates by hazard ratio instead of keeping the order of the model? |
title, subtitle
|
Plot title and subtitle; |
A ggplot object.
data(readmission) mod <- gcmrec(Survr(id, time, event) ~ as.factor(dukes) + sex, data = readmission, s = 3000) plotForest(mod) # Readable labels for a report plotForest(mod, labels = c("as.factor(dukes)2" = "Dukes C vs A-B", "as.factor(dukes)3" = "Dukes D vs A-B", "sex" = "Female vs male"))data(readmission) mod <- gcmrec(Survr(id, time, event) ~ as.factor(dukes) + sex, data = readmission, s = 3000) plotForest(mod) # Readable labels for a report plotForest(mod, labels = c("as.factor(dukes)2" = "Dukes C vs A-B", "as.factor(dukes)3" = "Dukes D vs A-B", "sex" = "Female vs male"))
Draws the survivor or cumulative hazard curve of each covariate profile, which is the way to show what the model implies for concrete subjects (for instance, the three Dukes stages side by side).
plotPredict(object, newdata, type = c("survival", "hazard"), labels = NULL)plotPredict(object, newdata, type = c("survival", "hazard"), labels = NULL)
object |
An object of class |
newdata |
Data frame of covariate profiles, one row per profile. Its row names, if any, are used as labels in the legend. |
type |
|
labels |
Optional character vector of labels for the profiles,
one per row of |
A ggplot object.
data(readmission) mod <- gcmrec(Survr(id, time, event) ~ as.factor(dukes) + sex, data = readmission, s = 3000) profiles <- data.frame(dukes = c(1, 2, 3), sex = 1) plotPredict(mod, profiles, labels = c("Dukes A-B", "Dukes C", "Dukes D"))data(readmission) mod <- gcmrec(Survr(id, time, event) ~ as.factor(dukes) + sex, data = readmission, s = 3000) profiles <- data.frame(dukes = c(1, 2, 3), sex = 1) plotPredict(mod, profiles, labels = c("Dukes A-B", "Dukes C", "Dukes D"))
Computes the linear predictor, the relative risk or the whole survivor and cumulative hazard curves for given covariate profiles.
## S3 method for class 'gcmrec' predict( object, newdata = NULL, type = c("risk", "lp", "survival", "hazard"), ... )## S3 method for class 'gcmrec' predict( object, newdata = NULL, type = c("risk", "lp", "survival", "hazard"), ... )
object |
An object of class |
newdata |
Data frame of covariate profiles, one row per profile,
with the covariates used in the model. If |
type |
Type of prediction: |
... |
Ignored; kept for compatibility with the generic. |
The model is multiplicative, so a covariate profile scales the
baseline by : the survivor function of the
profile is and its cumulative hazard is
. Note that the curves are functions of the
effective age, not of calendar time, and that they describe the gap
to the next event.
For "risk" and "lp", a numeric vector with one value per
profile. For "survival" and "hazard", a data frame with columns
profile, time and estimate, ready to be plotted (see
plotPredict()).
data(readmission) mod <- gcmrec(Survr(id, time, event) ~ as.factor(dukes) + sex, data = readmission, s = 3000) # Relative risk of two patient profiles profiles <- data.frame(dukes = c(1, 3), sex = c(1, 1)) predict(mod, profiles, type = "risk") # Whole survivor curve of each profile head(predict(mod, profiles, type = "survival"))data(readmission) mod <- gcmrec(Survr(id, time, event) ~ as.factor(dukes) + sex, data = readmission, s = 3000) # Relative risk of two patient profiles profiles <- data.frame(dukes = c(1, 3), sex = c(1, 1)) predict(mod, profiles, type = "risk") # Whole survivor curve of each profile head(predict(mod, profiles, type = "survival"))
Prints the coefficient table (with standard errors, z statistics and
p-values), the parameter of the function, the
frailty parameter when present, and fit summaries.
## S3 method for class 'gcmrec' print(x, digits = max(options()$digits - 4, 3), ...)## S3 method for class 'gcmrec' print(x, digits = max(options()$digits - 4, 3), ...)
x |
An object of class |
digits |
Number of significant digits to print. |
... |
Ignored; kept for compatibility with the generic. |
Invisibly, x.
Print a gcmrec summary
## S3 method for class 'summary.gcmrec' print(x, digits = 2, lab = "hr", ...)## S3 method for class 'summary.gcmrec' print(x, digits = 2, lab = "hr", ...)
x |
An object of class |
digits |
Number of decimal digits in the table. |
lab |
Label of the hazard ratio column. |
... |
Ignored; kept for compatibility with the generic. |
Invisibly, x.
Rehospitalization times after surgery in patients diagnosed with colorectal cancer.
readmissionreadmission
A data frame with 861 rows and 10 columns:
identifier of each subject, repeated for each recurrence
which readmission
start of interval (0 or previous recurrence time)
recurrence or censoring time
inter-occurrence or censoring time
censoring status: 1 for each readmission, 0 for the last (censored) record of each subject
did the patient receive chemotherapy? 1: No; 2: Yes
gender: 1: Males, 2: Females
Dukes' tumoral stage: 1: A-B; 2: C; 3: D
Charlson comorbidity index (time-dependent covariate): 0: index 0; 1: index 1-2; 3: index >= 3
González, J.R., Fernández, E., Moreno, V. et al. (2005). Gender differences in hospital readmission among colorectal cancer patients. Journal of Epidemiology and Community Health, 59(6), 506–511.
data(readmission) head(readmission)data(readmission) head(readmission)
Computes hazard ratios (exponentiated covariate coefficients) with
confidence intervals for a fitted gcmrec() model. Unlike older
versions of the package, the summary is returned as an object (of class
summary.gcmrec) with its own print method, following the standard S3
idiom.
## S3 method for class 'gcmrec' summary(object, level = 0.95, ...)## S3 method for class 'gcmrec' summary(object, level = 0.95, ...)
object |
An object of class |
level |
Confidence level for the intervals (default 0.95). |
... |
Ignored; kept for compatibility with the generic. |
An object of class summary.gcmrec, a list with components:
call |
the call that produced the fit |
conf.int |
matrix with the hazard ratio and its confidence limits for each covariate |
level |
the confidence level used |
loglik, n, nk
|
fit summaries copied from the model object |
data(readmission) mod <- gcmrec(Survr(id, time, event) ~ as.factor(dukes), data = readmission, s = 3000) summary(mod)data(readmission) mod <- gcmrec(Survr(id, time, event) ~ as.factor(dukes), data = readmission, s = 3000) summary(mod)
Creates the response object used by gcmrec() for recurrent event data.
Every subject must have exactly one censored time (its last record, with
event = 0); use addCenTime() when the end of follow-up coincides
with the last occurrence.
Survr(id, time, event)Survr(id, time, event)
id |
Subject identifier, repeated for each recurrence. |
time |
Inter-occurrence or censoring time. |
event |
Event indicator: 1 for an event, 0 for the censoring time. |
An object of class Survr: a matrix with columns id, time
and event.
data(readmission) with(readmission, head(Survr(id, time, event)))data(readmission) with(readmission, head(Survr(id, time, event)))
A clean ggplot2 theme shared by all the plotting functions of the
package: light horizontal grid, no panel border, muted axis text and
room for the legend at the bottom. Exported so that the figures of a
report can be restyled consistently.
theme_gcmrec(base_size = 12)theme_gcmrec(base_size = 12)
base_size |
Base font size in points. |
A ggplot2 theme object, to be added to any plot.
data(readmission) mod <- gcmrec(Survr(id, time, event) ~ as.factor(dukes), data = readmission, s = 3000) plot(mod) + theme_gcmrec(base_size = 14)data(readmission) mod <- gcmrec(Survr(id, time, event) ~ as.factor(dukes), data = readmission, s = 3000) plot(mod) + theme_gcmrec(base_size = 14)
Extract the covariance matrix from a gcmrec model
## S3 method for class 'gcmrec' vcov(object, ...)## S3 method for class 'gcmrec' vcov(object, ...)
object |
An object of class |
... |
Ignored; kept for compatibility with the generic. |
Covariance matrix of the estimated parameters (inverse of the
information matrix, or the jackknife estimate if the model was fitted
with se = "Jacknife").