View source: R/predictEventProb.selectFGR.R
selectFGR | R Documentation |
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.
selectFGR(formula, data, cause = 1, rule = "AIC", direction = "backward", ...)
formula |
A formula whose left hand side is a |
data |
A data.frame in which all the variables of
|
cause |
The failure type of interest. Defaults to |
rule |
Rule to pass on to crrstep ("AIC", "BIC" or "BICcr"),
also see |
direction |
see |
... |
Further arguments passed to |
Rob C.M. van Kruijsdijk R.C.M.vanKruijsdijk@umcutrecht.nl
Thomas Alexander Gerds tag@biostat.ku.dk
## 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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.