hieu
hieu

Reputation: 135

multinomial regression error: 'relevel' only for factors

I have the following data:

Class   Batch   Parity  EB
0   2   2   842.8302684
0   2   3   1435.313822
0   2   3   615.32252
1   3   2   428.0919074
1   3   3   629.6284765
1   3   2   428.0919074
.   .   .   .
.   .   .   .

I am running the multinomial regression using mlogit package but having problem back:

Error in relevel.default(attr(mf, "index")[["alt"]], reflevel) : 
  'relevel' only for factors

Could you please have a look to see where I am wrong. The model is:

model<-mlogit(Class~EB+DFS+Batch+Parity, data=dat, reflevel="1")

Class and Batch are categorical with Class ( 0 or 1) and Batch (1 to 6). Before running the model I applied this to transfer Class and Batch to factors:

dat$Class<-as.factor(dat$Class)
dat$Batch<-as.factor(dat$Batch)

Thank you very much!

Upvotes: 0

Views: 2935

Answers (1)

Lucas
Lucas

Reputation: 11

I had the same error and then realized I was using the actual dataset and not the dataset reshaped with "mlogit.data()".

Upvotes: 1

Related Questions