| Type: | Package |
| Title: | R Commander Plug-in for the 'survival' Package |
| Version: | 1.3-2 |
| Date: | 2023-08-19 |
| Author: | John Fox |
| Maintainer: | John Fox <jfox@mcmaster.ca> |
| Depends: | survival, date, stats |
| Imports: | Rcmdr (≥ 2.8-0), car |
| Description: | An R Commander plug-in for the survival package, with dialogs for Cox models, parametric survival regression models, estimation of survival curves, and testing for differences in survival curves, along with data-management facilities and a variety of tests, diagnostics and graphs. |
| License: | GPL-2 | GPL-3 [expanded from: GPL (≥ 2)] |
| LazyLoad: | yes |
| LazyData: | yes |
| RcmdrModels: | coxph, survreg, coxph.penal |
| NeedsCompilation: | no |
| Packaged: | 2023-08-19 18:34:25 UTC; johnfox |
| Repository: | CRAN |
| Date/Publication: | 2023-08-21 08:52:38 UTC |
Rcmdr Plug-In Package for the survival Package
Description
An R Commander plug-in for the survival package, with dialogs for managing survival data (this to a limited extent), Cox models, parametric survival regression models, estimation of survival curves, testing for differences in survival curves, and a variety of diagnostics, tests, and displays.
Details
The plug-in is tightly integrated with the R Commander interface; see the following menus: Data -> Survival data", Statistics -> Survival analysis, Statistics -> Fit Models, Models -> Hypothesis tests, Models -> Numerical diagnostics, Models -> Graphs.
Acknowledgments
I am grateful to Marilia Sa Carvalho, FIOCRUZ, Rio de Janeiro, Brazil, for many comments and suggestions, and to the following individuals for translations of messages into other languages: Philippe Grojean (French), Matjaz Jeran (Slovenian), Anton Korobeinikov (Russian), Manuel Munoz Marquez (Spanish), and Marilia Sa Carvalho (Portuguese).
Author(s)
John Fox
Maintainer: John Fox jfox@mcmaster.ca
References
John Fox, Marilia Sa Carvalho (2012). The RcmdrPlugin.survival Package: Extending the R Commander Interface to Survival Analysis. Journal of Statistical Software, 49(7), 1-32, doi:10.18637/jss.v049.i07.
Hemodialysis Data from Brazil
Description
This data set is analyzed in Sa Carvalho et al. (2003), and consists of data on 6805 hemodialysis patients in all federally funded clinics in Rio de Janeiro State, Brazil.
Usage
data(Dialysis)
Format
A data frame with 6805 observations on the following 7 variables.
centera numeric code indicating in which of 67 centers the patient was treated.
ageof the patient.
beginThe month in which treatment began, with
1representing January 1998.endThe month in which observation terminated, either because of death or censoring. The study ended in month
44(August, 2000).event1, death, or0, censoring.timethe difference between
endandbegin.diseasea factor with levels
congen, (congenital);diabetes;hypert(hypertension);other; andrenal.
Source
M. Sa Carvalho, R. Henderson, S. Shimakura, and I. P. S. C. Sousa (2003). Survival of hemodialysis patients: Modeling differences in risk of dialysis centers. International Journal for Quality in Health Care, 15: 189–196.
References
John Fox, Marilia Sa Carvalho (2012). The RcmdrPlugin.survival Package: Extending the R Commander Interface to Survival Analysis. Journal of Statistical Software, 49(7), 1-32. doi:10.18637/jss.v049.i07.
Examples
summary(Dialysis)
table(Dialysis$center)
Internal RcmdrPlugin.survival Objects
Description
Internal RcmdrPlugin.survival objects.
Details
These are not to be called by the user.
Rossi et al.'s Criminal Recidivism Data
Description
This data set is originally from Rossi et al. (1980), and is used as an example in Allison (1995). The data pertain to 432 convicts who were released from Maryland state prisons in the 1970s and who were followed up for one year after release. Half the released convicts were assigned at random to an experimental treatment in which they were given financial aid; half did not receive aid.
Usage
Rossi
Format
A data frame with 432 observations on the following 62 variables.
weekweek of first arrest after release or censoring; all censored observations are censored at 52 weeks.
arrest1if arrested,0if not arrested.finfinancial aid:
noyes.agein years at time of release.
raceblackorother.wexpfull-time work experience before incarceration:
nooryes.marmarital status at time of release:
marriedornot married.paroreleased on parole?
nooryes.prionumber of convictions prior to current incarceration.
educlevel of education:
2= 6th grade or less;3= 7th to 9th grade;4= 10th to 11th grade;5= 12th grade;6= some college.emp1employment status in the first week after release:
nooryes.emp2as above.
emp3as above.
emp4as above.
emp5as above.
emp6as above.
emp7as above.
emp8as above.
emp9as above.
emp10as above.
emp11as above.
emp12as above.
emp13as above.
emp14as above.
emp15as above.
emp16as above.
emp17as above.
emp18as above.
emp19as above.
emp20as above.
emp21as above.
emp22as above.
emp23as above.
emp24as above.
emp25as above.
emp26as above.
emp27as above.
emp28as above.
emp29as above.
emp30as above.
emp31as above.
emp32as above.
emp33as above.
emp34as above.
emp35as above.
emp36as above.
emp37as above.
emp38as above.
emp39as above.
emp40as above.
emp41as above.
emp42as above.
emp43as above.
emp44as above.
emp45as above.
emp46as above.
emp47as above.
emp48as above.
emp49as above.
emp50as above.
emp51as above.
emp52as above.
Source
Allison, P.D. (1995). Survival Analysis Using the SAS System: A Practical Guide. Cary, NC: SAS Institute.
References
Rossi, P.H., R.A. Berk, and K.J. Lenihan (1980). Money, Work, and Crime: Some Experimental Results. New York: Academic Press.
John Fox, Marilia Sa Carvalho (2012). The RcmdrPlugin.survival Package: Extending the R Commander Interface to Survival Analysis. Journal of Statistical Software, 49(7), 1-32. doi:10.18637/jss.v049.i07.
Examples
summary(Rossi)
Define Survival Data Dialog Box
Description
This dialog box permits you to define a time variable (or start and stop variables), an event indicator, a strata variable or variables, and a cluster variable to be associated with the current data set. If these characteristics are defined, then they will become default choices where appropriate in other dialog boxes.
Usage
SurvivalData() # normally not called directly
Value
Used only for its side effect.
Author(s)
John Fox <jfox@mcmaster.ca>
References
John Fox, Marilia Sa Carvalho (2012). The RcmdrPlugin.survival Package: Extending the R Commander Interface to Survival Analysis. Journal of Statistical Software, 49(7), 1-32. doi:10.18637/jss.v049.i07.
Diagnostics for Survival Regression Models
Description
These are primarily convenience functions for the RcmdrPlugin.survival package, to produce diagnostics for coxph and survreg models in a convenient form for plotting via the package's GUI.
Usage
crPlots(model, ...)
## S3 method for class 'coxph'
crPlots(model, ...)
## S3 method for class 'coxph'
dfbeta(model, ...)
## S3 method for class 'dfbeta.coxph'
plot(x, ...)
## S3 method for class 'coxph'
dfbetas(model, ...)
## S3 method for class 'dfbetas.coxph'
plot(x, ...)
## S3 method for class 'survreg'
dfbeta(model, ...)
## S3 method for class 'dfbeta.survreg'
plot(x, ...)
## S3 method for class 'survreg'
dfbetas(model, ...)
## S3 method for class 'dfbetas.survreg'
plot(x, ...)
MartingalePlots(model, ...)
## S3 method for class 'coxph'
MartingalePlots(model, ...)
testPropHazards(model, test.terms = FALSE, plot.terms = FALSE, ...)
## S3 method for class 'coxph'
testPropHazards(model, test.terms = FALSE, plot.terms = FALSE, ...)
Arguments
model, x |
a Cox regression or parametric survival regression model, as appropriate. |
test.terms |
test proportional hazards by terms in the Cox model, rather than by coefficients (default is |
plot.terms |
diagnostic plots of proportional hazards by terms in the Cox model, rather than by coefficients (default is |
... |
arguments to be passed down. |
Details
-
crPlots.coxphis a method for thecrPlotsfunction in the car package, to create component+residual (partial-residual) plots, usingresiduals.coxphandpredict.coxphin the survival package. -
testPropHazardsis essentially a wrapper for thecox.zphfunction in the survival package. -
MartingalePlotscreates null-model Martingale plots for Cox regression models, using theresiduals.coxphfunction in the survival package. -
dfbeta.coxphanddfbetas.coxphprovide methods for the standarddfbetaanddfbetasfunctions, using theresiduals.coxphfunction in the survival package for computation.plot.dfbeta.coxphandplot.dfbetas.coxphare plot methods for the objects produced by these functions. -
dfbeta.survreg,dfbetas.survreg,plot.dfbeta.survregandplot.dfbetas.survregare similar methods forsurvregobjects.
Value
Most of these function create graphs and don't return useful values; the dfbeta and dfbetas methods create matrices of dfbeta and dfbetas values.
Author(s)
John Fox <jfox@mcmaster.ca>
References
John Fox, Marilia Sa Carvalho (2012). The RcmdrPlugin.survival Package: Extending the R Commander Interface to Survival Analysis. Journal of Statistical Software, 49(7), 1-32. doi:10.18637/jss.v049.i07.
See Also
coxph, survreg, crPlots, residuals.coxph, residuals.survreg, predict.coxph, cox.zph
Dialog to Convert a Survival Data Set from "Wide" to "Long" Format
Description
Converts a survival-analysis data frame from "wide" format, in which time-varying covariates are separate variables, one per occasion, to "long" or counting-process format in which each occasion is a separate row in the data frame.
Usage
Unfold() # called via the R Commander menus
Details
Most of the dialog box is self-explanatory. A time-varying covariate is identified
by selecting the variables constituting the covariate in the "wide" version of the data set
using the variable-list box at the lower-left; specifying a name to be used
for the covariate in the "long" version of the data set; and pressing the Select button.
This process is repeated for each time-varying covariate. All time-varying covariates have to
be measured on the same occasions, which are assigned times 0, 1, ... in the output data set. If the
covariates are to be lagged, this is indicated via the Lag covariates slider near the
lower right. The default lag is 0 — i.e., no lag. The output data set will include variables named
start and stop, which give the counting-process start and stop times for each
row, and an event indicator composed of the name of the event indicator in the "wide" form of the
data set and the suffix .time.
The Unfold dialog calls the unfold function, which is somewhat more flexible.
Author(s)
John Fox <jfox@mcmaster.ca>
References
John Fox, Marilia Sa Carvalho (2012). The RcmdrPlugin.survival Package: Extending the R Commander Interface to Survival Analysis. Journal of Statistical Software, 49(7), 1-32. doi:10.18637/jss.v049.i07.
See Also
Function to Compute Layout for Plot Array
Description
Given a number of plots n, find a arrangement for showing the plots in an array,
set by par(mfrow=mfrow(n)).
Usage
mfrow(n, max.plots = 0)
Arguments
n |
number of plots |
max.plots |
maximum number of plots; |
Author(s)
John Fox <jfox@mcmaster.ca>
See Also
par
Examples
mfrow(4)
mfrow(5)
mfrow(6)
Plot Method for coxph Objects
Description
Plots the predicted survival function from a coxph object, setting covariates to particular values.
Usage
## S3 method for class 'coxph'
plot(x, newdata, typical = mean, byfactors=FALSE,
col = palette(), lty, conf.level = 0.95, ...)
Arguments
x |
a |
newdata |
a data frame containing (combinations of) values to which predictors are set; optional. |
typical |
function to use to compute "typical" values of numeric predictors. |
byfactors |
if |
col |
colors for lines. |
lty |
line-types for lines; if missing, defaults to 1 to number required. |
conf.level |
level for confidence intervals; note: whether or not confidence intervals are
plotted is determined by |
... |
arguments passed to |
Details
If newdata is missing then all combinations of levels of factor-predictors (or strata),
if present, are combined with "typical" values of numeric predictors.
Value
Invisibly returns the summary resulting from applying survfit.coxph
to the coxph object.
Author(s)
John Fox jfox@mcmaster.ca.
References
John Fox, Marilia Sa Carvalho (2012). The RcmdrPlugin.survival Package: Extending the R Commander Interface to Survival Analysis. Journal of Statistical Software, 49(7), 1-32. doi:10.18637/jss.v049.i07.
See Also
coxph, survfit.coxph,
plot.survfit.
Examples
require(survival)
cancer$sex <- factor(ifelse(cancer$sex == 1, "male", "female"))
mod.1 <- coxph(Surv(time, status) ~ age + wt.loss, data=cancer)
plot(mod.1)
plot(mod.1, typical=function(x) quantile(x, c(.25, .75)))
mod.2 <- coxph(Surv(time, status) ~ age + wt.loss + sex, data=cancer)
plot(mod.2)
mod.3 <- coxph(Surv(time, status) ~ (age + wt.loss)*sex, data=cancer)
plot(mod.3)
mod.4 <- coxph(Surv(time, status) ~ age + wt.loss + strata(sex), data=cancer)
plot(mod.4)
mods.1 <- survreg(Surv(time, status) ~ age + wt.loss, data=cancer)
Convert a Survival Data Set from "Wide" to "Long" Format
Description
Converts a survival-analysis data frame from "wide" format, in which time-varying covariates are separate variables, one per occasion, to "long" or counting-process format in which each occasion is a separate row in the data frame.
Usage
unfold(data, ...)
## S3 method for class 'data.frame'
unfold(data, time, event, cov,
cov.names = paste("covariate", ".", 1:ncovs, sep = ""),
suffix = ".time", cov.times = 0:ncov, common.times = TRUE, lag = 0,
show.progress=TRUE, ...)
Arguments
data |
a data frame to be "unfolded" from wide to long. |
time |
the column number or quoted name of the event/censoring-time variable in data. |
event |
the column number or quoted name of the event/censoring-indicator variable in data. |
cov |
a vector giving the column numbers of the time-dependent covariate
in |
cov.names |
a character string or character vector giving the name or names to be assigned to the time-dependent covariate(s) in the output data set. |
suffix |
the suffix to be attached to the name of the time-to-event variable in the output data set; defaults to '.time'. |
cov.times |
the observation times for the covariate values, including the start
time. This argument can take several forms: (1) The default is integers from 0 to
the number of covariate values (i.e., one more than the length of each vector in |
common.times |
a logical value indicating whether the times of observation
are the same for all individuals; defaults to |
lag |
number of observation periods to lag each value of the time-varying
covariate(s); defaults to |
show.progress |
if |
... |
arguments to be passed down. |
Value
A data frame containing the "long" version of the data set.
Author(s)
John Fox <jfox@mcmaster.ca>
References
John Fox, Marilia Sa Carvalho (2012). The RcmdrPlugin.survival Package: Extending the R Commander Interface to Survival Analysis. Journal of Statistical Software, 49(7), 1-32. doi:10.18637/jss.v049.i07.
Examples
if (interactive()){
head(Rossi, 2)
Rossi.long <- unfold(Rossi, time="week", event="arrest", cov=11:62,
cov.names="emp")
head(Rossi.long, 50)
}