Hello David and everyone,

I am really sorry for not abiding by the specific guidelines in my
prior communications. I tried to convert the present email in plain
text format (at least it is showing me so in my gmail client). I have
also converted the xlsx file into a csv format with .txt extension.

So, my problem is I need to run panel mixed logit regression for a
choice model. There are 3 alternatives, 9 questions for each
individual and 516 individuals in data. I have created a csv file in
long format from the survey questionnaire. Apart from the alternative
specific variables I have many individual specific variables and most
of these are dummies (dummy coded). I will use subsets of these in my
alternative model specifications. So, in my data I have 100 columns
with 13932 rows (3*9*516). After reading the csv file and creating a
dataframe 'mydata' I used the following command for mlogit.

mldata1<- mlogit.data(mydata, shape = "long", alt.var = "Alt_name",
choice = "Choice_binary", id.var = "IND")

It gives me the same error message- Error in 1:nchid : result would be
too long a vector.

The attached file (csv file with .txt extension) is an example of 2
individuals each with 3 questions. I have also reduced the number of
columns to 57. Now, there are 18 rows. But still if I use the same
command on my new data I get the same error message. Can anyone please
help me out with this? Because of this error I am stuck at the
dataframe level.


Thanks in advance.


Regards,
Rahul Chakraborty

On Tue, Sep 22, 2020 at 4:50 AM David Winsemius <dwinsem...@comcast.net> wrote:
>
> @Rahul;
>
>
> You need to learn to post in plain text and attachments may not be xls
> or xlsx. They need to be text files. And even if they are comma
> separated files and text, they still need to be named with a txt extension.
>
>
> I'm the only one who got the xlsx file. I got the error regardless of
> how many column I omitted, so my gues was possibly incorrect. But I did
> RTFM. See ?mlogit.datadfi The mlogit.data function is deprecated and you
> are told to use the dfidx function. Trying that you now get an error
> saying: " the two indexes don't define unique observations".
>
>
>  > sum(duplicated( dfrm[,1:2]))
> [1] 12
>  > length(dfrm[,1])
> [1] 18
>
> So of your 18 lines in the example file, most of them appear to be
> duplicated in their first two rows and apparently that is not allowed by
> dfidx.
>
>
> Caveat: I'm not a user of the mlogit package so I'm just reading the
> manual and possibly coming up with informed speculation.
>
> Please read the Posting Guide. You have been warned. Repeated violations
> of the policies laid down in that hallowed document will possibly result
> in postings being ignored.
>
IND,QES,STR,ALT_name,Choice_binary,Price,Refuel_availability,Registration_charges,Running_cost,Market_share,Friends_share,Refuel_time,Emission,Sex,Age2,Age3,Age4,Edu_PG,Edu_Oth,Occu_Pvt,Occu_Pub,Occu_SE,Location_metro,Location_majorcity,Ahm,Ben,Chen,NCR,Hyd,Kol,Mum,MajCity,HH_size,Children,IG2,IG3,IG4,HH_cars,PPC_morethan10,Daily_travel_medium,Daily_travel_long,Garage_y,DL_y,Own_accom,Freerider_tot,Satisfaction_tot,Political_view,WTP_env_tot,Warmglow_tot,Standout,Acceptance_new,Climate_perception,Env_pref,Tech_leader,Social_motivation_tot,EV_risk_tot,EV_awareness_tot
1,1,101,Hybrid,1,11,0.8,0.08,268,0.25,0.15,5,0.75,1,1,0,0,1,0,1,0,0,1,0,0,0,0,0,0,0,1,0,1,0,0,0,1,0,1,0,0,0,0,0,2,3,3,8,4,3,2,5,1,1,12,6,3
1,1,101,Electric,0,10,0.5,0.02,115,0.25,0,30,0,1,1,0,0,1,0,1,0,0,1,0,0,0,0,0,0,0,1,0,1,0,0,0,1,0,1,0,0,0,0,0,2,3,3,8,4,3,2,5,1,1,12,6,3
1,1,101,Petrol,0,10,1,0.08,383,0.5,0.85,5,1,1,1,0,0,1,0,1,0,0,1,0,0,0,0,0,0,0,1,0,1,0,0,0,1,0,1,0,0,0,0,0,2,3,3,8,4,3,2,5,1,1,12,6,3
1,2,102,Hybrid,1,10,0.8,0.08,230,0.25,0,5,0.75,1,1,0,0,1,0,1,0,0,1,0,0,0,0,0,0,0,1,0,1,0,0,0,1,0,1,0,0,0,0,0,2,3,3,8,4,3,2,5,1,1,12,6,3
1,2,102,Electric,0,12,0.5,0.04,153,0.05,0.15,30,0,1,1,0,0,1,0,1,0,0,1,0,0,0,0,0,0,0,1,0,1,0,0,0,1,0,1,0,0,0,0,0,2,3,3,8,4,3,2,5,1,1,12,6,3
1,2,102,Petrol,0,10,1,0.08,383,0.7,0.85,5,1,1,1,0,0,1,0,1,0,0,1,0,0,0,0,0,0,0,1,0,1,0,0,0,1,0,1,0,0,0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,2,202,Petrol,0,10,1,0.08,383,0.7,0.7,5,1,1,1,0,0,1,0,1,0,0,1,0,0,0,0,0,0,1,0,0,3,0,1,0,0,0,0,0,0,0,0,1,2,6,4,8,4,2,2,5,2,3,10,9,12
2,3,203,Hybrid,1,10,0.8,0.04,307,0.25,0.15,5,0.75,1,1,0,0,1,0,1,0,0,1,0,0,0,0,0,0,1,0,0,3,0,1,0,0,0,0,0,0,0,0,1,2,6,4,8,4,2,2,5,2,3,10,9,12
2,3,203,Electric,0,11,0.25,0.04,115,0.15,0.3,30,0,1,1,0,0,1,0,1,0,0,1,0,0,0,0,0,0,1,0,0,3,0,1,0,0,0,0,0,0,0,0,1,2,6,4,8,4,2,2,5,2,3,10,9,12
2,3,203,Petrol,0,10,1,0.08,383,0.6,0.55,5,1,1,1,0,0,1,0,1,0,0,1,0,0,0,0,0,0,1,0,0,3,0,1,0,0,0,0,0,0,0,0,1,2,6,4,8,4,2,2,5,2,3,10,9,12
______________________________________________
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