R: PipeOpDistrCompositor

mlr_pipeops_compose_distr {mlr3proba} | R Documentation

## PipeOpDistrCompositor

### Description

Estimates (or 'composes') a survival distribution from a predicted baseline `distr` and a `crank` or `lp` from two PredictionSurvs.

Compositor Assumptions:

- The baseline `distr` is a discrete estimator, e.g. surv.kaplan.

- The composed `distr` is of a linear form

- If `lp` is missing then `crank` is equivalent

These assumptions are strong and may not be reasonable. Future updates will upgrade this compositor to be more flexible.

### Dictionary

This PipeOp can be instantiated via the dictionary mlr3pipelines::mlr_pipeops or with the associated sugar function `mlr3pipelines::po()`:

    PipeOpDistrCompositor$new()
    mlr_pipeops$get("distrcompose")
    po("distrcompose")

### Input and Output Channels

PipeOpDistrCompositor has two input channels, "base" and "pred". Both input channels take `NULL` during training and PredictionSurv during prediction.

PipeOpDistrCompositor has one output channel named "output", producing `NULL` during training and a PredictionSurv during prediction.

The output during prediction is the PredictionSurv from the "pred" input but with an extra (or overwritten) column for `distr` predict type; which is composed from the `distr` of "base" and `lp` or `crank` of "pred".

### State

The `$state` is left empty (`list()`).

### Parameters

The parameters are:

- `form` :: `character(1)`
  Determines the form that the predicted linear survival model should take. This is either, accelerated-failure time, `aft`, proportional hazards, `ph`, or proportional odds, `po`. Default `aft`.

- `overwrite` :: `logical(1)`
  If `FALSE` (default) then if the "pred" input already has a `distr`, the compositor does nothing and returns the given PredictionSurv. If `TRUE` then the `distr` is overwritten with the `distr` composed from `lp`/`crank` - this is useful for changing the prediction `distr` from one model form to another.

### Internals

The respective `form`s above have respective survival distributions:

aft: S(t) = S0(t/exp(lp))

ph: S(t) = S0(t)^exp(lp)

po: S(t) = S0(t) / [exp(-lp) + S0(t) (1-exp(-lp))]

# nolint where S0 is the estimated baseline survival distribution, and lp is the predicted linear predictor. If the input model does not predict a linear predictor then `crank` is assumed to be the `lp` - this may be a strong and unreasonable assumption.

### Super class

`mlr3pipelines::PipeOp` -> `PipeOpDistrCompositor`

### Methods

#### Public methods

- `PipeOpDistrCompositor$new()`

- `PipeOpDistrCompositor$clone()`

Inherited methods

- `mlr3pipelines::PipeOp$predict()`

- `mlr3pipelines::PipeOp$print()`

- `mlr3pipelines::PipeOp$train()`

#### Method `new()`

Creates a new instance of this R6 class.

##### Usage

    PipeOpDistrCompositor$new(
      id = "compose_distr",
      param_vals = list(form = "aft", overwrite = FALSE)
    )

##### Arguments

`id`

  (`character(1)`)
  Identifier of the resulting object.

`param_vals`

  (`list()`)
  List of hyperparameter settings, overwriting the hyperparameter settings that would otherwise be set during construction.

#### Method `clone()`

The objects of this class are cloneable with this method.

##### Usage

    PipeOpDistrCompositor$clone(deep = FALSE)

##### Arguments

`deep`

  Whether to make a deep clone.

### See Also

pipeline_distrcompositor

Other survival compositors: `mlr_pipeops_compose_crank`

### Examples

    ## Not run:
    if (requireNamespace("mlr3pipelines", quietly = TRUE)) {
      library(mlr3)
      library(mlr3pipelines)
      task = tsk("rats")

      base = lrn("surv.kaplan")$train(task)$predict(task)
      pred = lrn("surv.coxph")$train(task)$predict(task)
      pod = po("distrcompose", param_vals = list(form = "aft", overwrite = TRUE))
      pod$predict(list(base = base, pred = pred))[[1]]
    }

    ## End(Not run)

[Package mlr3proba version 0.4.2 Index]