rmlogit

mlogit package in R: with alternative specific variables and without intercept


I'm new to R, and I'm trying to run a logit model with alternative specific variables and without intercept. I have checked the documentation, but it seems that when I run the model with alternative specific variables, the intercepts are always included. Could anyone kindly tell me how to run the model without intercept? Thanks. Below is what I have tried. I use the data set Fishing in the mlogit package in R.

m.fishing.1 <- mlogit(mode ~ price + catch | income, data = df.fishing, reflevel = "beach");

Solution

  • Use +0 in the model formula specification to exclude an intercept. From the help for mlogit::mFormula():

    data("Fishing", package = "mlogit")
    Fish <- mlogit.data(Fishing, varying = c(2:9), shape = "wide", choice =
                          "mode")    
    f3 <- mFormula(mode ~ price + catch | income + 0)
    mlogit(f3,Fish)
    

    ...and the output:

    > mlogit(f3,Fish)
    
    Call:
    mlogit(formula = mode ~ price + catch | income + 0, data = Fish,     method = "nr")
    
    Coefficients:
             price           catch     income:boat  income:charter     income:pier  
       -2.1597e-02      7.1208e-01      2.1014e-04      2.4498e-04      3.1272e-05  
    
    >