Rahul Chakraborty
2020-Sep-21 19:55 UTC
[R] Help with the Error Message in R "Error in 1:nchid : result would be too long a vector"
Hello everyone, I am using *mlogit* to analyse my choice experiment data. I have *3 alternatives* for each individual and for each individual I have *9 questions*. I have a response from *516 individuals*. So it is a panel of 9*516 observations. I have arranged the data in long format (it contains 100 columns indicating different variables and identifiers). In mlogit I tried the following command--- *mldata<- mlogit.data(mydata, shape = "long", alt.var = "Alt_name", choice = "Choice_binary", id.var = "IND")* It is giving me the following error message- Error in 1:nchid : result would be too long a vector Could you please help me with this? I don't think it is too big a data 100 ROWS*13932 columns. I faced no issue in Excel. I am stuck due to this issue. Thanks in advance. -- Best Regards, Rahul Chakraborty Research Fellow National Institute of Public Finance and Policy New Delhi- 110067 [[alternative HTML version deleted]]
David Winsemius
2020-Sep-21 20:14 UTC
[R] Help with the Error Message in R "Error in 1:nchid : result would be too long a vector"
If you had included output of summary(mydata) we might be more capable of giving a fact-based answer but I'm guessing that you have a lot of catagorical variables with multiple levels and some sort of combinatoric explosion is resulting in too many levels of a constructed factor. -- David. On 9/21/20 12:55 PM, Rahul Chakraborty wrote:> Hello everyone, > > I am using *mlogit* to analyse my choice experiment data. I have *3 > alternatives* for each individual and for each individual I have *9 > questions*. I have a response from *516 individuals*. So it is a panel of > 9*516 observations. I have arranged the data in long format (it contains > 100 columns indicating different variables and identifiers). > > In mlogit I tried the following command--- > > *mldata<- mlogit.data(mydata, shape = "long", alt.var = "Alt_name", choice > = "Choice_binary", id.var = "IND")* > > It is giving me the following error message- Error in 1:nchid : result > would be too long a vector > > Could you please help me with this? I don't think it is too big a data 100 > ROWS*13932 columns. I faced no issue in Excel. I am stuck due to this issue. > Thanks in advance. > > -- Best Regards, > Rahul Chakraborty > Research Fellow > National Institute of Public Finance and Policy > New Delhi- 110067 > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at 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.
Rahul Chakraborty
2020-Sep-21 20:37 UTC
[R] Help with the Error Message in R "Error in 1:nchid : result would be too long a vector"
Hello, Here is the result of summary(mydata) summary(mydata) IND Block QES STR ALT Min. : 1.0 Min. :1.000 Min. :1 Min. : 101 Min. :1 1st Qu.:129.8 1st Qu.:1.000 1st Qu.:3 1st Qu.:12978 1st Qu.:1 Median :258.5 Median :2.000 Median :5 Median :25855 Median :2 Mean :258.5 Mean :2.467 Mean :5 Mean :25855 Mean :2 3rd Qu.:387.2 3rd Qu.:4.000 3rd Qu.:7 3rd Qu.:38732 3rd Qu.:3 Max. :516.0 Max. :4.000 Max. :9 Max. :51609 Max. :3 ALT_name ASC Choice Choice_binary Length:13932 Min. :0.0000 Min. :1.000 Min. :0.0000 Class :character 1st Qu.:0.0000 1st Qu.:1.000 1st Qu.:0.0000 Mode :character Median :1.0000 Median :1.000 Median :0.0000 Mean :0.6667 Mean :1.626 Mean :0.3333 3rd Qu.:1.0000 3rd Qu.:2.000 3rd Qu.:1.0000 Max. :1.0000 Max. :3.000 Max. :1.0000 Price Refuel_availability Registration_charges Running_cost Min. : 9.00 Min. :0.25 Min. :0.00000 Min. :115.0 1st Qu.:10.00 1st Qu.:0.75 1st Qu.:0.04000 1st Qu.:192.0 Median :10.00 Median :0.90 Median :0.06000 Median :268.0 Mean :10.33 Mean :0.80 Mean :0.05333 Mean :268.2 3rd Qu.:11.00 3rd Qu.:1.00 3rd Qu.:0.08000 3rd Qu.:383.0 Max. :12.00 Max. :1.00 Max. :0.08000 Max. :383.0 Market_share Friends_share Refuel_time Emission Min. :0.0500 Min. :0.0000 Min. : 5.00 Min. :0.0000 1st Qu.:0.1500 1st Qu.:0.1500 1st Qu.: 5.00 1st Qu.:0.0000 Median :0.2500 Median :0.3000 Median : 5.00 Median :0.7500 Mean :0.3333 Mean :0.3333 Mean :13.33 Mean :0.5833 3rd Qu.:0.6000 3rd Qu.:0.5500 3rd Qu.:30.00 3rd Qu.:1.0000 Max. :0.9000 Max. :1.0000 Max. :30.00 Max. :1.0000 Sex Age2 Age3 Age4 Min. :0.0000 Min. :0.0000 Min. :0.0000 Min. :0.0000 1st Qu.:1.0000 1st Qu.:0.0000 1st Qu.:0.0000 1st Qu.:0.0000 Median :1.0000 Median :0.0000 Median :0.0000 Median :0.0000 Mean :0.7791 Mean :0.4574 Mean :0.2326 Mean :0.1531 3rd Qu.:1.0000 3rd Qu.:1.0000 3rd Qu.:0.0000 3rd Qu.:0.0000 Max. :1.0000 Max. :1.0000 Max. :1.0000 Max. :1.0000 Edu_PG Edu_Oth Occu_Pvt Occu_Pub Min. :0.0000 Min. :0.0000 Min. :0.000 Min. :0.0000 1st Qu.:0.0000 1st Qu.:0.0000 1st Qu.:0.000 1st Qu.:0.0000 Median :0.0000 Median :0.0000 Median :0.000 Median :0.0000 Mean :0.4147 Mean :0.1841 Mean :0.376 Mean :0.2733 3rd Qu.:1.0000 3rd Qu.:0.0000 3rd Qu.:1.000 3rd Qu.:1.0000 Max. :1.0000 Max. :1.0000 Max. :1.000 Max. :1.0000 Occu_SE Location_metro Location_majorcity Ahm Min. :0.0000 Min. :0.0000 Min. :0.0000 Min. :0.00000 1st Qu.:0.0000 1st Qu.:1.0000 1st Qu.:0.0000 1st Qu.:0.00000 Median :0.0000 Median :1.0000 Median :0.0000 Median :0.00000 Mean :0.2655 Mean :0.7655 Mean :0.1453 Mean :0.04457 3rd Qu.:1.0000 3rd Qu.:1.0000 3rd Qu.:0.0000 3rd Qu.:0.00000 Max. :1.0000 Max. :1.0000 Max. :1.0000 Max. :1.00000 Ben Chen NCR Hyd Min. :0.00000 Min. :0.00000 Min. :0.0000 Min. :0.00000 1st Qu.:0.00000 1st Qu.:0.00000 1st Qu.:0.0000 1st Qu.:0.00000 Median :0.00000 Median :0.00000 Median :0.0000 Median :0.00000 Mean :0.06977 Mean :0.04651 Mean :0.2558 Mean :0.03682 3rd Qu.:0.00000 3rd Qu.:0.00000 3rd Qu.:1.0000 3rd Qu.:0.00000 Max. :1.00000 Max. :1.00000 Max. :1.0000 Max. :1.00000 Kol Mum MajCity HH_size Min. :0.0000 Min. :0.0000 Min. :0.0000 Min. : 1.000 1st Qu.:0.0000 1st Qu.:0.0000 1st Qu.:0.0000 1st Qu.: 3.000 Median :0.0000 Median :0.0000 Median :0.0000 Median : 5.000 Mean :0.2016 Mean :0.1105 Mean :0.1453 Mean : 4.463 3rd Qu.:0.0000 3rd Qu.:0.0000 3rd Qu.:0.0000 3rd Qu.: 6.000 Max. :1.0000 Max. :1.0000 Max. :1.0000 Max. :10.000 Children IG2 IG3 IG4 Min. :0.0000 Min. :0.0000 Min. :0.0000 Min. :0.0000 1st Qu.:0.0000 1st Qu.:0.0000 1st Qu.:0.0000 1st Qu.:0.0000 Median :1.0000 Median :0.0000 Median :0.0000 Median :0.0000 Mean :0.8721 Mean :0.3818 Mean :0.4109 Mean :0.1841 3rd Qu.:1.0000 3rd Qu.:1.0000 3rd Qu.:1.0000 3rd Qu.:0.0000 Max. :4.0000 Max. :1.0000 Max. :1.0000 Max. :1.0000 HH_cars PPC_morethan10 PPC_gr1 PPC_gr2 Min. :0.0000 Min. :0.0000 Min. :0.000 Min. :0.00000 1st Qu.:0.0000 1st Qu.:0.0000 1st Qu.:0.000 1st Qu.:0.00000 Median :0.0000 Median :0.0000 Median :0.000 Median :0.00000 Mean :0.4864 Mean :0.4516 Mean :0.405 Mean :0.04651 3rd Qu.:1.0000 3rd Qu.:1.0000 3rd Qu.:1.000 3rd Qu.:0.00000 Max. :3.0000 Max. :1.0000 Max. :1.000 Max. :1.00000 Body_Sedan Body_SUV Daily_travel_medium Daily_travel_long Min. :0.0000 Min. :0.0000 Min. :0.0000 Min. :0.00000 1st Qu.:0.0000 1st Qu.:0.0000 1st Qu.:0.0000 1st Qu.:0.00000 Median :0.0000 Median :0.0000 Median :0.0000 Median :0.00000 Mean :0.3178 Mean :0.2364 Mean :0.3702 Mean :0.02713 3rd Qu.:1.0000 3rd Qu.:0.0000 3rd Qu.:1.0000 3rd Qu.:0.00000 Max. :1.0000 Max. :1.0000 Max. :1.0000 Max. :1.00000 Long_drive Mode_Carpool Mode_PB Mode_PV Min. :0.00000 Min. :0.00000 Min. :0.0000 Min. :0.0000 1st Qu.:0.00000 1st Qu.:0.00000 1st Qu.:0.0000 1st Qu.:0.0000 Median :0.00000 Median :0.00000 Median :0.0000 Median :0.0000 Mean :0.03488 Mean :0.02519 Mean :0.2907 Mean :0.4419 3rd Qu.:0.00000 3rd Qu.:0.00000 3rd Qu.:1.0000 3rd Qu.:1.0000 Max. :1.00000 Max. :1.00000 Max. :1.0000 Max. :1.0000 Mode_WRC Garage_y DL_y Own_accom Min. :0.000000 Min. :0.0000 Min. :0.0000 Min. :0.0000 1st Qu.:0.000000 1st Qu.:0.0000 1st Qu.:0.0000 1st Qu.:0.0000 Median :0.000000 Median :1.0000 Median :1.0000 Median :1.0000 Mean :0.007752 Mean :0.7267 Mean :0.6357 Mean :0.6647 3rd Qu.:0.000000 3rd Qu.:1.0000 3rd Qu.:1.0000 3rd Qu.:1.0000 Max. :1.000000 Max. :1.0000 Max. :1.0000 Max. :1.0000 Freerider_water_electricity Freerider_tot Freerider_avg Satisfaction_tot Min. :1.000 Min. :2.000 Min. :1.000 Min. : 2.000 1st Qu.:2.000 1st Qu.:2.000 1st Qu.:1.000 1st Qu.: 3.000 Median :3.000 Median :2.000 Median :1.000 Median : 4.000 Mean :3.002 Mean :2.244 Mean :1.122 Mean : 4.264 3rd Qu.:4.000 3rd Qu.:2.000 3rd Qu.:1.000 3rd Qu.: 5.000 Max. :5.000 Max. :8.000 Max. :4.000 Max. :10.000 Satisfaction_avg Political_view Meet_friends Meet_colleagues Min. :1.000 Min. :1.000 Length:13932 Length:13932 1st Qu.:1.500 1st Qu.:3.000 Class :character Class :character Median :2.000 Median :3.000 Mode :character Mode :character Mean :2.132 Mean :3.258 3rd Qu.:2.500 3rd Qu.:4.000 Max. :5.000 Max. :5.000 Meet_relatives Invite_colleagues Invite_friends Invite_relatives Length:13932 Length:13932 Length:13932 Length:13932 Class :character Class :character Class :character Class :character Mode :character Mode :character Mode :character Mode :character Lending_relatives Lending_friends Lending_colleagues Length:13932 Length:13932 Length:13932 Class :character Class :character Class :character Mode :character Mode :character Mode :character Willingness_Purchase_Env_frnd EVuse_pollution WTP_env_tot WTP_env_avg Min. :1.000 Min. :1.000 Min. : 2.000 Min. :1.000 1st Qu.:4.000 1st Qu.:3.000 1st Qu.: 7.000 1st Qu.:3.500 Median :4.000 Median :4.000 Median : 8.000 Median :4.000 Mean :4.132 Mean :3.992 Mean : 8.124 Mean :4.062 3rd Qu.:5.000 3rd Qu.:5.000 3rd Qu.: 9.000 3rd Qu.:4.500 Max. :5.000 Max. :5.000 Max. :10.000 Max. :5.000 Social_recognition Car_social_status Warmglow_tot Warmglow_avg Min. :1.000 Min. :1.00 Min. : 2.00 Min. :1.000 1st Qu.:3.000 1st Qu.:4.00 1st Qu.: 6.00 1st Qu.:3.000 Median :4.000 Median :4.00 Median : 8.00 Median :4.000 Mean :3.541 Mean :4.07 Mean : 7.61 Mean :3.805 3rd Qu.:4.000 3rd Qu.:5.00 3rd Qu.: 9.00 3rd Qu.:4.500 Max. :5.000 Max. :5.00 Max. :10.00 Max. :5.000 Standout Acceptance_new Climate_perception Env_pref Tech_leader Min. :1.000 Min. :1.0 Min. :1.000 Min. :1.000 Min. :1.0 1st Qu.:2.000 1st Qu.:2.0 1st Qu.:4.000 1st Qu.:2.000 1st Qu.:2.0 Median :3.000 Median :3.0 Median :5.000 Median :3.000 Median :2.0 Mean :2.657 Mean :2.8 Mean :4.483 Mean :3.093 Mean :2.5 3rd Qu.:3.000 3rd Qu.:4.0 3rd Qu.:5.000 3rd Qu.:4.000 3rd Qu.:3.0 Max. :5.000 Max. :5.0 Max. :5.000 Max. :5.000 Max. :5.0 Social_motivation_tot Social_motivation_avg Social_motivation_median Min. : 3.00 Min. :1.000 Min. :1.000 1st Qu.: 9.00 1st Qu.:3.000 1st Qu.:3.000 Median :11.00 Median :3.667 Median :3.000 Mean :10.62 Mean :3.539 Mean :3.514 3rd Qu.:12.00 3rd Qu.:4.000 3rd Qu.:4.000 Max. :15.00 Max. :5.000 Max. :5.000 EV_risk_tot EV_risk_avg EV_price EV_awareness_tot EV_awareness_avg Min. : 2.000 Min. :1.00 Min. :1.000 Min. : 3.000 Min. :1.000 1st Qu.: 8.000 1st Qu.:4.00 1st Qu.:1.000 1st Qu.: 4.000 1st Qu.:1.333 Median : 9.000 Median :4.50 Median :2.000 Median : 5.000 Median :1.667 Mean : 8.661 Mean :4.33 Mean :2.244 Mean : 5.419 Mean :1.806 3rd Qu.:10.000 3rd Qu.:5.00 3rd Qu.:3.000 3rd Qu.: 6.000 3rd Qu.:2.000 Max. :10.000 Max. :5.00 Max. :5.000 Max. :15.000 Max. :5.000 EV_awareness_median Lost_env Investment_trust Lottery1 Min. :1.000 Min. :1.000 Min. : 0 Length:13932 1st Qu.:1.000 1st Qu.:5.000 1st Qu.: 0 Class :character Median :2.000 Median :5.000 Median : 0 Mode :character Mean :1.806 Mean :4.913 Mean : 1345 3rd Qu.:2.000 3rd Qu.:5.000 3rd Qu.: 0 Max. :5.000 Max. :5.000 Max. :100000 Time1 Lottery2 Time2 Length:13932 Length:13932 Length:13932 Class :character Class :character Class :character Mode :character Mode :character Mode :character Yes, I have many Likert items and many dummy variables. How do I solve this issue? Best regards, On Tue, Sep 22, 2020 at 1:45 AM David Winsemius <dwinsemius at comcast.net> wrote:> If you had included output of summary(mydata) we might be more capable > of giving a fact-based answer but I'm guessing that you have a lot of > catagorical variables with multiple levels and some sort of combinatoric > explosion is resulting in too many levels of a constructed factor. > > > -- > > David. > > On 9/21/20 12:55 PM, Rahul Chakraborty wrote: > > Hello everyone, > > > > I am using *mlogit* to analyse my choice experiment data. I have *3 > > alternatives* for each individual and for each individual I have *9 > > questions*. I have a response from *516 individuals*. So it is a panel of > > 9*516 observations. I have arranged the data in long format (it contains > > 100 columns indicating different variables and identifiers). > > > > In mlogit I tried the following command--- > > > > *mldata<- mlogit.data(mydata, shape = "long", alt.var = "Alt_name", > choice > > = "Choice_binary", id.var = "IND")* > > > > It is giving me the following error message- Error in 1:nchid : result > > would be too long a vector > > > > Could you please help me with this? I don't think it is too big a data > 100 > > ROWS*13932 columns. I faced no issue in Excel. I am stuck due to this > issue. > > Thanks in advance. > > > > -- Best Regards, > > Rahul Chakraborty > > Research Fellow > > National Institute of Public Finance and Policy > > New Delhi- 110067 > > > > [[alternative HTML version deleted]] > > > > ______________________________________________ > > R-help at 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. >-- Rahul Chakraborty Research Fellow National Institute of Public Finance and Policy New Delhi- 110067 [[alternative HTML version deleted]]