R: Stepwise variable selection in the Fine & Gray regression...

selectFGR {pec} | R Documentation

## Stepwise variable selection in the Fine & Gray regression competing risk model

### Description

This is a wrapper function which first selects variables in the Fine & Gray regression model using `crrstep` from the `crrstep` package and then returns a fitted Fine & Gray regression model with the selected variables.

### Usage

    selectFGR(formula, data, cause = 1, rule = "AIC", direction = "backward", ...)

### Arguments

`formula` | A formula whose left hand side is a `Hist` object – see `Hist`. The right hand side specifies (a linear combination of) the covariates. See examples below.
`data` | A data.frame in which all the variables of `formula` can be interpreted.
`cause` | The failure type of interest. Defaults to `1`.
`rule` | Rule to pass on to crrstep ("AIC", "BIC" or "BICcr"), also see `crrstep`
`direction` | see `crrstep`
`...` | Further arguments passed to `crrstep`.

### Author(s)

Rob C.M. van Kruijsdijk R.C.M.vanKruijsdijk@umcutrecht.nl

Thomas Alexander Gerds tag@biostat.ku.dk

### Examples

    ## Not run:
    library(riskRegression)
    library(prodlim)
    library(lava)
    if (!requireNamespace("cmprsk",quietly=TRUE)){
    library(cmprsk)
    library(pec)
    m <- crModel()
    m <- addvar(m,c('X1','X2','X3','X4','X5','X6','X7','X8','X9','X10'))
    distribution(m,c("X2","X7","X9")) <- binomial.lvm()
    regression(m,eventtime1~X1+X2+X5+X9) <- c(-1,1,0.5,0.8)
    set.seed(100)
    d <- sim(m,100)
    ## full formula
    ff <- Hist(time, event) ~ X1 + X2 + X3 + X4 +X5 + X6 + X7+ X8 + X9 + X10

    # Fit full model with FGR
    fg <- FGR(ff,cause=1,data=d)

    # Backward selection based on the AIC
    sfgAIC <- selectFGR(ff, data=d, rule="AIC", direction="backward")

    sfgAIC$fit # Final FGR-model with selected variables

    # Risk reclassification plot at time = 4
    plot(predictEventProb(fg,times=4,newdata=d),
         predictEventProb(sfgAIC,times=4,newdata=d))

    # Backward selection based on the BIC, while forcing
    # the last two variables (X9 and X10) in the model
    sfgBIC <- selectFGR(ff, data=d, rule="BIC", direction="backward",
                      scope.min=~X9+X10)

    ## apparent performance
    pec(list(full.model=fg,selectedAIC=sfgAIC,selectedBIC=sfgBIC),
        formula=Hist(time, event)~1,
        data=d)

    ## bootstrap cross-validation performance
    set.seed(7)
    pec(list(full.model=fg,selectedAIC=sfgAIC,selectedBIC=sfgBIC),
        formula=Hist(time, event)~1,
        data=d,
        B=5,
        splitMethod="bootcv")
    }

    ## End(Not run)

[Package pec version 2020.11.17 Index]