开发者

Ordering in Logistic Regression

In logistic regression SAS has the option to model 1 rather than 0 using "descending" option. Is there any method in R, where we c开发者_C百科an do the same thing?

The code I'm using is the following:

glm(y~x1+x2+x3, family=binomial(link="logit"), na.action=na.pass)

Regards, Ari


The option is exactly the same as modeling 1-y, and will return the same coefficients but with a different sign. So either you put 1-y in the model, or you just invert your coefficients :

Data <- data.frame(
    y = rbinom(100,1,0.5),
    x1 = rnorm(100),
    x2 = rnorm(100),
    x3 = rnorm(100)
)

mod1 <- glm(y~x1+x2+x3, family=binomial(link="logit"), 
           na.action=na.pass,data=Data)

mod2 <- glm((1-y)~x1+x2+x3, family=binomial(link="logit"),
           na.action=na.pass,data=Data)

> all.equal(coef(mod2),-coef(mod1))
[1] TRUE
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜