Movatterモバイル変換


[0]ホーム

URL:


Type:Package
Title:Cause-Specific Framework for Competing-Risk Analysis
Version:1.2.1
Date:2025-09-23
Description:Numerical integration of cause-specific survival curves to arrive at cause-specific cumulative incidence functions, with three usage modes: 1) Convenient API for parametric survival regression followed by competing-risk analysis, 2) API for CFC, accepting user-specified survival functions in R, and 3) Same as 2, but accepting survival functions in C++. For mathematical details and software tutorial, see Mahani and Sharabiani (2019) <doi:10.18637/jss.v089.i09>.
License:GPL-2 |GPL-3 [expanded from: GPL (≥ 2)]
Imports:Rcpp (≥ 0.12.1), abind, survival, doParallel, foreach
LinkingTo:Rcpp, RcppArmadillo, RcppProgress
NeedsCompilation:yes
Packaged:2025-09-24 04:31:26 UTC; root
Author:Mansour T.A. Sharabiani [aut], Alireza S. Mahani [aut, cre]
Maintainer:Alireza S. Mahani <alireza.s.mahani@gmail.com>
Repository:CRAN
Date/Publication:2025-09-24 05:11:41 UTC

The Bone Marrow Transplant Data

Description

Bone marrow transplant data with 408 rows and 5 columns.

Format

The data has 408 rows and 5 columns.

cause

a numeric vector code. Survival status. 1: dead from treatment related causes, 2: relapse , 0: censored.

time

a numeric vector. Survival time.

platelet

a numeric vector code. Plalelet 1: more than 100 x10^9 per L, 0: less.

tcell

a numeric vector. T-cell depleted BMT 1:yes,0:no.

age

a numeric vector code. Age of patient, scaled andcentered ((age-35)/15).

Source

Simulated data (taken from R package 'timereg')


Cause-specific competing-risk survival analysis

Description

Using adaptive generalized Newton-Cotes for calculating cumulative incidence functions.

Usage

cfc(f.list, args.list, n, tout, Nmax = 100L, rel.tol = 1e-05, ncores = 1)

Arguments

f.list

InR mode, this is a list of survival functions, one per cause. Each survival function must have the prototypef(t, args, n), wheret is a vector of time-from-index values,args is a list of all arguments needed by the function, andn is the iterator that allows the function to produce a different output for each observation and/or Bayesian sample. The output is a vector of survival probabilities at timest for that particular observation/sample combination with iterator valuen. InC++ mode, this is a list of lists, one per cause. Each list must contain pointers to threeC++ functions, in order: 1) survival function of typefunc with prototype defined astypedef arma::vec (*func)(arma::vec x, void* arg, int n) (usingRcppArmadillo'svec class) and a similar interpetation as itsR counterpart, 2) initializer function of typeinitfunc, with prototype defined astypedef void* (*initfunc)(List arg), whereList is theRcpp wrapper class forR lists, and 3) resource de-allocator function of typefreefunc with this prototype:typedef void (*freefunc)(void *arg). See vignette forC++ example.

args.list

List of arguments (each one a list), one per cause, to be supplied to the survival functions inf.list.

n

Range of iterator (starting at1) for survival functions. This can be the product of number of observations, and number of MCMC samplers in a Bayesian survival function.

tout

Vector of time points for which cumulative incidence functions are requested.

Nmax

Maximum number of subdivisions in the interval [0,max(tout)] to be created in the adaptive quadrature algorithm.

rel.tol

Threshold for relative integration error, used as stoppage criterion. It is calculated as the maximum relative error at time pointmax(tout) across all causes. Each relative error number is the difference between the Simpson-based and trapezoidal-based numbers, divided by the Simpson-based number.

ncores

Number of parallel threads to use. This is currrently only implemented inC++ mode.

Value

An object of classcfc, which is a list with the following elements:

ci

Array of dimensions(length(tout), length(f.list), n), cumulative incidence functions for all causes and all values of the iterator, evaluated at all time points indicated bytout.

s

Array of same dimensions asci, containing the (unadjusted) survival functions for all causes and all values of the iterator, evaluated at all time points indicated bytout.

is.maxiter

Binary Array of lengthn, where1 indicates that subdivision process for quadrature problem applied to survival functions at iterationn reached maximum set byNmax before converging, and0 otherwise.

n.maxiter

Number of iterations that did not converge, i.e.,sum(is.maxiter).

Author(s)

Mansour T.A. Sharabiani, Alireza S. Mahani

References

Haller, B., Schmidt, G., & Ulm, K. (2013). Applying competing risks regression models: an overview. Lifetime data analysis, 1-26.

Mahani A.S. and Sharabiani M.T.A. (2019). Bayesian, and Non-Bayesian, Cause-Specific Competing-Risk Analysis for Parametric and Nonparametric Survival Functions: The R Package CFC. Journal of Statistical Software, 89(9), 1-29. doi:10.18637/jss.v089.i09

Prentice et al (1978). The analysis of failure times in the presence of competing risks. Biometrics, 541-554.

See Also

cfc.survreg

Examples

## Not run: library("survival") # used for constructing survival formulaslibrary("BSGW") # used for Bayesian survival regressiondata("bmt")# splitting data into training and prediction setsidx.train <- sample(1:nrow(bmt), size = 0.7 * nrow(bmt))idx.pred <- setdiff(1:nrow(bmt), idx.train)nobs.train <- length(idx.train)nobs.pred <- length(idx.pred)# prepare data and formula for Bayesian cause-specific survival regression# using R package BSGWout.prep <- cfc.prepdata(Surv(time, cause) ~ platelet + age + tcell, bmt)f1 <- out.prep$formula.list[[1]]f2 <- out.prep$formula.list[[2]]dat <- out.prep$dattmax <- out.prep$tmax# estimating cause-specific models# set nsmp to larger number in real-world applicationsnsmp <- 10reg1 <- bsgw(f1, dat[idx.train, ], control = bsgw.control(iter = nsmp)  , ordweib = T, print.level = 0)reg2 <- bsgw(f2, dat[idx.train, ], control = bsgw.control(iter = nsmp)  , ordweib = T, print.level = 0)# defining survival function for this modelsurvfunc <- function(t, args, n) {  nobs <- args$nobs; natt <- args$natt; nsmp <- args$nsmp  alpha <- args$alpha; beta <- args$beta; X <- args$X  idx.smp <- floor((n - 1) / nobs) + 1  idx.obs <- n - (idx.smp - 1) * nobs  return (exp(- t ^ alpha[idx.smp] *                 exp(sum(X[idx.obs, ] * beta[idx.smp, ]))));}# preparing function and argument listsX.pred <- as.matrix(cbind(1, bmt[idx.pred, c("platelet", "age", "tcell")]))arg.1 <- list(nobs = nobs.pred, natt = 4, nsmp = nsmp  , alpha = exp(reg1$smp$betas), beta = reg1$smp$beta, X = X.pred)arg.2 <- list(nobs = nobs.pred, natt = 4, nsmp = nsmp  , alpha = exp(reg2$smp$betas), beta = reg2$smp$beta, X = X.pred)arg.list <- list(arg.1, arg.2)f.list <- list(survfunc, survfunc)# cause-specific competing-risk# set rel.tol to smaller number in real-world applicationstout <- seq(from = 0.0, to = tmax, length.out = 10)out.cfc <- cfc(f.list, arg.list, nobs.pred * nsmp, tout, rel.tol = 1e-2)## End(Not run)

Cause-specific competing-risk survival analysis in probability denomination

Description

Constructing cumulative incidence and event-free probability functions from cause-specific survival times give for a fixed set of probabilities.

Usage

cfc.pbasis(t1, t2, probs, unity.tol = 1e-06, diff.tol = 0.01,  diff.tol.policy = c("all", "mean"))

Arguments

t1

Multi-dimensional array containing survival times for cause 1 (i.e. exponential of the negative integral of hazard function). First dimension must correspond to probabilities at which times are calculated. Elements with same time, but distributed in the space of remaining dimensions, are treated independently. These diemensions can correspond, e.g., to observations or samples (in Bayesian frameworks). Survival times must be increasing along the first dimension.

t2

Multi-dimensional array containing survival times for cause 2. See note fort1.

probs

Probabilities for which survival times are provided int1 andt2. Must begin at 1.0 and be decreasing.

unity.tol

Tolerance for difference of survival probability from 1.0 at time=0.0. In other words, we require thatabs(probs[1] - 1.0) < unity.tol.

diff.tol

Tolerance for change in survival probabilities from one time point to the next. Large changes lead to higher errors during numerical integration.

diff.tol.policy

If"mean", then average change in survival probabilities are compared todiff.tol. If"all", each values is compared. The latter is more strict.

Details

For each 'row' oft1, andt2, all elements are processed independently. To combine the survival curves from corresponding elements oft1 andt2, we first form a 'comon denominator' time vector by combining the two time vectors and sorting the results (after removing duplicates). We limit the maximum value in the combined time vector to minimum of the the two maxima from each cause. Next, we use interpolation to find survival probabilities of each cause at all the time points in the combined time vector. Finally, we call the functioncfc.tbasis.

Value

Ift1 andt2 are one-dimensional, a matrix with columns named"time","ci1","ci2" and"efp" is returned. For multi-dimensional arrays, a list is returned with one such matrix for each element of the consolidated dimension representing all but the first dimension oft1 andt2.

Author(s)

Mansour T.A. Sharabiani, Alireza S. Mahani

References

Mahani A.S. and Sharabiani M.T.A. (2019). Bayesian, and Non-Bayesian, Cause-Specific Competing-Risk Analysis for Parametric and Nonparametric Survival Functions: The R Package CFC. Journal of Statistical Software, 89(9), 1-29. doi:10.18637/jss.v089.i09

Prentice et al (1978). The analysis of failure times in the presence of competing risks. Biometrics, 541-554.

See Also

cfc.tbasis

Examples

## Not run: # prepare data for cause-specific competing-risk analysisdata(bmt)bmt$status1 <- 1*(bmt$cause==1)bmt$status2 <- 1*(bmt$cause==2)f1 <- Surv(time, status1) ~ platelet + age + tcellf2 <- Surv(time, status2) ~ platelet + age + tcell# perform weibull regression on each cause independentlylibrary(survival)reg1 <- survreg(f1, bmt)reg2 <- survreg(f2, bmt)# predict times for given probabilities# transpose predictions so that first dimension# is time/probability (use first 50 observations for speed)pvec <- seq(from=1.0, to = 0.1, length.out = 100)pred1 <- t(predict(reg1, newdata = bmt[1:50,], p = 1-pvec, type = "quantile"))pred2 <- t(predict(reg2, newdata = bmt[1:50,], p = 1-pvec, type = "quantile"))# cause-specific competing risk analysis - probability modemy.cfc <- cfc.pbasis(pred1, pred2, probs = pvec)# calculating averages across observations (e.g. patients in the study)my.summ <- summary(my.cfc)# plotting average CI and event-free probability curvesplot(my.summ)## End(Not run)

Utility function for CFC data preparation

Description

Preparing a data frame and formulas for cause-specific competing-risk survival analysis. It expands the multi-state status column into a series of binary columns by treating an event for a cause as censoring for all other causes.

Usage

cfc.prepdata(formul, dat)

Arguments

formul

Original survival formula.

dat

Original data frame, withstatus column being an integer with values from0 toK. The value0 represents right-censoring, while1 toK represent theK mutually-exclusive events.

Details

The output data frame will haveK new binary status columns. TheK new status columns will be named"status_1","status_2" through"status_<K>". Each of the output formulas informula.list field will have the correspondingstatus. Column "status_1" will be1 whereverstatus equals1 in original data frame, and0 elsewhere, and similarly for the remainingK-1 newly-added status columns.

Value

A list with the following elements:

K

Number of causes.

dat

Expanded data frame.

formula.list

A list ofK formulas, each corresponding to one of the cause-specific survival models to be estimated. See details.

formula.noresp

A formula with no left-hand side (time and status variables). This can be used for preparing the model matrix for prediction data sets, which can possibly have no response.

tmax

Maximum time to event/censoring extracted from original data frame. This can be used, e.g., during competing-risk analysis.

Author(s)

Mansour T.A. Sharabiani, Alireza S. Mahani

References

Mahani A.S. and Sharabiani M.T.A. (2019). Bayesian, and Non-Bayesian, Cause-Specific Competing-Risk Analysis for Parametric and Nonparametric Survival Functions: The R Package CFC. Journal of Statistical Software, 89(9), 1-29. doi:10.18637/jss.v089.i09

Examples

data(bmt)prep.out <- cfc.prepdata(Surv(time, cause) ~ platelet + age + tcell, bmt)

Cause-specific competing-risk survival analysis, using parametric survival regression models

Description

Convenient function to build cause-specific, parametric survival models using thesurvival package. This is followed by application ofcfc function to produce cumulative incidence functions.

Usage

cfc.survreg(formula, data, newdata = NULL, dist = "weibull"  , control = survreg.control(), tout, Nmax = 100L  , rel.tol = 1e-05)

Arguments

formula

Survival formula with a multi-state status variable. Seecfc.prepdata.

data

Data frame containing variables listed informula.

newdata

Data frame of structure similar todata, perhaps without the time and status columns, to be used for generating cumulative incidence curves.

dist

One ofsurvreg.distributions. It can also be a vector, in which case elements1 throughK (number of causes) will be extracted and assigned to each cause-specific survival model. This allows for using different distributions for different causes.

control

List ofsurvreg control parameters, according tosurvreg.control.

tout

Time points, along which to produce the cumulative incidence curves.

Nmax

Maximum number of subdivisions to be used in thecfc quadrature algorithm.

rel.tol

Threshold for relative error incfc quadrature, used as a stoppage criterion. Seecfc for details.

Value

A list with the following elements:

K

Number of causes.

formulas

List of formulas used in each of theK cause-specific survival regression models.

regs

List of all cause-specific regression objects returned bysurvreg, one per cause. Thex field of each regression object has been substituted by the model matrix fromnewdata.

tout

Same as input.

cfc

An object of classcfc, the output of applyingcfc to the parametric survival regression models constructed usingsurvreg fromsurvival package.

Author(s)

Mansour T.A. Sharabiani, Alireza S. Mahani

References

Mahani A.S. and Sharabiani M.T.A. (2019). Bayesian, and Non-Bayesian, Cause-Specific Competing-Risk Analysis for Parametric and Nonparametric Survival Functions: The R Package CFC. Journal of Statistical Software, 89(9), 1-29. doi:10.18637/jss.v089.i09

See Also

cfc.prepdata,cfc

Examples

data(bmt)formul <- Surv(time, cause) ~ platelet + age + tcellret <- cfc.survreg(formul, bmt[1:300, ], bmt[-(1:300), ]  , Nmax = 300, rel.tol = 1e-3)

Survival probability function forsurvreg models

Description

Function for predicting survival probability as a function of time forsurvreg regression objects insurvival package. It can be used to mixsurvreg models with other survival models in competing-risk analysis, usingCFC package. This function is used insidecfc.survreg.

Usage

cfc.survreg.survprob(t, args, n)

Arguments

t

Time from index. Must be non-negative, but can be a vector.

args

Regression object that is returned bysurvreg. If usingnewdata for prediction, thex field of this object must be updated accordingly.

n

Observation index, must be between1 andnrow(args$x).

Value

Vector of survival probabilities at time(s)t.

Author(s)

Mansour T.A. Sharabiani, Alireza S. Mahani

References

Mahani A.S. and Sharabiani M.T.A. (2019). Bayesian, and Non-Bayesian, Cause-Specific Competing-Risk Analysis for Parametric and Nonparametric Survival Functions: The R Package CFC. Journal of Statistical Software, 89(9), 1-29. doi:10.18637/jss.v089.i09

See Also

cfc.survreg

Examples

## Not run: library("CFC") # for cfcdata(bmt)library("randomForestSRC") # for rfsrclibrary("survival") # for survregprep <- cfc.prepdata(Surv(time, cause) ~ platelet + age + tcell, bmt)f1 <- prep$formula.list[[1]]f2 <- prep$formula.list[[2]]dat <- prep$dattmax <- prep$tmax# building a parametric Weibull regression model# for cause 1reg1 <- survreg(f1, dat, x = TRUE) # must keep x for prediction# building a random forest survival model for cause 2reg2 <- rfsrc(f2, dat)# implementing a continuous interface for the random forest# survival functionrfsrc.survfunc <- function(t, args, n) {  which.zero <- which(t < .Machine$double.eps)  ret <- approx(args$time.interest, args$survival[n, ], t, rule = 2)$y  ret[which.zero] <- 1.0  return (ret)}# constructing function and argument listf.list <- list(cfc.survreg.survprob, rfsrc.survfunc)arg.list <- list(reg1, reg2)# competing-risk analysistout <- seq(0.0, tmax, length.out = 10)# increase rel.tol for higher accuracycfc.out <- cfc(f.list, arg.list, nrow(bmt), tout, rel.tol = 1e-3)## End(Not run)

Cause-specific competing-risk survival analysis in time denomination

Description

Constructing cumulative incidence and event-free probability functions from cause-specific survival probabilities evaluated at fixed time points.

Usage

cfc.tbasis(p1, p2, unity.tol = 1e-06, diff.tol = 0.01,  diff.tol.policy = c("mean", "all"), check = TRUE)

Arguments

p1

Multi-dimensional array containing survival probabilities for cause 1 (i.e. exponential of the negative integral of hazard function). First dimension must correspond to time points at which probabilities are calculated. Elements with same time, but distributed in the space of remaining dimensions, are treated independently. These diemensions can correspond, e.g., to observations or samples (in Bayesian frameworks).

p2

Multi-dimensional array containing survival probabilities for cause 2. See note forp1.

unity.tol

Tolerance for difference of survival probabilities from 1.0 at time=0.0, which is the first 'row' of arraysp1 andp2. For example, for two-dimensional arrays, we needall(abs(p1[1,]-1.0) < unity.tol), and a similar condition forp2.

diff.tol

Tolerance for change in survival probabilities from one time point to the next. Large changes lead to higher errors during numerical integration.

diff.tol.policy

If"mean", then average change in survival probabilities are compared todiff.tol. If"all", each values is compared. The latter is more strict.

check

Boolean flag indicating whether or not to check probability arrays for validity. Current validity checks are: 1) ensuring all probabilities are between 0.0 and 1.0, 2) all probabilities at time=0.0 are equal to 1.0 (seeunity.tol), 3) No changes in probabilities from one time point to next are too large (seediff.tol). Dimensional consistency betweenp1 andp2 is always checked regardless of the value of this flag.

Details

Assuming one-dimensionalp1 andp2 for clarity, the algorithm calculates cumulative incidence function for cuase 1 using a recursive formula:ci1[n+1] = ci1[n] + dci1[n], wheredci1[n] = 0.5*(p2[n] + p2[n+1])*(p1[n] - p1[n+1]). The increment in cumulative incidence function for cause 2 is similarly calculated,dci2[n] = 0.5*(p1[n] + p1[n+1])*(p2[n] - p2[n+1]). These equations guarantee thatdci1[n] + dci2[n] = p1[n]*p2[n] - p1[n+1]*p2[n+1]. Event-free probability is simply calculated asefp[n] = p1[n]*p2[n]. Taken together, this numerical integration ensures thatefp[n+1] - efp[n] + dci1[n] + dci2[n] = 0.

Value

Ifp1 andp2 are one-dimensional arrays (i.e. vectors), a matrix with columns named"ci1","ci2" and"efp" is returned, representing the cummulative incidence functions for cause 1 and cause 2 and the event-free probability, evaluated at same time points asp1 andp2 are provided. Ifp1 andp2 are multi-dimensional arrays, a list is returned with elements"ci1","ci2" and"efp", each one with the same interpretation, and all of the same dimensions asp1 andp2.

Note

The integration algorithm described above does not require knowledge of time step. (Alternatively, using hazard functions for integration would have required specification of time step.) Sincep1 andp2 are integrals (followed by exponentiation) of cause-specific hazard functions, using them directly adds to robustness of numerical integration and avoids error accumulation. The returned cumulative incidence and event-free probabilities correspond to the same time points assumed for input cause-specific probabilities.

Author(s)

Mansour T.A. Sharabiani, Alireza S. Mahani

References

Mahani A.S. and Sharabiani M.T.A. (2019). Bayesian, and Non-Bayesian, Cause-Specific Competing-Risk Analysis for Parametric and Nonparametric Survival Functions: The R Package CFC. Journal of Statistical Software, 89(9), 1-29. doi:10.18637/jss.v089.i09

Prentice et al (1978). The analysis of failure times in the presence of competing risks. Biometrics, 541-554.

See Also

cfc.pbasis

Examples

## Not run: # prepare data for cause-specific competing-risk analysisdata(bmt)bmt$status1 <- 1*(bmt$cause==1)bmt$status2 <- 1*(bmt$cause==2)f1 <- Surv(time, status1) ~ platelet + age + tcellf2 <- Surv(time, status2) ~ platelet + age + tcell# sample-based bayesian weibull regressionlibrary(BSGW)reg1 <- bsgw(f1, bmt, ordweib = TRUE, control = bsgw.control(iter = 500, burnin = 100, nskip = 50))reg2 <- bsgw(f2, bmt, ordweib = TRUE, control = bsgw.control(iter = 500, burnin = 100, nskip = 50))# prediction on a uniform grid of 100 time points# (use first 50 observations for speed)pred1 <- predict(reg1, newdata = bmt[1:50,], tvec = 100)pred2 <- predict(reg2, newdata = bmt[1:50,], tvec = 100)# permuting dimensions of survival objects to conform with cfcS1 <- aperm(pred1$smp$S, c(2,1,3))S2 <- aperm(pred2$smp$S, c(2,1,3))# cause-specific competing risk analysis - time modemy.cfc <- cfc.tbasis(S1, S2)# calculating averages across observations (e.g. patients in the study)my.summ <- summary(my.cfc, MARGIN = c(1,2))# plotting mean CI and event-free functions# as well as their sampled-based confidence intervalsplot(my.summ, t = pred1$tvec)## End(Not run)

Summarizing and plotting output ofcfc

Description

summary method for classcfc.

Usage

## S3 method for class 'cfc'summary(object  , f.reduce = function(x) x  , pval = 0.05, ...)## S3 method for class 'summary.cfc'plot(x, which = c(1, 2), ...)

Arguments

object

An object of class "cfc", usually the result of a call tocfc.

f.reduce

Function to be applied to each sub-array ofobject$ci (cumulative incidence) andobject$s (survival probability).

pval

Desired significance level for confidence intervals produced bysummary.cfc. We essentially set the argumentprobs toc(pval/2, 0.5, 1-pval/2) when callingquantile.

x

An object of class "summary.cfc", usually the result of a call tosummary.cfc.

which

Vector of integers, indicating which plot(s) must be produced: 1) cumulative incidence functions, one per cause. For each cause, median and credible bands are plotted vs. time-from-index. 2) (unadjusted) survival functions, one per cause. Similar to (1), median and credible bands are plotted.

...

Further arguments to be passed tof.reduce (forsummary.cfc).

Value

Recall that the survival probability and cumulative incidence arrays returned bycfc are three-dimensional, and their first two dimensions indicate 1) time points and 2) causes.f.reduce is expected to produce an array of a fixed length, when applied to each sub-array,ci[i, j, ] ands[i, j, ]. The end-result is two three-dimensional array, where the first two dimensions are identical to its input arrays. This 3D array is then passed to thequantile function to compute median and credible bands. There is a special case wheref.reduce returns a scalar, rather than an array, when applied to each sub-array. In this case, quantile calculation is meaningless and we return simply these point estimates. In summary, the return object fromsummary is a list with elements: 1)ci (cumulative incidence), 2)s (survival), and 3)quantiles, a boolean flag indicating whether the cumulative incidence and survival arrays returned are quantiles or point estimates.

Author(s)

Alireza S. Mahani, Mansour T.A. Sharabiani

References

Mahani A.S. and Sharabiani M.T.A. (2019). Bayesian, and Non-Bayesian, Cause-Specific Competing-Risk Analysis for Parametric and Nonparametric Survival Functions: The R Package CFC. Journal of Statistical Software, 89(9), 1-29. doi:10.18637/jss.v089.i09

See Also

cfc,summary.

Examples

## Not run: library("BSGW") # used for Bayesian survival regressiondata(bmt)# splitting data into training and prediction setsidx.train <- sample(1:nrow(bmt), size = 0.7 * nrow(bmt))idx.pred <- setdiff(1:nrow(bmt), idx.train)nobs.train <- length(idx.train)nobs.pred <- length(idx.pred)# prepare data and formula for Bayesian cause-specific survival regression# using R package BSGWout.prep <- cfc.prepdata(Surv(time, cause) ~ platelet + age + tcell, bmt)f1 <- out.prep$formula.list[[1]]f2 <- out.prep$formula.list[[2]]dat <- out.prep$dattmax <- out.prep$tmax# estimating cause-specific models# set nsmp to larger number in real-world applicationsnsmp <- 10reg1 <- bsgw(f1, dat[idx.train, ], control = bsgw.control(iter = nsmp)  , ordweib = T, print.level = 0)reg2 <- bsgw(f2, dat[idx.train, ], control = bsgw.control(iter = nsmp)  , ordweib = T, print.level = 0)# defining survival function for this modelsurvfunc <- function(t, args, n) {  nobs <- args$nobs; natt <- args$natt; nsmp <- args$nsmp  alpha <- args$alpha; beta <- args$beta; X <- args$X  idx.smp <- floor((n - 1) / nobs) + 1  idx.obs <- n - (idx.smp - 1) * nobs  return (exp(- t ^ alpha[idx.smp] *                 exp(sum(X[idx.obs, ] * beta[idx.smp, ]))));}# preparing function and argument listsX.pred <- as.matrix(cbind(1, bmt[idx.pred, c("platelet", "age", "tcell")]))arg.1 <- list(nobs = nobs.pred, natt = 4, nsmp = nsmp  , alpha = exp(reg1$smp$betas), beta = reg1$smp$beta, X = X.pred)arg.2 <- list(nobs = nobs.pred, natt = 4, nsmp = nsmp  , alpha = exp(reg2$smp$betas), beta = reg2$smp$beta, X = X.pred)arg.list <- list(arg.1, arg.2)f.list <- list(survfunc, survfunc)# cause-specific competing-risk# set rel.tol to smaller number in real-world applicationsout.cfc <- cfc(f.list, arg.list, nobs.pred * nsmp, tout, rel.tol = 1e-2)# summarizing (and plotting) the results# this function calculates the population-average CI and survival, one# per each MCMC sample; therefore, the quantiles produced by the summary# method, correspondingly, reflect our confidence in population-average valuesmy.f.reduce <- function(x, nobs, nsmp) {  return (colMeans(array(x, dim = c(nobs, nsmp))))}my.summ <- summary(out.cfc, f.reduce = my.f.reduce, nobs = nobs.pred, nsmp = nsmp)## End(Not run)

Summarizing probability-denominated CFC objects

Description

summary method for classcfc.pbasis.

Usage

## S3 method for class 'cfc.pbasis'summary(object, ...)## S3 method for class 'summary.cfc.pbasis'plot(x, ...)

Arguments

object

An object of class "cfc.pbasis", usually the result of a call tocfc.pbasis.

x

An object of class "summary.cfc.pbasis", usually the result of a call tosummary.cfc.pbasis.

...

Further arguments to be passed to/from other methods.

Value

The functionsummary.cfc.pbasis calculates the average of cumulative incidence and event-free probability functions at each time point across all elements of the object list. If the object is a matrix, it is returned without change.

Author(s)

Alireza S. Mahani, Mansour T.A. Sharabiani

References

Mahani A.S. and Sharabiani M.T.A. (2019). Bayesian, and Non-Bayesian, Cause-Specific Competing-Risk Analysis for Parametric and Nonparametric Survival Functions: The R Package CFC. Journal of Statistical Software, 89(9), 1-29. doi:10.18637/jss.v089.i09

See Also

The model fitting function iscfc.pbasis. Seesummary andplot for descriptions of the generic methods. Seecfc.tbasis for time-denominated CFC, as well as usage examples.


Summarizing and plotting output ofcfc.survreg

Description

summary and method for classcfc.survreg.

Usage

## S3 method for class 'cfc.survreg'summary(object, obs.idx = "all", ...)## S3 method for class 'summary.cfc.survreg'plot(x, which = c(1, 2), ...)

Arguments

object

An object of class "cfc.survreg", usually the result of a call tocfc.survreg.

obs.idx

Index of observations to calculate mean cumulative incidence for; defaults to all observation.

...

Further arguments to be passed to/from other methods.

x

An object of classsummary.cfc.survreg, usually the output ofsummary.cfc.survreg.

which

Vector of integers, indicating which plot(s) must be produced: 1) cumulative incidence functions, one per cause, as a function of time-to-index, all in the same plot, 2) comparison of cumulative incidence function with/without competing-risk adjustment. The unadjusted figure is equivalent to 1 minus the Kaplan-Meyer (i.e., survival) function.

Value

summary.cfc.surveeg produces a matrix of dimensionslength(object$tout) (number of time points) byobject$K (number of causes). See description ofwhich aregument forplot.summary.cfc.survreg.

Author(s)

Mansour T.A. Sharabiani, Alireza S. Mahani

References

Mahani A.S. and Sharabiani M.T.A. (2019). Bayesian, and Non-Bayesian, Cause-Specific Competing-Risk Analysis for Parametric and Nonparametric Survival Functions: The R Package CFC. Journal of Statistical Software, 89(9), 1-29. doi:10.18637/jss.v089.i09

See Also

The model fitting function iscfc.survreg. Seesummary andplot for descriptions of the generic methods. For more flexible ways of cause-specific competing-risk analysis, seecfc.


Summarizing time-denominated CFC objects

Description

summary method for classcfc.tbasis.

Usage

## S3 method for class 'cfc.tbasis'summary(object,  MARGIN = if (class(object)[2] == "matrix") NULL else 1,  ...)## S3 method for class 'summary.cfc.tbasis'plot(x, t = 1, ci = 0.95, ...)

Arguments

object

An object of class "cfc.tbasis", usually the result of a call tocfc.tbasis.

MARGIN

Dimensions of cumulative incidence and event-free probability arrays to keep while averaging the remaining dimensions. If thecfc.tbasis object is a matrix, no averaging is performed, and the function returns the object unchanged. Note that for list objects,MARGIN must include1 since it is meaningless to average out the time/probability dimension (which is always the first one).

x

An object of class "summary.cfc.tbasis", usually the result of a call tosummary.cfc.tbasis.

t

Regular time step, or vector of time values, used for producing cumulative incidence and event-free probability plots.

ci

Confidence interval used in cumulative incidence and event-free probability plots.

...

Further arguments to be passed to/from other methods.

Value

The functionsummary.cfc.tbasis calculates the average of cumulative incidence and event-free probability functions as directed byMARGIN. For example, if the elementci1 of the object list is three-dimensional, then usingMARGIN=c(1,2) causes the last dimension to be averaged out.

Author(s)

Alireza S. Mahani, Mansour T.A. Sharabiani

References

Mahani A.S. and Sharabiani M.T.A. (2019). Bayesian, and Non-Bayesian, Cause-Specific Competing-Risk Analysis for Parametric and Nonparametric Survival Functions: The R Package CFC. Journal of Statistical Software, 89(9), 1-29. doi:10.18637/jss.v089.i09

See Also

The model fitting function iscfc.tbasis. Seesummary andplot for descriptions of the generic methods. Seecfc.pbasis for probability-denominated CFC, as well as usage examples.


[8]ページ先頭

©2009-2025 Movatter.jp