In logistic regression SAS has the option to model 1 rather than 0 using "descending" option. Is there any method in R, where we can 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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With