I have two vectors (A and B) with categorical data of 36 subjects. A_i,j being the categorytype1 j, subject i fits into and B_i,k is categorytype2 k of subject i. With i=1:36, j=1:5 and k=1:6.
library(mlogit)
AB <- read.csv("C:/.../AB.csv")
head(AB)
Subject A B
1 1 1 3
2 2 3 3
3 3 1 6
4 4 1 3
5 5 1 2
6 6 1 4
I would like to find a probability for every category combination. So with what chance does a subject choose category j and k for all j=1:5 and k=1:6.
I was told the probit/logit model was a great tool to use for this problem and I tried estimating it in R.
mldata<-mlogit.data(AB, choice="A", alt.var="B", shape="long", id.var = "Subject")
Gives me an error and I can not find my mistake.
Error in `row.names<-.data.frame`(`*tmp*`, value = c("1.3", "1.3", "1.6", :
duplicate 'row.names' are not allowed
In addition: Warning message:
non-unique values when setting 'row.names': ‘1.3’, ‘2.2’, ‘2.3’, ‘3.1’,‘3.5’,‘4.2’,‘4.3’, ‘5.3’, ‘5.4’, ‘6.5’, ‘7.3’, ‘8.2’, ‘8.3’
I tried looking through the help files but has not helped me a lot.
I hope someone can point out the mistake(s) I'm making.
Thank you very much for your help.