|
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 |
|
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: > 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. ______________________________________________ [hidden email] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. |
| Powered by Nabble | Edit this page |
