Cox回归之变量筛选的R实现 (Stepwise Variable Selection in R)

参考链接:http://finzi.psych.upenn.edu/R/library/My.stepwise/html/My.stepwise.coxph.html

package

install.packages("My.stepwise")

Usage

My.stepwise.coxph(Time = NULL, T1 = NULL, T2 = NULL, Status = NULL,
  variable.list, in.variable = "NULL", data, sle = 0.15, sls = 0.15,
  vif.threshold = 999)

Arguments

Time

The 'Time' (time to an event) for the sepcified Cox's proportional hazards model as in coxph().

T1

The 'T1' (Start) of the long-form data for the sepcified Cox's model as in coxph().

T2

The 'T2' (Stop) of the long-form data for the sepcified Cox's model as in coxph().

Status

The 'Status' (event indicator) for the sepcified Cox's proportional hazards model as in coxph().

variable.list

A list of covariates to be selected.

in.variable

A list of covariate(s) to be always included in the regression model.

data

The data to be analyzed.

sle

The chosen significance level for entry (SLE).

sls

The chosen significance level for stay (SLS).

vif.threshold

The chosen threshold value of variance inflating factor (VIF).

Examples

## Not run: 
The data 'lung' is available in the 'survival' package.
## End(Not run)

if (requireNamespace("survival", quietly = TRUE)) {
 lung <- survival::lung
}

names(lung)
dim(lung)
my.data <- na.omit(lung)
dim(my.data)
head(my.data)
my.data$status1 <- ifelse(my.data$status==2,1,0)
my.variable.list <- c("inst", "age", "sex", "ph.ecog", "ph.karno", "pat.karno")
My.stepwise.coxph(Time = "time", Status = "status1", variable.list = my.variable.list,
   in.variable = c("meal.cal", "wt.loss"), data = my.data)

my.variable.list <- c("inst", "age", "sex", "ph.ecog", "ph.karno", "pat.karno", "meal.cal",
   "wt.loss")
My.stepwise.coxph(Time = "time", Status = "status1", variable.list = my.variable.list,
   data = my.data, sle = 0.25, sls = 0.25)

 

你可能感兴趣的:(统计分析,R语言)