View source: R/TTTE_Analytical.R
TTTE_Analytical | R Documentation |
This function allows to compute the TTT curve from a formula containing a factor type variable (classification variable).
TTTE_Analytical( formula, response = NULL, scaled = TRUE, data = NULL, method = c("Barlow", "censored"), partition_method = NULL, silent = FALSE, ... )
formula |
an object of class |
response |
an optional numeric vector with data of the response variable.
Using this argument is equivalent to define a formula with the
right side such as |
scaled |
logical. If |
data |
an optional data frame containing the variables (response and the
factor, if it is desired). If data is not specified, the variables
are taken from the environment from which |
method |
a character specifying the method of computation. There are two
options available: |
partition_method |
a list specifying cluster formation when the covariate in
|
silent |
logical. If TRUE, warnings of |
... |
further arguments passing to |
When method
argument is set as 'Barlow'
, this function
uses the original expression of empirical TTT presented by
\insertCiteBarlow1979;textualEstimationTools and used by
\insertCiteAarset1987;textualEstimationTools:
φ_n≤ft( \frac{r}{n}\right) = \frac{≤ft( ∑_{i=1}^{r} T_{(i)} \right) + (n-r)T_{(r)}}{∑_{i=1}^{n} T_i}
where T_(r) is the rth order statistic, with
r=1,2,…, n, and n is the sample size. On the other hand, the option
'censored' is an implementation based on integrals presented in
\insertCiteWestberg1994;textualEstimationTools, and using
survfit
to compute the Kaplan-Meier estimator:
φ_n≤ft( \frac{r}{n}\right) = ∑_{j=1}^{r} ≤ft[ ∏_{i=1}^{j} ≤ft( 1 - \frac{d_i}{n_i}\right) \right] ≤ft(T_{(j)} - T_{(j-1)} \right)
A list with class object Empirical.TTT
containing a list with the
following information:
i/n' |
A matrix containing the empirical quantiles. This matrix has the number of columns equals to the number of levels of the factor considered (number of strata). |
phi_n |
A matrix containing the values of empirical TTT. his matrix has the number of columns equals to the number of levels of the factor considered (number of strata). |
strata |
A numeric named vector storing the number of observations per strata, and the name of each strata (names of the levels of the factor). |
Jaime Mosquera Gutiérrez, jmosquerag@unal.edu.co
Barlow1979EstimationTools
\insertRefAarset1987EstimationTools
\insertRefKlefsjo1991EstimationTools
\insertRefWestberg1994EstimationTools
plot.EmpiricalTTT
library(EstimationTools) #-------------------------------------------------------------------------------- # Example 1: Scaled empirical TTT from 'mgus1' data from 'survival' package. TTT_1 <- TTTE_Analytical(Surv(stop, event == 'pcm') ~1, method = 'cens', data = mgus1, subset=(start == 0)) head(TTT_1$`i/n`) head(TTT_1$phi_n) print(TTT_1$strata) #-------------------------------------------------------------------------------- # Example 2: Scaled empirical TTT using a factor variable with 'aml' data # from 'survival' package. TTT_2 <- TTTE_Analytical(Surv(time, status) ~ x, method = "cens", data = aml) head(TTT_2$`i/n`) head(TTT_2$phi_n) print(TTT_2$strata) #-------------------------------------------------------------------------------- # Example 3: Non-scaled empirical TTT without a factor (arbitrarily simulated # data). set.seed(911211) y <- rweibull(n=20, shape=1, scale=pi) TTT_3 <- TTTE_Analytical(y ~ 1, scaled = FALSE) head(TTT_3$`i/n`) head(TTT_3$phi_n) print(TTT_3$strata) #-------------------------------------------------------------------------------- # Example 4: non-scaled empirical TTT without a factor (arbitrarily simulated # data) using the 'response' argument (this is equivalent to Third example). set.seed(911211) y <- rweibull(n=20, shape=1, scale=pi) TTT_4 <- TTTE_Analytical(response = y, scaled = FALSE) head(TTT_4$`i/n`) head(TTT_4$phi_n) print(TTT_4$strata) #-------------------------------------------------------------------------------- # Eample 5: empirical TTT with a continuously variant term for the shape # parameter in Weibull distribution. x <- runif(50, 0, 10) shape <- 0.1 + 0.1*x y <- rweibull(n = 50, shape = shape, scale = pi) partitions <- list(method='quantile-based', folds=5) TTT_5 <- TTTE_Analytical(y ~ x, partition_method = partitions) head(TTT_5$`i/n`) head(TTT_5$phi_n) print(TTT_5$strata) plot(TTT_5) # Observe changes in Empirical TTT #--------------------------------------------------------------------------------
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.