| Title: | Fuzzy Survival Analysis with Vague Event Times and Fuzzy Censoring |
|---|---|
| Description: | Fuzzy survival analysis for data in which event times and/or failure indicators are vague, for instance when a failure is only known to have occurred during the second quarter of a year, or when it is uncertain whether a subject lost to follow-up had in fact failed. Vague information is represented by fuzzy numbers. The package provides a fuzzy product-limit estimator obtained from nested alpha-cuts of the fuzzy survival function, a fuzzy Cox proportional hazards model with fuzzy coefficient and hazard ratio estimates, and a fuzzy log-rank test. Type-reduction utilities for summarizing fuzzy estimates by single numbers, a simulation engine for validation studies, plotting, print and summary methods, and alpha-cut based confidence bands are provided. The bounds are computed at the alpha-cuts of the fuzzy event times, so the alpha-cut intervals returned for the survival function, the regression coefficients and the test statistic are nested by construction. |
| Authors: | Mukul Bijalwan [aut, cre] (ORCID: <https://orcid.org/0009-0001-3040-6912>), Gunjan Aggrwal [aut], Mukul Jain [aut] |
| Maintainer: | Mukul Bijalwan <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.1.0 |
| Built: | 2026-10-15 20:42:25 UTC |
| Source: | https://github.com/cran/fuzzySurvival |
alpha_cuts() evaluates the nested alpha-cuts, support() and core()
return the 0-cut and the 1-cut, and membership() recovers the membership
function from the alpha-cut function.
alpha_cuts(x, level = c(0, 0.25, 0.5, 0.75, 1)) support(f) core(f) membership(x, at, by = 0.001)alpha_cuts(x, level = c(0, 0.25, 0.5, 0.75, 1)) support(f) core(f) membership(x, at, by = 0.001)
x, f
|
A |
level |
Alpha level(s) at which to evaluate the cut, in |
at |
Points at which to evaluate the membership function. |
by |
Spacing of the level grid used by |
membership() works by inverting the alpha-cut function: for a value s
the membership is the highest level at which s still lies inside the
alpha-cut, i.e. . Because the cut family is nested this is the usual
definition, computed on a grid of 1/by levels.
alpha_cuts() and support() / core() return data frames with
columns id, level, lower, upper; membership() returns an n by
length(at) matrix.
fn <- fuzzy_number_trapezoid(3, 5, 7, 9) alpha_cuts(fn, c(0, 0.25, 1)) support(fn) membership(fn, c(2, 4, 6, 8, 10))fn <- fuzzy_number_trapezoid(3, 5, 7, 9) alpha_cuts(fn, c(0, 0.25, 1)) support(fn) membership(fn, c(2, 4, 6, 8, 10))
Turns a fuzzy number into a numeric vector, e.g. to hand over to the
functions of survival, or to compare the fuzzy estimators with their crisp
counterparts.
as_crisp(f, level = 1, method = c("midpoint", "lower", "upper"))as_crisp(f, level = 1, method = c("midpoint", "lower", "upper"))
f |
A |
level |
Alpha level of the representative. |
method |
|
A numeric vector with the same length as f.
as_crisp(fuzzy_number_trapezoid(3, 5, 7, 9)) as_crisp(fuzzy_number_trapezoid(3, 5, 7, 9), level = 1, method = "lower")as_crisp(fuzzy_number_trapezoid(3, 5, 7, 9)) as_crisp(fuzzy_number_trapezoid(3, 5, 7, 9), level = 1, method = "lower")
fuzzy_number, unwrapping data frame columnsA fuzzy_number placed in a data frame becomes a list column holding one
object, so that the columns of every subject stay together. This helper
accepts either a fuzzy_number or such a list column and always returns a
fuzzy_number, which is what the user-facing functions call internally.
as_fuzzy_number(x)as_fuzzy_number(x)
x |
A |
A fuzzy_number.
d <- data.frame(t = I(list(fuzzy_number_interval(4, 6)))) d$t alpha_cuts(d$t, 1) is_crisp(d$t)d <- data.frame(t = I(list(fuzzy_number_interval(4, 6)))) d$t alpha_cuts(d$t, 1) is_crisp(d$t)
Combine fuzzy numbers
## S3 method for class 'fuzzy_number' c(...)## S3 method for class 'fuzzy_number' c(...)
... |
|
A fuzzy_number of length max(length(...)).
c(fuzzy_number_triangle(1, 2, 3), fuzzy_number_crisp(5))c(fuzzy_number_triangle(1, 2, 3), fuzzy_number_crisp(5))
A fuzzy number carries a whole family of alpha-cuts; to obtain a single
crisp value a defuzzification (type reduction) rule is needed. All the
rules implemented here are the classical type-reduction rules of fuzzy set
theory, written on the level-valued-set (alpha-cut) representation used by
the package. Writing for the alpha-cut at level
, for its middle and
for the width of the level strip:
defuzz( x, method = c("midrange", "centroid", "gmirl", "sgmrl", "ms", "msm", "yager", "min", "max"), level = 0.5, by = 0.001, ... )defuzz( x, method = c("midrange", "centroid", "gmirl", "sgmrl", "ms", "msm", "yager", "min", "max"), level = 0.5, by = 0.001, ... )
x |
A |
method |
Defuzzification rule; see Details. A vector of rules returns one row per rule. |
level |
Alpha level, only used by |
by |
Spacing of the level grid used for the integrals. |
... |
Further arguments, such as |
midranges(alpha), the middle of the alpha-cut at level alpha
(mean of range).
centroid, the centre of gravity of the membership function.
gmirlgraded mean integration representation level,
.
sgmrlsimplified graded mean,
.
mssmallest element of the supremum cut, .
msmsmallest mean of the supremum, .
yagerYager's ranking; for a continuous membership function it
reduces to the middle of the core, .
min, max
the smallest and largest element of the support.
For a symmetric fuzzy number the centroid, gmirl, sgmrl, yager and
midrange rules all return its centre of symmetry, and min/max its
symmetric end points, which makes the rules easy to check.
Passing several rules at once returns one row per rule, which is a quick way of comparing the type reductions on the same fuzzy number.
A numeric vector with one value per fuzzy number, or a matrix with
one row per requested rule when method has length greater than one.
fuzzy_spread(), fkm_fuzzy_surv()
fn <- fuzzy_number_trapezoid(3, 5, 7, 9) defuzz(fn, "centroid") defuzz(fn, "midrange", level = 0.5) # a symmetric fuzzy number: every centred rule gives 5 defuzz(fuzzy_number_triangle(2, 5, 8), c("centroid", "gmirl", "sgmrl"))fn <- fuzzy_number_trapezoid(3, 5, 7, 9) defuzz(fn, "centroid") defuzz(fn, "midrange", level = 0.5) # a symmetric fuzzy number: every centred rule gives 5 defuzz(fuzzy_number_triangle(2, 5, 8), c("centroid", "gmirl", "sgmrl"))
Defuzzification of fuzzy Cox coefficients
defuzz.fcox( x, method = c("midrange", "centroid", "gmirl", "sgmrl", "ms", "msm", "yager", "min", "max"), level = 0.5, by = 0.001, conf.int = 0.95, exponentiate = FALSE )defuzz.fcox( x, method = c("midrange", "centroid", "gmirl", "sgmrl", "ms", "msm", "yager", "min", "max"), level = 0.5, by = 0.001, conf.int = 0.95, exponentiate = FALSE )
x |
A |
method |
Defuzzification rule; see Details. A vector of rules returns one row per rule. |
level |
Alpha level, only used by |
by |
Spacing of the level grid used for the integrals. |
conf.int |
Confidence level of the (fuzzy) confidence interval. |
exponentiate |
Return defuzzified hazard ratios instead of coefficients. |
A data frame with the point estimate and the fuzzy interval.
data(fuzzy_dfs) fit <- fcox(fuzzy_surv(ft, fs) ~ age + arm, data = fuzzy_dfs) defuzz(fit, "centroid", exponentiate = TRUE)data(fuzzy_dfs) fit <- fcox(fuzzy_surv(ft, fs) ~ age + arm, data = fuzzy_dfs) defuzz(fit, "centroid", exponentiate = TRUE)
fkm fitDefuzzification of an fkm fit
defuzz.fkm( x, method = c("midrange", "centroid", "gmirl", "sgmrl", "ms", "msm", "yager", "min", "max"), level = 0.5, by = 0.001, times = NULL )defuzz.fkm( x, method = c("midrange", "centroid", "gmirl", "sgmrl", "ms", "msm", "yager", "min", "max"), level = 0.5, by = 0.001, times = NULL )
x |
An |
method |
Defuzzification rule; see Details. A vector of rules returns one row per rule. |
level |
Alpha level, only used by |
by |
Spacing of the level grid used for the integrals. |
times |
Times at which the survival probability is evaluated; defaults to the distinct times of the fit. |
A numeric vector with one value per requested time.
data(fuzzy_dfs) fit <- fkm(fuzzy_surv(ft, fs) ~ 1, data = fuzzy_dfs) defuzz(fit, "centroid", times = c(6, 12, 24))data(fuzzy_dfs) fit <- fkm(fuzzy_surv(ft, fs) ~ 1, data = fuzzy_dfs) defuzz(fit, "centroid", times = c(6, 12, 24))
exp() is increasing, so the alpha-cuts are mapped end point by end point.
## S3 method for class 'fuzzy_number' exp(x)## S3 method for class 'fuzzy_number' exp(x)
x |
A |
A fuzzy_number.
exp(fuzzy_number_trapezoid(-1, 0, 1, 2))exp(fuzzy_number_trapezoid(-1, 0, 1, 2))
A Cox model for vague event times. At each alpha level the model is fitted
with survival::coxph() to the lower and to the upper end of the time cuts,
and the two fits bound the regression coefficients. The alpha-cut of the
coefficient of a covariate is
where the cumulative min/max over the levels up to is what
makes the intervals nested, so the result is a fuzzy number rather than a
family of unrelated intervals. Hazard ratios are obtained by exponentiating
the fuzzy coefficients (an increasing, hence membership-preserving map).
fcox( formula, data, time, status, covariates = NULL, levels = NULL, ties = "efron", ... ) ## S3 method for class 'formula' fcox( formula, data, time, status, covariates = NULL, levels = NULL, ties = "efron", ... ) ## Default S3 method: fcox( formula, data, time, status, covariates = NULL, levels = NULL, ties = "efron", ... )fcox( formula, data, time, status, covariates = NULL, levels = NULL, ties = "efron", ... ) ## S3 method for class 'formula' fcox( formula, data, time, status, covariates = NULL, levels = NULL, ties = "efron", ... ) ## Default S3 method: fcox( formula, data, time, status, covariates = NULL, levels = NULL, ties = "efron", ... )
formula |
A model formula such as |
data |
A data frame containing the variables of |
time, status
|
Accepted instead of |
covariates |
A data frame or matrix of covariates, used instead of the
right hand side of |
levels |
Alpha levels at which the model is fitted. |
ties, ...
|
Passed to |
Confidence intervals combine the fuzzy coefficient with the standard error of the crisp (level 1) fit, and the p-values are the smallest and largest values attainable given the fuzzy coefficient and that standard error.
An object of class fcox, a list with components
beta |
a |
se |
standard errors of the level 1 fit, |
var |
variance of the level 1 fit, |
fit |
the crisp |
p.value |
a |
data(fuzzy_dfs) fit <- fcox(fuzzy_surv(ft, fs) ~ age + arm, data = fuzzy_dfs) summary(fit) defuzz(fit, "centroid", exponentiate = TRUE)data(fuzzy_dfs) fit <- fcox(fuzzy_surv(ft, fs) ~ age + arm, data = fuzzy_dfs) summary(fit) defuzz(fit, "centroid", exponentiate = TRUE)
The fuzzy Kaplan-Meier estimator of the survival function for vague event times and/or vague failure indicators.
fkm( formula, data, time, status, group = NULL, levels = NULL, conf.type = c("log", "log-log", "plain"), conf.int = 0.95, ... ) ## S3 method for class 'formula' fkm( formula, data, time, status, group = NULL, levels = NULL, conf.type = c("log", "log-log", "plain"), conf.int = 0.95, ... ) ## Default S3 method: fkm( formula, data, time, status, group = NULL, levels = NULL, conf.type = c("log", "log-log", "plain"), conf.int = 0.95, ... )fkm( formula, data, time, status, group = NULL, levels = NULL, conf.type = c("log", "log-log", "plain"), conf.int = 0.95, ... ) ## S3 method for class 'formula' fkm( formula, data, time, status, group = NULL, levels = NULL, conf.type = c("log", "log-log", "plain"), conf.int = 0.95, ... ) ## Default S3 method: fkm( formula, data, time, status, group = NULL, levels = NULL, conf.type = c("log", "log-log", "plain"), conf.int = 0.95, ... )
formula |
A model formula, e.g. |
data |
A data frame containing the variables of |
time, status
|
Accepted as an alternative to |
group |
Optional grouping variable; fits a separate curve per level. |
levels |
Alpha levels at which the bounds are evaluated. Level 0 (the support, i.e. the completely vague case) and level 1 (the core, i.e. the fully plausible case) are always included. |
conf.type |
Transformation used for the confidence bands of the two
bounds, as in |
conf.int |
Confidence level of the bands. |
... |
Further arguments passed to |
An object of class fkm, a list with, among others, the components
time |
the distinct times at which the curves are evaluated. |
lower, upper
|
matrices of the lower and upper survival bounds, one row per alpha level. |
levels |
the alpha levels of those rows. |
surv |
the defuzzified curve (see |
n.risk, n.event
|
numbers at risk and of events. |
Let be the fuzzy event time of subject . For an
alpha level the set of data compatible with "the true times have
membership at least " is
.
Replacing every vague time by the lower end of its alpha-cut makes the
failures happen as early as possible, so the resulting Kaplan-Meier curve
is the lower bound of the survival function, and the
upper end gives the upper bound . The alpha-cut of
the fuzzy survival function is then
Because the time cuts are nested, the risk sets of
shrink as grows, hence is
non-decreasing and non-increasing in : the
reported intervals are nested alpha-cuts of a proper fuzzy number, and they
collapse onto the classical Kaplan-Meier curve when the data are crisp.
Vague failure indicators are handled by the fractional estimator: a subject
with degree of belief that the event occurred contributes a
fractional number of events , which reduces exactly to the
classical estimator when all are 0 or 1.
fkm_fuzzy_surv(), fcox(), flogrank()
data(fuzzy_dfs) # overall fuzzy Kaplan-Meier curve fit <- fkm(fuzzy_surv(ft, fs) ~ 1, data = fuzzy_dfs) summary(fit, times = c(6, 12, 24)) # a defuzzified curve, and the alpha-cut bounds plot(fit) defuzz(fit, "centroid", times = 12) # by treatment arm fit2 <- fkm(fuzzy_surv(ft, fs) ~ arm, data = fuzzy_dfs) plot(fit2, type = "diff")data(fuzzy_dfs) # overall fuzzy Kaplan-Meier curve fit <- fkm(fuzzy_surv(ft, fs) ~ 1, data = fuzzy_dfs) summary(fit, times = c(6, 12, 24)) # a defuzzified curve, and the alpha-cut bounds plot(fit) defuzz(fit, "centroid", times = 12) # by treatment arm fit2 <- fkm(fuzzy_surv(ft, fs) ~ arm, data = fuzzy_dfs) plot(fit2, type = "diff")
Turns the fuzzy survival curve of an fkm() fit into a vector of fuzzy
numbers, one per requested time, so that defuzz(), alpha_cuts() and
membership() can be applied to the survival probability itself.
fkm_fuzzy_surv(x, times = NULL)fkm_fuzzy_surv(x, times = NULL)
x |
An |
times |
Times at which the survival probability is evaluated. Defaults to the distinct times of the fit. |
A fuzzy_number whose alpha-cut at level alpha is
[S^-_alpha(t), S^+_alpha(t)].
data(fuzzy_dfs) fit <- fkm(fuzzy_surv(ft, fs) ~ 1, data = fuzzy_dfs) s <- fkm_fuzzy_surv(fit, times = c(6, 12, 24)) alpha_cuts(s, c(0, 0.5, 1)) membership(s, 0.6)data(fuzzy_dfs) fit <- fkm(fuzzy_surv(ft, fs) ~ 1, data = fuzzy_dfs) s <- fkm_fuzzy_surv(fit, times = c(6, 12, 24)) alpha_cuts(s, c(0, 0.5, 1)) membership(s, 0.6)
The log-rank statistic is computed on the lower and on the upper end of the time cuts at each alpha level, giving a fuzzy chi-square statistic and hence a fuzzy p-value. When the data are crisp the bounds coincide with the classical log-rank test.
flogrank(formula, data, time, status, group = NULL, levels = NULL, ...)flogrank(formula, data, time, status, group = NULL, levels = NULL, ...)
formula |
A model formula |
data |
A data frame containing the variables of |
time, status, group
|
Accepted instead of |
levels |
Alpha levels at which the statistic is evaluated. |
... |
Further arguments, ignored. |
An object of class flogrank, a list with the fuzzy statistic
statistic, the fuzzy p-value p.value, the crisp level 1 fit fit and
the observed and expected number of events per group.
data(fuzzy_dfs) fit <- flogrank(fuzzy_surv(ft, fs) ~ arm, data = fuzzy_dfs) fit defuzz(fit$p.value, "centroid")data(fuzzy_dfs) fit <- flogrank(fuzzy_surv(ft, fs) ~ arm, data = fuzzy_dfs) fit defuzz(fit$p.value, "centroid")
A synthetic example dataset of 240 subjects with a treatment arm, age and
sex, generated by sim_fuzzy_surv() with quarterly examinations. Use it to
see the whole workflow: fkm(), fcox() and flogrank().
fuzzy_dfsfuzzy_dfs
A data frame with 240 rows and the following columns:
idsubject identifier.
ageage in years.
armtreatment arm, "Treated" or "Control".
sex"Male" or "Female".
ftfuzzy event time: an interval fuzzy number when the failure was only known to occur between two examinations, a crisp fuzzy number otherwise.
fsfailure indicator, strictly between 0 and 1 when the status of a censored record is uncertain.
true_time, true_status, observed
the unobserved quantities used to generate the fuzzy ones, useful for checking coverage.
sim_fuzzy_surv(), fkm(), fcox()
data(fuzzy_dfs) str(fuzzy_dfs) fit <- fkm(fuzzy_surv(ft, fs) ~ arm, data = fuzzy_dfs) plot(fit, type = "diff")data(fuzzy_dfs) str(fuzzy_dfs) fit <- fkm(fuzzy_surv(ft, fs) ~ arm, data = fuzzy_dfs) plot(fit, type = "diff")
A fuzzy number is a fuzzy set on the real line described by its nested alpha-cuts
where is non-decreasing and is
non-increasing in , is the support and is
the core. Every object of class fuzzy_number stores such an alpha-cut
function; the membership function is recovered numerically from it, so that
both representations are always consistent.
fuzzy_number_trapezoid(l, cl, cr, r, label = NULL) fuzzy_number_triangle(a, m, b, label = NULL) fuzzy_number_interval(lo, hi, label = NULL) fuzzy_number_crisp(x, label = NULL) fuzzy_number_from_acut(acut, support = NULL, label = NULL)fuzzy_number_trapezoid(l, cl, cr, r, label = NULL) fuzzy_number_triangle(a, m, b, label = NULL) fuzzy_number_interval(lo, hi, label = NULL) fuzzy_number_crisp(x, label = NULL) fuzzy_number_from_acut(acut, support = NULL, label = NULL)
l, cl, cr, r
|
Left and right end points and core end points of the
trapezoid; must satisfy |
label |
Optional character label (e.g. a variable name). |
a, m, b
|
Left end point, mode and right end point of a triangle. |
lo, hi
|
End points of a flat (crisp-valued on the interval) fuzzy number. |
x |
Values of crisp fuzzy numbers. |
acut |
Function of a vector of alpha levels returning a list with
matrices |
support |
Optional |
The package uses fuzzy numbers for two kinds of vague information in survival data: vague (interval-like) event times such as "the failure occurred in the second quarter of the year", and vague failure indicators such as "lost to follow-up, possibly with an unobserved failure".
An object of class fuzzy_number: a list with components
acut (alpha-cut function), support (n by 2), label and n.
fuzzy_number_trapezoid()trapezoidal, (l, cl, cr, r).
fuzzy_number_triangle()triangular, a special case.
fuzzy_number_interval()flat core: the value is plausible to degree one on the whole interval (a "vague period").
fuzzy_number_crisp()a point mass; a degenerate fuzzy number.
A crisp vector is accepted wherever a fuzzy number is expected and is
promoted with fuzzy_number_crisp(), so a fuzzy estimator reproduces the
classical one exactly on crisp data.
alpha_cuts(), membership(), defuzz(), fkm(), fcox()
# "the failure occurred in the second quarter" (months 4 to 6) q2 <- fuzzy_number_interval(4, 6) alpha_cuts(q2, c(0, 0.5, 1)) # a rounded vague time: certainly between 3 and 9, surely at 5-7 fuzzy_number_trapezoid(3, 5, 7, 9) # membership functions fuzzy_number_triangle(0, 1, 2)# "the failure occurred in the second quarter" (months 4 to 6) q2 <- fuzzy_number_interval(4, 6) alpha_cuts(q2, c(0, 0.5, 1)) # a rounded vague time: certainly between 3 and 9, surely at 5-7 fuzzy_number_trapezoid(3, 5, 7, 9) # membership functions fuzzy_number_triangle(0, 1, 2)
Width (diffusion) of fuzzy numbers
fuzzy_spread(f, level = 0)fuzzy_spread(f, level = 0)
f |
A |
level |
Alpha level(s). |
Numeric vector or matrix of widths f^+_alpha - f^-_alpha.
fuzzy_spread(fuzzy_number_triangle(1, 2, 3), c(0, 0.5, 1))fuzzy_spread(fuzzy_number_triangle(1, 2, 3), c(0, 0.5, 1))
fuzzy_surv() is the fuzzySurvival analogue of survival::Surv(): it
bundles a vector of (possibly fuzzy) times with a vector of failure
indicators, so that the estimators can be used inside model formulas.
fuzzy_surv(time, status, ...)fuzzy_surv(time, status, ...)
time |
A |
status |
Numeric vector of failure indicators. Values in |
... |
Additional components stored in the result, e.g. a grouping or stratification variable. |
The failure indicator may itself be vague. A numeric status in [0, 1]
is read as a degree of belief that the subject failed, and subjects whose
indicator is strictly between 0 and 1 are handled by the fractional
Kaplan-Meier estimator (they enter the risk set with a fractional weight).
This models records such as "lost to follow-up, last seen alive, but an
unobserved event cannot be excluded".
An object of class fuzzy_surv, a list with components time
(a fuzzy_number), status (numeric) and n.
# crisp times fuzzy_surv(c(2, 5, 7, 9), c(1, 0, 1, 1)) # vague event times: "failed during the second quarter" for subject 2 tm <- fuzzy_number_crisp(c(2, 6, 9)) tm[2] <- fuzzy_number_interval(4, 6) fuzzy_surv(tm, c(1, 1, 1)) # vague censoring: subject 2 failed with degree of belief 0.5 fuzzy_surv(c(2, 5, 7, 9), c(1, 0.5, 1, 1))# crisp times fuzzy_surv(c(2, 5, 7, 9), c(1, 0, 1, 1)) # vague event times: "failed during the second quarter" for subject 2 tm <- fuzzy_number_crisp(c(2, 6, 9)) tm[2] <- fuzzy_number_interval(4, 6) fuzzy_surv(tm, c(1, 1, 1)) # vague censoring: subject 2 failed with degree of belief 0.5 fuzzy_surv(c(2, 5, 7, 9), c(1, 0.5, 1, 1))
Point-wise extension of the arithmetic operations through the alpha-cut
representation (Zadeh's extension principle), evaluated on a grid of
1/by levels. Division is only defined for cuts that do not contain zero.
## S3 method for class 'fuzzy_number' Ops(e1, e2)## S3 method for class 'fuzzy_number' Ops(e1, e2)
e1, e2
|
|
A fuzzy_number of the common length.
x <- fuzzy_number_trapezoid(1, 2, 3, 4) x + 10 x * xx <- fuzzy_number_trapezoid(1, 2, 3, 4) x + 10 x * x
Is a fuzzy number crisp?
is_crisp(f, tol = 1e-08)is_crisp(f, tol = 1e-08)
f |
A |
tol |
Tolerance for comparing the end points of the alpha-cuts. |
A logical vector of length length(f).
is_crisp(c(fuzzy_number_crisp(3), fuzzy_number_interval(1, 2)))is_crisp(c(fuzzy_number_crisp(3), fuzzy_number_interval(1, 2)))
Test whether an object is a fuzzy number
is_fuzzy_number(x) is.fuzzy_number(x)is_fuzzy_number(x) is.fuzzy_number(x)
x |
Any object. |
TRUE if x inherits from fuzzy_number.
is.fuzzy_number(fuzzy_number_triangle(1, 2, 3)) is.fuzzy_number(1:3)is.fuzzy_number(fuzzy_number_triangle(1, 2, 3)) is.fuzzy_number(1:3)
Draws the alpha-cut bounds of the fuzzy survival function. With
type = "diff" the fuzzy difference of two groups' curves is drawn
instead, the fuzzy counterpart of a survival difference plot.
## S3 method for class 'fkm' plot( x, type = c("surv", "diff", "table"), levels = c(0, 0.25, 0.5, 0.75, 1), cols = c("#2166AC", "#B2182B"), fill = 80, xlab = "Time", ylab = "Survival probability", main = "Fuzzy Kaplan-Meier estimate", lty = 1, legend = TRUE, times = NULL, ... )## S3 method for class 'fkm' plot( x, type = c("surv", "diff", "table"), levels = c(0, 0.25, 0.5, 0.75, 1), cols = c("#2166AC", "#B2182B"), fill = 80, xlab = "Time", ylab = "Survival probability", main = "Fuzzy Kaplan-Meier estimate", lty = 1, legend = TRUE, times = NULL, ... )
x |
An |
type |
|
levels |
Alpha levels whose bounds are drawn. |
cols |
Colours for the lower and upper bound. |
fill |
Alpha transparency of the shaded region between the bounds. |
xlab, ylab, main
|
Axis labels and title. |
lty |
Line type of the defuzzified curve. |
legend |
Whether to draw a legend. |
times |
Times at which the difference is evaluated. |
... |
Further graphical parameters. |
NULL invisibly; called for the side effect.
data(fuzzy_dfs) fit <- fkm(fuzzy_surv(ft, fs) ~ 1, data = fuzzy_dfs) plot(fit) fit2 <- fkm(fuzzy_surv(ft, fs) ~ arm, data = fuzzy_dfs) plot(fit2, type = "diff")data(fuzzy_dfs) fit <- fkm(fuzzy_surv(ft, fs) ~ 1, data = fuzzy_dfs) plot(fit) fit2 <- fkm(fuzzy_surv(ft, fs) ~ arm, data = fuzzy_dfs) plot(fit2, type = "diff")
Plot the membership function of fuzzy numbers
## S3 method for class 'fuzzy_number' plot( x, y, n = 20, main = "Membership function", xlab = "Value", ylab = "Membership", ... )## S3 method for class 'fuzzy_number' plot( x, y, n = 20, main = "Membership function", xlab = "Value", ylab = "Membership", ... )
x |
A |
y |
Unused, for compatibility with the generic. |
n |
Maximum number of fuzzy numbers to draw. |
main, xlab, ylab
|
Plot labels. |
... |
Further graphical parameters. |
NULL invisibly; called for the side effect.
plot(c(fuzzy_number_trapezoid(0, 1, 2, 4), fuzzy_number_interval(5, 6)))plot(c(fuzzy_number_trapezoid(0, 1, 2, 4), fuzzy_number_interval(5, 6)))
Generates true event times from a Weibull model, applies censoring, and then coarsens the information the way a real record does: the failure is only known to have occurred between two examinations, and a fraction of the censored records carries an uncertain failure status.
sim_fuzzy_surv( n = 200, beta = c(age = 0.3, arm = -0.6), mu = log(24), sigma = 0.6, shape = 1.4, cov_mean = 0, cov_sd = 1, censor_max = NULL, censor_rate = 1/40, exam_every = 3, prop_vague = 0.6, prop_uncertain = 0.2, seed = NULL )sim_fuzzy_surv( n = 200, beta = c(age = 0.3, arm = -0.6), mu = log(24), sigma = 0.6, shape = 1.4, cov_mean = 0, cov_sd = 1, censor_max = NULL, censor_rate = 1/40, exam_every = 3, prop_vague = 0.6, prop_uncertain = 0.2, seed = NULL )
n |
Number of subjects. |
beta |
Named vector of log hazard ratios, one per covariate column. |
mu, sigma, shape
|
Weibull parameters: |
cov_mean, cov_sd
|
Mean and standard deviation of the covariates; a
two-level covariate (a treatment arm) is created when any name of |
censor_max, censor_rate
|
Censoring: a uniform cut-off on |
exam_every |
Spacing of the examinations, in time units. A failure between two examinations is reported as a vague time spanning them. |
prop_vague |
Proportion of the failures that are reported as vague (interval) times rather than exact ones. |
prop_uncertain |
Proportion of the censored records whose failure
status is uncertain; their degree of belief is drawn uniformly on
|
seed |
Optional seed for reproducibility. |
The true times and statuses are returned alongside the fuzzy ones, so that the coverage of the fuzzy estimators can be checked directly.
A data frame with the covariates, the fuzzy time column ft, the
fuzzy status column fs, and the true_time/true_status used to
generate them.
set.seed(1) d <- sim_fuzzy_surv(n = 60, beta = c(age = 0.4, arm = -0.5)) head(d[, c("arm", "fs")]) fit <- fkm(fuzzy_surv(ft, fs) ~ arm, data = d) plot(fit, type = "diff")set.seed(1) d <- sim_fuzzy_surv(n = 60, beta = c(age = 0.4, arm = -0.5)) head(d[, c("arm", "fs")]) fit <- fkm(fuzzy_surv(ft, fs) ~ arm, data = d) plot(fit, type = "diff")
Summaries and plots of a fuzzy Cox fit
## S3 method for class 'fcox' summary( object, conf.int = 0.95, exponentiate = FALSE, digits = 4, method = "centroid", ... ) ## S3 method for class 'fcox' print(x, conf.int = 0.95, ...) ## S3 method for class 'fcox' coef(object, exponentiate = FALSE, ...) ## S3 method for class 'fcox' plot( x, type = c("hr", "membership"), conf.int = 0.95, xlab = "Hazard ratio", main = "Fuzzy Cox model", legend = TRUE, ... )## S3 method for class 'fcox' summary( object, conf.int = 0.95, exponentiate = FALSE, digits = 4, method = "centroid", ... ) ## S3 method for class 'fcox' print(x, conf.int = 0.95, ...) ## S3 method for class 'fcox' coef(object, exponentiate = FALSE, ...) ## S3 method for class 'fcox' plot( x, type = c("hr", "membership"), conf.int = 0.95, xlab = "Hazard ratio", main = "Fuzzy Cox model", legend = TRUE, ... )
object |
A |
conf.int |
Confidence level of the reported intervals. |
exponentiate |
Report hazard ratios instead of coefficients. |
digits |
Number of significant digits. |
method |
Defuzzification rule, see |
... |
Further arguments, ignored by |
x |
A |
type |
Either |
xlab, main, legend
|
Plot labels, and whether to draw a legend. |
summary() returns a list with the coefficient table and the
number of subjects and events; the plot method returns NULL invisibly.
data(fuzzy_dfs) fit <- fcox(fuzzy_surv(ft, fs) ~ age + arm, data = fuzzy_dfs) summary(fit) plot(fit)data(fuzzy_dfs) fit <- fcox(fuzzy_surv(ft, fs) ~ age + arm, data = fuzzy_dfs) summary(fit) plot(fit)
Summaries of a fuzzy Kaplan-Meier fit
## S3 method for class 'fkm' summary( object, times = NULL, digits = 4, method = "centroid", conf.int = 0.95, alpha = 0, ... ) ## S3 method for class 'fkm_summary' print(x, ...)## S3 method for class 'fkm' summary( object, times = NULL, digits = 4, method = "centroid", conf.int = 0.95, alpha = 0, ... ) ## S3 method for class 'fkm_summary' print(x, ...)
object |
An |
times |
Times at which to report the curves. |
digits |
Number of significant digits. |
method |
Defuzzification rule, see |
conf.int |
Confidence level of the reported bands. |
alpha |
Alpha level of the reported band, |
... |
Further arguments, ignored by |
x |
The data frame returned by |
A data frame with one row per time and columns for the alpha-cut
bounds lower/upper, the defuzzified value surv, the numbers at risk,
of events and censored, and the band on the defuzzified curve.