Skip to content

error in running glm() function

2 messages · shrutibansal, Rolf Turner

#
m1.logit <-lm(default ~ 
                          amt.fac + 
                          age.fac + 
                          duration +
                          chk_acct +
                          history +
                          purpose +
                          sav_acct +
                          employment +
                          install_rate + 
                          pstatus +
                          other_debtor +
                          time_resid +
                          property +
                          other_install + 
                          housing +
                          other_credits +
                          job +
                          num_depend + 
                          telephone + 
                          foreign
                                  , family = binomial(link = "logit"), data
= dev)

on running this code I am getting the following error

Error in `contrasts<-`(`*tmp*`, value = contr.funs[1 + isOF[nn]]) : 
  contrasts can be applied only to factors with 2 or more levels
..
please help me solving this problem



--
View this message in context: http://r.789695.n4.nabble.com/error-in-running-glm-function-tp4637727.html
Sent from the R help mailing list archive at Nabble.com.
#
Ummmm, doesn't the error message tend to indicate to you that
at least one of the factors in the model has only one level?

That would make that factor a constant, whence it could not possibly
contribute any predictive power, whence it should be eliminated from
the model.

Note that you *must* have meant "glm()" not "lm()" --- the "family"
argument makes no sense with lm().

It is quite possible that your model could/should be written
(more simply --- understatement of the millennium!!!) as:

     ml.logit <- glm(default ~ ., family=binomial,data=dev)

(assuming the given list of variates exhausts the columns of "dev").

Note that you do not need to specify link="logit" (or even link=logit;
the quotes are unnecessary!) since logit is the default link for the
binomial family.

     cheers,

         Rolf Turner
On 25/07/12 19:28, shrutibansal wrote: