powered by
This stepwise variable selection procedure can be applied to obtain the best candidates for a survreg fit.
survreg
srstepwise(x, times, delta, sle = 0.15, sls = 0.15, dist='lognormal')
Returns a list of indices of variables which have entered and stayed.
Matrix of variables to consider.
The time to an event, if any.
The event indicator: 1 for event, 0 for no event.
The chosen significance level for entering.
The chosen significance level for staying.
The distribution to be used by survreg.
Unfortunately, no stepwise procedure exists for survreg models. Therefore, we provide this brute force method.
lung
names. <- names(lung)[-(2:3)] status1 <- ifelse(lung$status==2,1,0) X <- as.matrix(lung)[ , names.] vars=srstepwise(X, lung$time, status1) print(names.[vars])
Run the code above in your browser using DataLab