### Usage of Mixture Cure Model Functions Source: https://cran.r-project.org/web/packages/flexsurvcure/refman/flexsurvcure.html Demonstrates the usage of functions for mixture cure models, including density, distribution, hazard, quantile, random generation, and survival time calculations. These functions require base distribution functions and cure fraction parameters. ```R pmixsurv(pfun, q, theta, ...) hmixsurv(dfun, pfun, x, theta, ...) Hmixsurv(pfun, x, theta, ...) dmixsurv(dfun, pfun, x, theta, ...) qmixsurv(qfun, p, theta, ...) rmixsurv(qfun, n, theta, ...) rmst_mixsurv(pfun, t, theta, ...) mean_mixsurv(pfun, theta, ...) ``` -------------------------------- ### Usage of Non-Mixture Cure Model Functions Source: https://cran.r-project.org/web/packages/flexsurvcure/refman/flexsurvcure.html Illustrates the usage of functions for non-mixture cure models, covering density, distribution, hazard, quantile, random generation, and survival time calculations. These functions also require base distribution functions and cure fraction parameters. ```R pnmixsurv(pfun, q, theta, ...) hnmixsurv(dfun, x, theta, ...) Hnmixsurv(pfun, x, theta, ...) dnmixsurv(dfun, pfun, x, theta, ...) qnmixsurv(qfun, p, theta, ...) rnmixsurv(qfun, n, theta, ...) rmst_nmixsurv(pfun, t, theta, ...) mean_nmixsurv(pfun, theta, ...) ``` -------------------------------- ### Generic Non-Mixture Cure Models Source: https://cran.r-project.org/web/packages/flexsurvcure/refman/flexsurvcure.html Provides functions for probability density, distribution, quantile, random generation, hazard, cumulative hazard, mean, and restricted mean for generic non-mixture cure models. These functions operate by taking the corresponding functions of a base distribution as arguments. ```APIDOC ## Non-Mixture Cure Models ### Description Probability density, distribution, quantile, random generation, hazard cumulative hazard, mean, and restricted mean functions for generic non-mixture cure models. These distribution functions take as arguments the corresponding functions of the base distribution used. ### Usage ``` pnmixsurv(pfun, q, theta, ...) hnmixsurv(dfun, x, theta, ...) Hnmixsurv(pfun, x, theta, ...) dnmixsurv(dfun, pfun, x, theta, ...) qnmixsurv(qfun, p, theta, ...) rnmixsurv(qfun, n, theta, ...) rmst_nmixsurv(pfun, t, theta, ...) mean_nmixsurv(pfun, theta, ...) ``` ### Arguments * `pfun`: The base distribution's cumulative distribution function. * `theta`: The estimated cure fraction. * `...`: Parameters to be passed to the pdf or cdf of the base distribution. * `dfun`: The base distribution's probability density function. * `x`, `q`, `t`: Vector of times. * `qfun`: The base distribution's quantile function. * `p`: Vector of probabilities. * `n`: Number of random numbers to simulate. ### Value - `dnmixsurv`: gives the density. - `pnmixsurv`: gives the distribution function. - `hnmixsurv`: gives the hazard. - `Hnmixsurv`: gives the cumulative hazard. - `qnmixsurv`: gives the quantile function, computed by crude numerical inversion. - `rnmixsurv`: generates random survival times by using `qnmixsurv` on a sample of uniform random numbers. It is slow due to numerical root-finding. - `mean_nmixsurv` and `rmst_nmixsurv`: give the mean and restricted mean survival times, respectively. ``` -------------------------------- ### Generic Mixture Cure Models Source: https://cran.r-project.org/web/packages/flexsurvcure/refman/flexsurvcure.html Provides functions for probability density, distribution, quantile, random generation, hazard, cumulative hazard, mean, and restricted mean for generic mixture cure models. These functions operate by taking the corresponding functions of a base distribution as arguments. ```APIDOC ## Mixture Cure Model Functions ### Description Probability density, distribution, quantile, random generation, hazard cumulative hazard, mean, and restricted mean functions for generic mixture cure models. These distribution functions take as arguments the corresponding functions of the base distribution used. ### Usage ``` pmixsurv(pfun, q, theta, ...) hmixsurv(dfun, pfun, x, theta, ...) Hmixsurv(pfun, x, theta, ...) dmixsurv(dfun, pfun, x, theta, ...) qmixsurv(qfun, p, theta, ...) rmixsurv(qfun, n, theta, ...) rmst_mixsurv(pfun, t, theta, ...) mean_mixsurv(pfun, theta, ...) ``` ### Arguments * `pfun`: The base distribution's cumulative distribution function. * `theta`: The estimated cure fraction. * `...`: Additional parameters to be passed to the pdf or cdf of the base distribution. * `dfun`: The base distribution's probability density function. * `x`, `q`, `t`: Vector of times. * `qfun`: The base distribution's quantile function. * `p`: Vector of probabilities. * `n`: Number of random numbers to simulate. ### Value - `dmixsurv`: gives the density. - `pmixsurv`: gives the distribution function. - `hmixsurv`: gives the hazard. - `Hmixsurv`: gives the cumulative hazard. - `qmixsurv`: gives the quantile function, computed by crude numerical inversion. - `rmixsurv`: generates random survival times by using `qmixsurv` on a sample of uniform random numbers. It is slow due to numerical root-finding. - `mean_mixsurv` and `rmst_mixsurv`: give the mean and restricted mean survival times, respectively. ``` -------------------------------- ### Fit Weibull Mixture Cure Model with Log-Log Link Source: https://cran.r-project.org/web/packages/flexsurvcure/refman/flexsurvcure.html Fits a Weibull mixture cure model using a log-log link function for the cure fraction. This demonstrates how to change the link function for modeling the cure fraction, which can influence the estimation of the proportion of cured individuals. ```R flexsurvcure(Surv(rectime,censrec)~group, data=bc, dist="weibull", link="loglog") ``` -------------------------------- ### Fit Mixture Cure Model (Weibull PH) Source: https://cran.r-project.org/web/packages/flexsurvcure/vignettes/flexsurvcure.Rmd Fits a mixture cure model using a Weibull distribution and logistic link for the cure fraction. Requires the flexsurvcure package and bc dataset. ```r library(flexsurvcure) cure_model <- flexsurvcure(Surv(rectime, censrec)~group, data=bc, link="logistic", dist="weibullPH", mixture=T) print(cure_model) ``` -------------------------------- ### Fit Non-Mixture Cure Model (Weibull PH) Source: https://cran.r-project.org/web/packages/flexsurvcure/vignettes/flexsurvcure.Rmd Fits a non-mixture cure model by setting mixture=F in the flexsurvcure function. Uses a log-log link and Weibull PH distribution. ```r library(flexsurvcure) cure_model_nmix <- flexsurvcure(Surv(rectime, censrec)~group, data=bc, link="loglog", dist="weibullPH", mixture=F) print(cure_model_nmix) ``` -------------------------------- ### Predict Survival Probabilities from Mixture Cure Model Source: https://cran.r-project.org/web/packages/flexsurvcure/vignettes/flexsurvcure.Rmd Generates predicted survival probabilities from a fitted mixture cure model using the summary S3 method. Specify time points and tidy=T for a data frame output. ```r summary(cure_model, t=seq(from=0,to=3000,by=1000), type="survival", tidy=T) ``` -------------------------------- ### Plot Mixture Cure Model Results Source: https://cran.r-project.org/web/packages/flexsurvcure/vignettes/flexsurvcure.Rmd Generates a graphical display of the fitted mixture cure model results using the plot S3 method. ```r plot(cure_model) ``` -------------------------------- ### Fit Log-Normal Non-Mixture Cure Model Source: https://cran.r-project.org/web/packages/flexsurvcure/refman/flexsurvcure.html Fits a log-normal non-mixture cure model. This model is used when there is no distinct cured fraction, and the survival probability asymptotically approaches a cure fraction. The 'mixture = FALSE' argument specifies a non-mixture model. ```R flexsurvcure(Surv(rectime,censrec)~group, data=bc, dist="lnorm", mixture = FALSE) ``` -------------------------------- ### flexsurvcure Function Source: https://cran.r-project.org/web/packages/flexsurvcure/refman/flexsurvcure.html Fits flexible parametric mixture and non-mixture cure models for time-to-event data. It supports various base distributions and allows covariates to be modeled on different parameters. ```APIDOC ## flexsurvcure ### Description Mixture and non-mixture cure models using flexible base distributions from the flexsurv package. ### Usage ```R flexsurvcure( formula, data, weights, bhazard, subset, dist, na.action, link = "logistic", mixture = T, ... ) ``` ### Arguments * `formula` (formula): A formula expression in conventional R linear modeling syntax. The response must be a survival object as returned by the `survival::Surv()` function, and any covariates are given on the right-hand side. For example, `Surv(time, dead) ~ age + sex`. `Surv` objects of `type="right"`,`"counting"`, `"interval1"` or `"interval2"` are supported, corresponding to right-censored, left-truncated or interval-censored observations. If there are no covariates, specify `1` on the right hand side, for example `Surv(time, dead) ~ 1`. By default, covariates are placed on the “theta” parameter of the distribution, representing the cure fraction, through a linear model with the selected link function. Covariates can be placed on parameters of the base distribution by using the name of the parameter as a “function” in the formula. For example, in a Weibull model, the following expresses the scale parameter in terms of age and a treatment variable `treat`, and the shape parameter in terms of sex and treatment. `Surv(time, dead) ~ age + treat + shape(sex) + shape(treat)`. However, if the names of the ancillary parameters clash with any real functions that might be used in formulae (such as `I()`, or `factor()`), then those functions will not work in the formula. A safer way to model covariates on ancillary parameters is through the `anc` argument to `flexsurv::flexsurvreg`. `survival::survreg()` users should also note that the function `strata()` is ignored, so that any covariates surrounded by `strata()` are applied to the location parameter. * `data` (data.frame): A data frame in which to find variables supplied in `formula`. If not given, the variables should be in the working environment. * `weights` (variable): Optional variable giving case weights. * `bhazard` (variable): Optional variable giving expected hazards for relative survival models. * `subset` (vector): Vector of integers or logicals specifying the subset of the observations to be used in the fit. * `dist` (string): A string representing one of the built-in distributions of flexsurv. `Surv(time, dead) ~ age + treat, anc = list(shape = ~ sex + treat)` * `na.action` (function): A missing-data filter function, applied after any 'subset' argument has been used. Default is `options()$na.action`. * `link` (string): A string representing the link function to use for estimation of the cure fraction. Defaults to "logistic", but also supports "loglog", "probit", and "identity". * `mixture` (logical): Optional TRUE/FALSE to specify whether a mixture model should be fitted. Defaults to TRUE. * `...` (any): Other arguments to be passed to `flexsurv::flexsurvreg`. ### Details This function works as a wrapper around `flexsurv::flexsurvreg()` by dynamically constructing a custom distribution using wrappers to the pdf and cdf functions. In a parametric mixture model, it is assumed that there exists a group of individuals who experience no excess mortality, with the proportion of such individuals being given by the cure fraction parameter, and a parametric distribution representing the excess mortality for the remaining individuals. By contrast, a parametric non-mixture model simply rescales an existing parametric distribution such that the probability of survival asymptotically approaches the cure fraction parameter as time approaches infinity. ### Examples ```R flexsurvcure(Surv(rectime,censrec)~group, data=bc, dist="weibull", anc=list(scale=~group)) flexsurvcure(Surv(rectime,censrec)~group, data=bc, dist="lnorm", mixture = FALSE) flexsurvcure(Surv(rectime,censrec)~group, data=bc, dist="weibull", link="loglog") ``` ``` -------------------------------- ### Fit Complex Mixture Cure Model with Covariates Source: https://cran.r-project.org/web/packages/flexsurvcure/vignettes/flexsurvcure.Rmd Fits a more complex mixture cure model by adding covariates to the parametric distribution for the uncured individuals. Uses the anc argument to specify formulas for affected parameters. ```r cure_model_complex <- flexsurvcure(Surv(rectime, censrec)~group, data=bc, link="logistic", dist="weibullPH", mixture=T, anc=list(scale=~group)) print(cure_model_complex) plot(cure_model_complex) ``` -------------------------------- ### Fit Weibull Mixture Cure Model with Covariates on Scale Source: https://cran.r-project.org/web/packages/flexsurvcure/refman/flexsurvcure.html Fits a Weibull mixture cure model where the scale parameter is modeled using the 'group' covariate. This is useful for analyzing time-to-event data with a cure fraction and understanding how covariates affect the survival distribution. ```R flexsurvcure(Surv(rectime,censrec)~group, data=bc, dist="weibull", anc=list(scale=~group)) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.