kcifcurves: k-groups of multiple Cumulative Incidents Functions curves

kcifcurvesR Documentation

k-groups of multiple Cumulative Incidents Functions curves

Description

Function for grouping CIF curves, given a number k, based on the k-means or k-medians algorithm.

Usage

kcifcurves(
  time,
  status = NULL,
  x = NULL,
  max_time = NULL,
  labels = NULL,
  k,
  kbin = 50,
  weights = NULL,
  algorithm = "kmeans",
  bagging = FALSE,
  nsamples = 5,
  seed = NULL
)

Arguments

time

Survival time.

status

Censoring indicator of the survival time of the process; 0 if the total time is censored and 1 otherwise.

x

Categorical variable indicating the population to which the observations belongs.

labels

TODO

k

An integer specifying the number of groups of curves to be performed.

kbin

Size of the grid over which the survival functions are to be estimated.

weights

TODO

algorithm

A character string specifying which clustering algorithm is used, i.e., k-means("kmeans") or k-medians ("kmedians").

bagging

TODO

nsamples

TODO

seed

Seed to be used in the procedure.

Value

A list containing the following items:

measure

Value of the test statistics.

levels

Original levels of the variable x.

cluster

A vector of integers (from 1:k) indicating the cluster to which each curve is allocated.

centers

An object of class survfit containing the centroids (mean of the curves pertaining to the same group).

curves

An object of class survfit containing the survival curves for each population.

Author(s)

Nora M. Villanueva and Marta Sestelo.

Examples

library(clustcurv)
library(survival)
data(veteran)

# Survival: 2 groups k-means
s2 <- ksurvcurves(time = veteran$time, status = veteran$status,
x = veteran$celltype, k = 2, algorithm = "kmeans")

data.frame(level = s2$level, cluster = s2$cluster)


# Survival: 2 groups k-medians
s22 <- ksurvcurves(time = veteran$time, status = veteran$status,
x = veteran$celltype, k = 2, algorithm = "kmedians")

data.frame(level = s22$level, cluster = s22$cluster)





sestelo/clustcurv documentation built on March 18, 2023, 12:11 a.m.