0

Do you have an idea why the mlogit function is yielding an error?
duplicate 'row.names' are not allowed
The row names are not duplicate if you ask me. This is driving me crazy.

> mlORDERS <- mlogit.data(ORDERS, choice="PAYMENT_METHOD", shape="wide", id.var="ORDER_NUMBER")

> head(mlORDERS)
      ORDER_NUMBER CUSTOMER_ID PAYMENT_METHOD GROSS_RETAIL_TOTAL GENDER SOLVENCY_SCORE EXISTING_CUSTOMER chid alt
1.CCA 1.010311e+13     1402114          FALSE             1271.6   male            527              TRUE    1 CCA
1.INV 1.010311e+13     1402114           TRUE             1271.6   male            527              TRUE    1 INV
1.PPA 1.010311e+13     1402114          FALSE             1271.6   male            527              TRUE    1 PPA
1.PRE 1.010311e+13     1402114          FALSE             1271.6   male            527              TRUE    1 PRE
2.CCA 1.010311e+13      758980          FALSE               53.9 female            385              TRUE    2 CCA
2.INV 1.010311e+13      758980           TRUE               53.9 female            385              TRUE    2 INV

> str(mlORDERS)
Classes ‘mlogit.data’ and 'data.frame': 100 obs. of  9 variables:
 $ ORDER_NUMBER      : num  1.01e+13 1.01e+13 1.01e+13 1.01e+13 1.01e+13 ...
 $ CUSTOMER_ID       : int  1402114 1402114 1402114 1402114 758980 758980 758980 758980 217054 217054 ...
 $ PAYMENT_METHOD    : logi  FALSE TRUE FALSE FALSE FALSE TRUE ...
 $ GROSS_RETAIL_TOTAL: num  1271.6 1271.6 1271.6 1271.6 53.9 ...
 $ GENDER            : Factor w/ 2 levels "male","female": 1 1 1 1 2 2 2 2 2 2 ...
 $ SOLVENCY_SCORE    : int  527 527 527 527 385 385 385 385 543 543 ...
 $ EXISTING_CUSTOMER : logi  TRUE TRUE TRUE TRUE TRUE TRUE ...
 $ chid              : num  1 1 1 1 2 2 2 2 3 3 ...
 $ alt               : chr  "CCA" "INV" "PPA" "PRE" ...
 - attr(*, "index")='data.frame':   100 obs. of  3 variables:
  ..$ chid: Factor w/ 25 levels "1","2","3","4",..: 1 1 1 1 2 2 2 2 3 3 ...
  ..$ alt : Factor w/ 4 levels "CCA","INV","PPA",..: 1 2 3 4 1 2 3 4 1 2 ...
  ..$ id  : Factor w/ 25 levels "10103114445506",..: 20 20 20 20 1 1 1 1 18 18 ...
 - attr(*, "choice")= chr "PAYMENT_METHOD"

> mlModel <- mlogit(ORDERS$PAYMENT_METHOD ~ 1 | ORDERS$GENDER + ORDERS$SOLVENCY_SCORE, data=mlORDERS)
Error in `row.names<-.data.frame`(`*tmp*`, value = value) : 
  duplicate 'row.names' are not allowed
In addition: Warning message:
non-unique value when setting 'row.names': ‘NA.NA’ 

I even tried make.unique(rownames(mlORDERS)) and which(duplicated(mlORDERS[, 1])) which doesn't help neither.

wimpato
  • 11
  • 3
  • `row.names(df) <- NULL` will give you the row numbers. `row.names(df) <- make.unique(row.names(df))` will append values to duplicate names to make them unique while preserving them if this is desired. – lmo Apr 19 '17 at 12:08
  • Unfortunately that doesn't solve it. I tried above command for unique row names but I still get the same error message. Also, there are no NAs when I look at the table. Must be a another reason not correctly expressed by the error message I fear... – wimpato Apr 19 '17 at 19:20
  • In the meanwhile I could solve this: Correct: `mlModel <- mlogit(PAYMENT_METHOD ~ 1 | GROSS_RETAIL_TOTAL + SOLVENCY_SCORE, data=mlORDERS)` Wrong: `mlModel <- mlogit(ORDERS$PAYMENT_METHOD ~ 1 | GROSS_RETAIL_TOTAL + SOLVENCY_SCORE, data=mlORDERS)` – wimpato Apr 20 '17 at 11:11

0 Answers0