R中如何做glm
#data importation
model <- glm(y ~ ., data = wave, family=binomial)
model.default <- glm(y ~ 1, data = wave, family=binomial)
model.forward <-
stepAIC(model.default,
scope=list(lower=as.formula(model.default),upper=as.formula(model)),
direction="forward",
k=log(nrow(wave))
)
说明这里的变量选择用了stepAIC, optimizes the Akaike (AIC) criterion.
According the forward search, we try all the
regression with 1 predictor. We perform "p" logistic regression learning process. Then, we select the best one. We try to add a second variable. So, we perform "p-1" regressions. The algorithm is quadratic O(p²). The calculation time is heavily impacted.
评论