0

Customers are faced with series of choices of unique alternatives. For example:

Customer 1 chooses between alternatives A1,A2,A3,A4; Customer 1 chooses between atlernatives B1,B2; Customer 2 chooses between alternatives C1,C2,C3; Customer 2 chooses between alternatives D1,D2,D3 etc

Can any R package deal with it?

For example.csv

CHOICE,CUSTOMER,CHID,ALT,DIST,INCOME
1,1,1,1,100,70
0,1,1,2,372,70
0,1,1,3,417,70
0,1,1,4,180,70
1,1,2,1,68,70
0,1,2,2,354,70
0,2,3,1,68,100
0,2,3,2,354,100
1,2,3,3,399,100
1,2,4,1,180,100
0,2,4,2,100,100
0,2,4,3,80,100

mlogit failed

> library(mlogit)
> ExData <- read.csv("C:/Users/John/Desktop/R/example.csv")
> MLData <- mlogit.data(ExData, shape="long", choice="CHOICE", chid.var="CHID", id.var="CUSTOMER", alt.var="ALT")
> res <- mlogit(CHOICE~DIST|INCOME, data=MLData, shape="long", alt.var="ALT")
Error in `row.names<-.data.frame`(`*tmp*`, value = paste(chid, alt, sep = ".")) : 
duplicate 'row.names' are not allowed
In addition: Warning message:
non-unique values when setting 'row.names': ‘2.1’, ‘2.2’, ‘3.3’

while for example1.csv where the number of alternatives is constant

CHOICE,CUSTOMER,CHID,ALT,DIST,INCOME
1,1,1,1,100,70
0,1,1,2,372,70
0,1,1,3,417,70
0,1,2,1,180,70
1,1,2,2,68,70
0,1,2,3,354,70
0,2,3,1,68,100
0,2,3,2,354,100
1,2,3,3,399,100
1,2,4,1,180,100
0,2,4,2,100,100
0,2,4,3,80,100

everything is fine.

8k14
  • 103
  • 2
  • This main thrust of your question does not appear appropriate for SO, which is a "forum" for focused questions on programming problems. Please consider removing this question and posting a modified version on [CrossValidated](http://stats.stackexchange.com/) which would be more appropriate for questions on statistical methodology. I'm fairly sure that what your data cannot be modeled by a multinomial logit, regardless of the software involved. Translating into a binary outcome, we get that customers make a choice to purchase a distinct item from the menu with no overlap in the choice set. – lmo Jul 05 '17 at 12:14
  • Thanks @lmo. I hope that multinomial logit can't deal with my data. At least [this paper](http://facweb.knowlton.ohio-state.edu/pviton/courses2/crp5700/5700-mlogit.pdf) mentions varying choice sets – 8k14 Jul 05 '17 at 14:17
  • based on rich-scriven's suggestion, [here](https://stackoverflow.com/questions/26440404/mlogit-duplicate-row-names-are-not-allowed), this seems to work. `mlogit(CHOICE~DIST|INCOME, data=MLData, shape="long", alt.levels=unique(exData$ALT))`. Not sure what the difference is. – lmo Jul 05 '17 at 15:24
  • @lmo, thanks a lot. It works now. However I start to doubt if the specification of my model is correct... – 8k14 Jul 05 '17 at 20:21
  • Yeah. I'm not too familiar with this model and just started to read about it. At least for the `mnlogit` package, it appears that each "choice situation" must present the same choice set in each instance. Using `alt.levels` here may be forcing a balanced panel. – lmo Jul 05 '17 at 20:25
  • @lmo, as the alternatives are not categorized I start to doubt that multinomial logit is applicable in my case... – 8k14 Jul 06 '17 at 08:24
  • Take a look at my initial comment. I'd suggest that you post a statistical modelling question on CV. Describe your data in some detail -- sample size, choice set, etc. -- and then mention that you are investigating the use of multinomial logit but are concerned about certain issues (explain issues) and then ask if another model may be more appropriate. – lmo Jul 06 '17 at 11:52
  • @lmo, I've tried once but got no answer. Anyway thanks, I'll try once again. – 8k14 Jul 06 '17 at 14:59

0 Answers0