Multinomial logistic regression with mlogit (R)

I have been trying to use the mlogit package from R and it is really difficult. I pass here some notes to make it easier the next time:

  • The formula expression has 3 parts what it is really strange at first. The best explanation is here:

http://cran.r-project.org/web/packages/mnlogit/vignettes/mnlogit.pdf

,in chapter 2.4. Actually the different parts are a way to distribute the variables between variables that vary with the subject (the person or thing that does the choose) or variables that varies with the chooser plus the alternative value choosen.

  • Before using the training data you have to pass it through the mgit.data function to transform it in a long format
  • You have to pass also the test data through the mgit.data function and you have to make sure that you have a column for the variable that you want to predict (the value is indiferent), you have to say also the possible alternative values using alt.val
  • The result is given in probability matrix format for which you have to choose the value with highest probability

References: http://cran.r-project.org/web/packages/mlogit/vignettes/mlogit.pdf http://cran.r-project.org/web/packages/mlogit/vignettes/Exercises.pdf http://www.inside-r.org/packages/cran/mlogit/docs/suml http://elsa.berkeley.edu/books/train1201.pdf    ,for reference to the theory http://cran.r-project.org/web/packages/mnlogit/vignettes/mnlogit.pdf http://www.utstat.toronto.edu/~brunner/oldclass/312f12/lectures/MultinomialLogitWithR.pdf http://www.stat.columbia.edu/~martin/W2024/R11.pdf http://stats.stackexchange.com/questions/9962/multiclass-logistic-regression-with-mlogit-in-r http://stats.stackexchange.com/questions/6702/predict-after-running-the-mlogit-function-in-r

Anuncios

Responder

Introduce tus datos o haz clic en un icono para iniciar sesión:

Logo de WordPress.com

Estás comentando usando tu cuenta de WordPress.com. Cerrar sesión / Cambiar )

Imagen de Twitter

Estás comentando usando tu cuenta de Twitter. Cerrar sesión / Cambiar )

Foto de Facebook

Estás comentando usando tu cuenta de Facebook. Cerrar sesión / Cambiar )

Google+ photo

Estás comentando usando tu cuenta de Google+. Cerrar sesión / Cambiar )

Conectando a %s