Hello,

Please keep this on the list so that others can give their contribution.

If you have reshaped your data can you post the code you ran to reshape it? Right now we only have the original attachment, in wide format, not the long format data.

Rui Barradas

Às 21:55 de 22/09/20, Rahul Chakraborty escreveu:
Hi,

Thank you so much for your reply.
Yes, thank you for pointing that out, I apologise for that error in
the variable name. However, my data is in long format.

See, my first column is IND which identifies my individuals,
second column is QES which identifies the question number each
individual faces, 3rd column is a stratification code that can be
ignored. Columns 6-13 are alternative specific variables and rest are
individual specific. So 1st 3 rows indicate 1st question faced by 1st
individual containing 3 alternatives, and so on. So, I have already
arranged the data in long format.

With that in mind if I use shape="long" it still gives me error.

Best  regards,

On Tue, Sep 22, 2020 at 11:00 PM Rui Barradas <ruipbarra...@sapo.pt> wrote:

Hello,

I apologize if the rest of quotes prior to David's email are missing,
for some reason today my mail client is not including them.

As for the question, there are two other problems:

1) Alt_name is misspelled, it should be ALT_name;

2) the data is in wide, not long, format.

A 3rd, problem is that in ?dfidx it says

alt.var
the name of the variable that contains the alternative index (for a long
data.frame only) or the name under which the alternative index will be
stored (the default name is alt)


So if shape = "wide", alt.var is not needed.
But I am not a user of package mlogit, I'm just guessing.

The following seems to fix it (it doesn't throw errors).


mldata1 <- dfidx(mydata, shape = "wide",
                   #alt.var = "ALT_name",
                   choice = "Choice_binary",
                   id.var = "IND")


Hope this helps,

Rui Barradas


Às 16:15 de 22/09/20, David Winsemius escreveu:
You were told two things about your code:


1) mlogit.data is deprecated by the package authors, so use dfidx.

2) dfidx does not allow duplicate ids in the first two columns.


Which one of those are you asserting is not accurate?






______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to