[R] Running a Logit Model in R

David Winsemius dwinsemius at comcast.net
Sun Jan 31 05:04:07 CET 2010


On Jan 30, 2010, at 8:24 PM, Mathew, Abraham T wrote:

>
> I'm an R newbie and had the following question. I'm trying to run a  
> logit model because I have a dependant variable that is a factor  
> with three levels. Each of my independent variables are factor  
> variables and have two or more levels, which is why I'm unsure about  
> the error.

How are you expecting glm to construct a _binomial_ model with a  
dependent variable that has 3 levels?

>
> regone <- glm(data96$RV961327 ~ data96$RV960605 + data96$RV960610 +  
> data96$RV960337 +     data96$RV960385 + data96$RV960417 +  
> data96$RV960615 + data96$RV960698 + data96   $RV960714 +  
> data96$RV961145 + data96$RV960067 + data96$RV960702,  
> family=binomial(logit))

Perhaps:

library(MASS)
?polr

(Or)

library(nnet)
?multinom

(Or)

library(rms)
?lrm

>
> This produces the following error.
>
> Error in `contrasts<-`(`*tmp*`, value = "contr.treatment") :
>  contrasts can be applied only to factors with 2 or more levels
>
-- 

David Winsemius, MD
Heritage Laboratories
West Hartford, CT



More information about the R-help mailing list