以framingham数据为例,先建立模型
load("framingham.Rdata")
#哑变量
framingham$male<-factor(framingham$male,
levels = c(0,1),
labels = c("女性","男性"))
framingham$education<-factor(framingham$education,
levels = c(1,2,3,4),
labels = c("高中以下","高中","大学","大学以上"))
framingham$currentSmoker<-factor(framingham$currentSmoker,
levels = c(0,1),
labels = c("不吸烟","吸烟"))
framingham$BPMeds<-factor(framingham$BPMeds,
levels = c(0,1),
labels = c("不服用","服用"))
framingham$prevalentStroke<-factor(framingham$prevalentStroke,
levels = c(0,1),
labels =