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? Also, I noticed that S-Plus but not R has a glim routine that uses maximum likelihood. What would be the equivalent? Thanks.
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
Did you try the following: >>r <- glm(brain.cancer~epilepsy+other.cancer-1, c3, >> family=binomial(link="logit") ) The construct "-1" on the right hand side of a formula means to exclude the intercept. See, e.g., "model formulae" in the index to Modern Applied Statistics with S by Venables & Ripley. I don't remember doing this with glm, but I've done it with lm. hope this helps. spencer graves 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? > > Also, I noticed that S-Plus but not R has a glim routine that uses > maximum likelihood. What would be the equivalent? > > Thanks. > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://www.stat.math.ethz.ch/mailman/listinfo/r-help
Thanks to Thomas Lumley, Spencer Graves, and Steve Sullivan for their advice on and off list to modify the formula with +0 (which I did; it worked) or -1 at the end. A couple of items of clarification: , On Tue, 2003-08-19 at 15:32, Thomas Lumley wrote:> 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 compatibleOmit the intercept=FALSE in the above lines; it causes an error even with the augmented model spec.> > > Also, I noticed that S-Plus but not R has a glim routine that uses > > maximum likelihood. What would be the equivalent? > > glm. >I thought glm was a minimize the deviations approach, which is different from maximize likelihood.> -thomas > >--