Skip to content
Back to formatted view

Raw Message

Message-ID: <500FBCC6.30301@xtra.co.nz>
Date: 2012-07-25T09:30:46Z
From: Rolf Turner
Subject: error in running glm() function
In-Reply-To: <1343201292178-4637727.post@n4.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:
> 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.