R:自动选择模型

时间:2016-12-07 16:31:49

标签: r glm

我正在使用step函数来查找最佳逻辑模型。然后我必须将该模型复制并粘贴到对glm的新调用中。有没有办法让我自动推广这个?

full=glm(RESPONSE ~ SEX + TOTCHOL + ..., data=training,   
family=binomial(link="logit"))
summary(full)
anova(full,test="Chisq")

#BEST MODEL
full.forward <- step(null,   
                scope=list(lower=null,upper=full),direction="forward", 
                family=binomial(link="logit")

#rerun BEST MODEL getting details. I want the model automated.
reduced=glm(RESPONSE ~ SYSBP + as.factor(BPMEDS) + DIABP + BMI + AGE,
        data=training,family=binomial(link="logit"))

Mary A. Marion

0 个答案:

没有答案