How to remove intercept in R
Asked Answered
F

2

31

I need to create a probit model without the intercept. So, how can I remove the intercept from a probit model in R?

Frail answered 8/1, 2013 at 14:17 Comment(1)
Just add a -1 in your formula as in: glm(y ~ x1 + x2 - 1, family = binomial(link = "probit"), data = yourdata) this will estimate a probit model without intercept.Connote
P
52

You don't say how you are intending to fit the probit model, but if it uses R's formula notation to describe the model then you can supply either + 0 or - 1 as part of the formula to suppress the intercept:

mod <- foo(y ~ 0 + x1 + x2, data = bar)

or

mod <- foo(y ~ x1 + x2 - 1, data = bar)

(both using pseudo R code of course - substitute your modelling function and data/variables.)

If this is a model fitting by glm() then something like:

mod <- glm(y ~ x1 + x2 - 1, data = bar, family = binomial(link = "probit"))

should do it (again substituting in your data and variable names as appropriate.)

Peabody answered 8/1, 2013 at 15:54 Comment(2)
Is there a difference between using + 0 or -1 ?Barre
@NiekdeKlein No, no difference that II am aware ofPeabody
I
15

Also, if you have an existing formula object, foo, you can remove the intercept with update like this:

foo <- y ~ x1 + x2
bar <- update(foo, ~ . -1)
# bar == y ~ x1 + x2 - 1
Invocation answered 18/3, 2014 at 21:48 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.