Skip to content
Prev 385738 / 398503 Next

Help with the Error Message in R "Error in 1:nchid : result would be too long a vector"

Hello,

I tried to reduce the size of my dataframe. Now I have 57 columns of which
29 are already dummy coded. If I run   *mldata1<- mlogit.data(mydata1,
shape = "long", alt.var = "Alt_name", choice = "Choice_binary", id.var =
"IND") *it still gives me the same error message-* Error in 1:nchid :
result would be too long a vector. *

I will not use all of those variables in one regression model, but I need
those for different model specifications. The Excel file I created from my
survey looks like the attached file. The main data is a panel of 516
individuals each answering 9 questions over 3 alternatives.

Following is the output of the summary of the dataframe.

summary(mydata1)
      IND             QES         STR          ALT_name
Choice_binary
 Min.   :  1.0   Min.   :1   Min.   :  101   Length:13932       Min.
:0.0000
 1st Qu.:129.8   1st Qu.:3   1st Qu.:12978   Class :character   1st
Qu.:0.0000
 Median :258.5   Median :5   Median :25855   Mode  :character   Median
:0.0000
 Mean   :258.5   Mean   :5   Mean   :25855                      Mean
:0.3333
 3rd Qu.:387.2   3rd Qu.:7   3rd Qu.:38732                      3rd
Qu.:1.0000
 Max.   :516.0   Max.   :9   Max.   :51609                      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   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.4864   Mean   :0.4516   Mean   :0.3702      Mean   :0.02713
 3rd Qu.:1.0000   3rd Qu.:1.0000   3rd Qu.:1.0000      3rd Qu.:0.00000
 Max.   :3.0000   Max.   :1.0000   Max.   :1.0000      Max.   :1.00000
    Garage_y           DL_y          Own_accom      Freerider_tot
 Min.   :0.0000   Min.   :0.0000   Min.   :0.0000   Min.   :2.000
 1st Qu.:0.0000   1st Qu.:0.0000   1st Qu.:0.0000   1st Qu.:2.000
 Median :1.0000   Median :1.0000   Median :1.0000   Median :2.000
 Mean   :0.7267   Mean   :0.6357   Mean   :0.6647   Mean   :2.244
 3rd Qu.:1.0000   3rd Qu.:1.0000   3rd Qu.:1.0000   3rd Qu.:2.000
 Max.   :1.0000   Max.   :1.0000   Max.   :1.0000   Max.   :8.000
 Satisfaction_tot Political_view   WTP_env_tot      Warmglow_tot
 Standout
 Min.   : 2.000   Min.   :1.000   Min.   : 2.000   Min.   : 2.00   Min.
:1.000
 1st Qu.: 3.000   1st Qu.:3.000   1st Qu.: 7.000   1st Qu.: 6.00   1st
Qu.:2.000
 Median : 4.000   Median :3.000   Median : 8.000   Median : 8.00   Median
:3.000
 Mean   : 4.264   Mean   :3.258   Mean   : 8.124   Mean   : 7.61   Mean
:2.657
 3rd Qu.: 5.000   3rd Qu.:4.000   3rd Qu.: 9.000   3rd Qu.: 9.00   3rd
Qu.:3.000
 Max.   :10.000   Max.   :5.000   Max.   :10.000   Max.   :10.00   Max.
:5.000
 Acceptance_new Climate_perception    Env_pref      Tech_leader
 Min.   :1.0    Min.   :1.000      Min.   :1.000   Min.   :1.0
 1st Qu.:2.0    1st Qu.:4.000      1st Qu.:2.000   1st Qu.:2.0
 Median :3.0    Median :5.000      Median :3.000   Median :2.0
 Mean   :2.8    Mean   :4.483      Mean   :3.093   Mean   :2.5
 3rd Qu.:4.0    3rd Qu.:5.000      3rd Qu.:4.000   3rd Qu.:3.0
 Max.   :5.0    Max.   :5.000      Max.   :5.000   Max.   :5.0
 Social_motivation_tot  EV_risk_tot     EV_awareness_tot
 Min.   : 3.00         Min.   : 2.000   Min.   : 3.000
 1st Qu.: 9.00         1st Qu.: 8.000   1st Qu.: 4.000
 Median :11.00         Median : 9.000   Median : 5.000
 Mean   :10.62         Mean   : 8.661   Mean   : 5.419
 3rd Qu.:12.00         3rd Qu.:10.000   3rd Qu.: 6.000
 Max.   :15.00         Max.   :10.000   Max.   :15.000

On Tue, Sep 22, 2020 at 2:07 AM Rahul Chakraborty <chakrarahul at gmail.com>
wrote: