[R] logistic regression without intercept

Thomas Lumley tlumley at u.washington.edu
Wed Aug 20 00:32:41 CEST 2003


On Tue, 19 Aug 2003, Ross Boylan wrote:

> I want to do a logistic regression without an intercept term.  This
> option is absent from glm, though present in some of the inner functions
> glm uses.  I gather glm is the standard way to do logistic regression in
> R.
>
> Hoping it would be passed in, I said
> > r <- glm(brain.cancer~epilepsy+other.cancer, c3,
> >        family=binomial(link="logit"), intercept=FALSE)
> which produced
> Error in glm.control(...) : unused argument(s) (intercept ...)
>
> Is there an easy way to do this?  I suppose I could start hacking away
> at glm so it would take the argument and pass it on, but is it absent
> for a reason?

Yes. You specify no intercept  with the formula:
r <- glm(brain.cancer~epilepsy+other.cancer+0, c3,
        family=binomial(link="logit"), intercept=FALSE)
or
r <- glm(brain.cancer~epilepsy+other.cancer-1, c3,
        family=binomial(link="logit"), intercept=FALSE)

The latter is S-PLUS compatible

> Also, I noticed that S-Plus but not R has a glim routine that uses
> maximum likelihood.  What would be the equivalent?

glm.

	-thomas




More information about the R-help mailing list