Skip to content

Commit 42a5707

Browse files
authored
Update documentation of survival models to new doc style (#582)
* doc update for `survival_reg()` * doc update for `proportional_hazards()` * doc update for `surv_reg()` * use correct mode * clean up * update docs for `surv_reg()` - tuning parameters - other details * update ref to pkg-level docs of flexsurv
1 parent af897c7 commit 42a5707

15 files changed

+430
-272
lines changed

R/proportional_hazards.R

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,36 @@
11
#' Proportional hazards regression
22
#'
3-
#' `proportional_hazards()` is a way to generate a _specification_ of a model
4-
#' before fitting and allows the model to be created using different packages
5-
#' in R. The main arguments for the model are:
6-
#' \itemize{
7-
#' \item \code{penalty}: The total amount of regularization
8-
#' in the model. Note that this must be zero for some engines.
9-
#' \item \code{mixture}: The mixture amounts of different types of
10-
#' regularization (see below). Note that this will be ignored for some engines.
11-
#' }
12-
#' These arguments are converted to their specific names at the
13-
#' time that the model is fit. Other options and arguments can be
14-
#' set using `set_engine()`. If left to their defaults
15-
#' here (`NULL`), the values are taken from the underlying model
16-
#' functions. If parameters need to be modified, `update()` can be used
17-
#' in lieu of recreating the object from scratch.
3+
#' @description
4+
#' `proportional_hazards()` defines a proportional hazards model.
185
#'
19-
#' @param mode A single character string for the prediction outcome mode.
20-
#' Possible values for this model are "unknown", or "censored regression".
21-
#' @param engine A single character string specifying what computational engine
22-
#' to use for fitting. Possible engines are listed below. The default for this
23-
#' model is `"survival"`.
6+
#' There are different ways to fit this model. The method of estimation is
7+
#' chosen by setting the model _engine_.
8+
#'
9+
#' \Sexpr[stage=render,results=rd]{parsnip:::make_engine_list("proportional_hazards")}
10+
#'
11+
#' More information on how \pkg{parsnip} is used for modeling is at
12+
#' \url{https://www.tidymodels.org/}.
13+
#'
14+
#' @inheritParams boost_tree
2415
#' @inheritParams linear_reg
16+
#' @param mode A single character string for the prediction outcome mode.
17+
#' The only possible value for this model is "censored regression".
18+
#'
19+
#' @template spec-details
20+
#'
21+
#' @template spec-survival
2522
#'
2623
#' @details
2724
#' Proportional hazards models include the Cox model.
28-
#' For `proportional_hazards()`, the mode will always be "censored regression".
2925
#'
30-
#' @seealso [fit.model_spec()], [set_engine()], [update()]
26+
#' @template spec-references
27+
#'
28+
#' @seealso \Sexpr[stage=render,results=rd]{parsnip:::make_seealso_list("proportional_hazards")}
29+
#'
3130
#' @examples
3231
#' show_engines("proportional_hazards")
32+
#'
33+
#' proportional_hazards(mode = "censored regression")
3334
#' @keywords internal
3435
#' @export
3536
proportional_hazards <- function(

R/surv_reg.R

Lines changed: 16 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -6,57 +6,34 @@
66
#' This function is soft-deprecated in favor of `survival_reg()` which uses the
77
#' `"censored regression"` mode.
88
#'
9-
#' `surv_reg()` is a way to generate a _specification_ of a model
10-
#' before fitting and allows the model to be created using
11-
#' R. The main argument for the
12-
#' model is:
13-
#' \itemize{
14-
#' \item \code{dist}: The probability distribution of the outcome.
15-
#' }
16-
#' This argument is converted to its specific names at the
17-
#' time that the model is fit. Other options and arguments can be
18-
#' set using `set_engine()`. If left to its default
19-
#' here (`NULL`), the value is taken from the underlying model
20-
#' functions.
9+
#' `surv_reg()` defines a parametric survival model.
2110
#'
22-
#' The data given to the function are not saved and are only used
23-
#' to determine the _mode_ of the model. For `surv_reg()`,the
24-
#' mode will always be "regression".
11+
#' There are different ways to fit this model. The method of estimation is
12+
#' chosen by setting the model _engine_.
2513
#'
26-
#' Since survival models typically involve censoring (and require the use of
27-
#' [survival::Surv()] objects), the [fit.model_spec()] function will require that the
28-
#' survival model be specified via the formula interface.
14+
#' \Sexpr[stage=render,results=rd]{parsnip:::make_engine_list("surv_reg")}
2915
#'
30-
#' Also, for the `flexsurv::flexsurvfit` engine, the typical
31-
#' `strata` function cannot be used. To achieve the same effect,
32-
#' the extra parameter roles can be used (as described above).
16+
#' More information on how \pkg{parsnip} is used for modeling is at
17+
#' \url{https://www.tidymodels.org/}.
3318
#'
19+
#' @inheritParams boost_tree
3420
#' @param mode A single character string for the prediction outcome mode.
3521
#' The only possible value for this model is "regression".
36-
#' @param engine A single character string specifying what computational engine
37-
#' to use for fitting. Possible engines are listed below. The default for this
38-
#' model is `"survival"`.
39-
#' @param dist A character string for the outcome distribution. "weibull" is
40-
#' the default.
41-
#' @details
42-
#' For `surv_reg()`, the mode will always be "regression".
22+
#' @param dist A character string for the probability distribution of the
23+
#' outcome. The default is "weibull".
4324
#'
44-
#' The model can be created using the `fit()` function using the
45-
#' following _engines_:
46-
#' \itemize{
47-
#' \item \pkg{R}: `"flexsurv"`, `"survival"` (the default)
48-
#' }
25+
#' @template spec-details
4926
#'
50-
#' @includeRmd man/rmd/surv-reg.Rmd details
27+
#' @template spec-survival
28+
#'
29+
#' @template spec-references
30+
#'
31+
#' @seealso \Sexpr[stage=render,results=rd]{parsnip:::make_seealso_list("surv_reg")}
5132
#'
52-
#' @seealso [fit.model_spec()], [survival::Surv()], [set_engine()], [update()]
53-
#' @references Jackson, C. (2016). `flexsurv`: A Platform for Parametric Survival
54-
#' Modeling in R. _Journal of Statistical Software_, 70(8), 1 - 33.
5533
#' @examples
5634
#' show_engines("surv_reg")
5735
#'
58-
#' surv_reg()
59-
#'
36+
#' surv_reg(mode = "regression", dist = "weibull")
6037
#' @keywords internal
6138
#' @export
6239
surv_reg <- function(mode = "regression", engine = "survival", dist = NULL) {

R/surv_reg_flexsurv.R

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#' Parametric survival regression
2+
#'
3+
#' [flexsurv::flexsurvreg()] fits a parametric survival model.
4+
#'
5+
#' @includeRmd man/rmd/surv_reg_flexsurv.Rmd details
6+
#'
7+
#' @name details_surv_reg_flexsurv
8+
#' @keywords internal
9+
NULL

R/surv_reg_survival.R

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#' Parametric survival regression
2+
#'
3+
#' [survival::survreg()] fits a parametric survival model.
4+
#'
5+
#' @includeRmd man/rmd/surv_reg_survival.Rmd details
6+
#'
7+
#' @name details_surv_reg_survival
8+
#' @keywords internal
9+
NULL

R/survival_reg.R

Lines changed: 24 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,35 @@
11
#' Parametric survival regression
22
#'
3-
#' `survival_reg()` is a way to generate a _specification_ of a model
4-
#' before fitting and allows the model to be created using
5-
#' R. The main argument for the
6-
#' model is:
7-
#' \itemize{
8-
#' \item \code{dist}: The probability distribution of the outcome.
9-
#' }
10-
#' This argument is converted to its specific names at the
11-
#' time that the model is fit. Other options and argument can be
12-
#' set using `set_engine()`. If left to its default
13-
#' here (`NULL`), the value is taken from the underlying model
14-
#' functions. If parameters need to be modified, `update()` can be used
15-
#' in lieu of recreating the object from scratch.
3+
#' @description
4+
#' `survival_reg()` defines a parametric survival model.
165
#'
6+
#' There are different ways to fit this model. The method of estimation is
7+
#' chosen by setting the model _engine_.
8+
#'
9+
#' \Sexpr[stage=render,results=rd]{parsnip:::make_engine_list("survival_reg")}
10+
#'
11+
#' More information on how \pkg{parsnip} is used for modeling is at
12+
#' \url{https://www.tidymodels.org/}.
13+
#'
14+
#' @inheritParams boost_tree
1715
#' @param mode A single character string for the prediction outcome mode.
1816
#' The only possible value for this model is "censored regression".
19-
#' @param engine A single character string specifying what computational engine
20-
#' to use for fitting. Possible engines are listed below. The default for this
21-
#' model is `"survival"`.
22-
#' @param dist A character string for the outcome distribution. "weibull" is
23-
#' the default.
24-
#' @details
25-
#' The data given to the function are not saved and are only used
26-
#' to determine the _mode_ of the model. For `survival_reg()`,the
27-
#' mode will always be "censored regression".
17+
#' @param dist A character string for the probability distribution of the
18+
#' outcome. The default is "weibull".
19+
#'
2820
#'
29-
#' Since survival models typically involve censoring (and require the use of
30-
#' [survival::Surv()] objects), the [fit.model_spec()] function will require that the
31-
#' survival model be specified via the formula interface.
21+
#' @template spec-details
22+
#'
23+
#' @template spec-survival
24+
#'
25+
#' @template spec-references
26+
#'
27+
#' @seealso \Sexpr[stage=render,results=rd]{parsnip:::make_seealso_list("survival_reg")}
3228
#'
33-
#' @seealso [fit.model_spec()], [survival::Surv()], [set_engine()], [update()]
3429
#' @examples
35-
#' survival_reg()
30+
#' show_engines("survival_reg")
31+
#'
32+
#' survival_reg(mode = "censored regression", dist = "weibull")
3633
#' @keywords internal
3734
#' @export
3835
survival_reg <- function(mode = "censored regression", engine = "survival", dist = NULL) {

man-roxygen/spec-survival.R

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#' @details
2+
#' Since survival models typically involve censoring (and require the use of
3+
#' [survival::Surv()] objects), the [fit.model_spec()] function will require that the
4+
#' survival model be specified via the formula interface.

man/details_surv_reg_flexsurv.Rd

Lines changed: 60 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/details_surv_reg_survival.Rd

Lines changed: 89 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/parsnip_update.Rd

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)