[R] mlogit error

Achim Zeileis Achim.Zeileis at uibk.ac.at
Fri Aug 13 09:14:11 CEST 2010


On Fri, 13 Aug 2010, Maha Bakoben wrote:

> Hi,
>
> I'm trying to fit a multinomial logistic regression to my data which
> consists of 5 discrete variables (scales 1:10) and 1000 observations.
>
> I get the following error:
>
> Error in `row.names<-.data.frame`(`*tmp*`, value = c("NA.NA", "NA.NA",  :
>  duplicate 'row.names' are not allowed
> In addition: Warning message:
> non-unique value when setting 'row.names': ?NA.NA?
>
> My code:
>
>> flevel1$Q120<-as.factor(flevel1$Q120)
>> MData<-mlogit.data(flevel1, varying=NULL,choice="Q120", shape="wide")
>> LogitModel<-mlogit(flevel1$Q120~1|flevel1$Q92, data=MData)

It's hard to say what you do wrong because you don't provide a 
reproducible example. (Please see the posting guide, linked at the end of 
this e-mail, for good posting practices.)

But it certainly looks suspicious that you force mlogit to use the 
variables from flevel1 but provide data = MData. Try to do

   mlogit(Q120 ~ 1 | Q92, data = MData)

In general, it is recommended to use

   y ~ x, data = mydata

in R, where "mydata" contains (the appropriate version of y and x). It 
typically leads to identical results as

   mydata$y ~ mydata$x

which is, however, less elegant, especially if more variables are 
involved. But using

   otherdata$y ~ otherdata$x, data = mydata

is very likely to lead to confusion...

hth,
Z

> MData[1:10,]
>     Q56 Q92 Q102 Q119  Q120
> 1.1   10   7   10   10 FALSE
> 1.10  10   7   10   10  TRUE
> 1.2   10   7   10   10 FALSE
> 1.3   10   7   10   10 FALSE
> 1.4   10   7   10   10 FALSE
> 1.5   10   7   10   10 FALSE
> 1.6   10   7   10   10 FALSE
> 1.7   10   7   10   10 FALSE
> 1.8   10   7   10   10 FALSE
> 1.9   10   7   10   10 FALSE
>
>
>
> Your help will be greatly appreciated.
>
> Maha
>
> 	[[alternative HTML version deleted]]
>
>



More information about the R-help mailing list