Package mnlogit. November 8, 2016

Similar documents
Package truncreg. R topics documented: August 3, 2016

Package oglmx. R topics documented: May 5, Type Package

Package sfa. R topics documented: February 20, 2015

Package glmmml. R topics documented: March 25, Encoding UTF-8 Version Date Title Generalized Linear Models with Clustering

Package addhaz. September 26, 2018

Package GWRM. R topics documented: July 31, Type Package

Package vinereg. August 10, 2018

Package mlogit. R topics documented: February 6, Version Date Title multinomial logit model

Package ridge. R topics documented: February 15, Title Ridge Regression with automatic selection of the penalty parameter. Version 2.

Multinomial Logit Models with R

Package gppm. July 5, 2018

Package colf. October 9, 2017

Package lgarch. September 15, 2015

Package cwm. R topics documented: February 19, 2015

Package bife. May 7, 2017

Package hgam. February 20, 2015

Package cosinor. February 19, 2015

Package palmtree. January 16, 2018

Package RWiener. February 22, 2017

The biglm Package. August 25, bigglm... 1 biglm Index 5. Bounded memory linear regression

Package mcemglm. November 29, 2015

Package survivalmpl. December 11, 2017

Package mreg. February 20, 2015

Package glmnetutils. August 1, 2017

Package RAMP. May 25, 2017

Package svapls. February 20, 2015

Package intccr. September 12, 2017

Package mlegp. April 15, 2018

Package BiDimRegression

Package ordinalcont. January 10, 2018

Package rpst. June 6, 2017

Package flexcwm. May 20, 2018

Package PrivateLR. March 20, 2018

Package SAM. March 12, 2019

Package dglm. August 24, 2016

Package nnet. R topics documented: March 20, Priority recommended. Version Date Depends R (>= 2.14.

The glmmml Package. August 20, 2006

Package glogis. R topics documented: March 16, Version Date

Package mrm. December 27, 2016

Package rfsa. R topics documented: January 10, Type Package

Package svalues. July 15, 2018

Package ihs. February 25, 2015

Package svmpath. R topics documented: August 30, Title The SVM Path Algorithm Date Version Author Trevor Hastie

Package rdd. March 14, 2016

Package ordinalnet. December 5, 2017

Package misclassglm. September 3, 2016

Package glinternet. June 15, 2018

Package milr. June 8, 2017

The grplasso Package

Package hiernet. March 18, 2018

Package mvprobit. November 2, 2015

Package MatchIt. April 18, 2017

Package maboost. R topics documented: February 20, 2015

Package marqlevalg. February 20, 2015

Package gee. June 29, 2015

Package merror. November 3, 2015

Package SAMUR. March 27, 2015

Package robustreg. R topics documented: April 27, Version Date Title Robust Regression Functions

Package EnsembleBase

Package PTE. October 10, 2017

Package Formula. July 11, 2017

Package robustfa. February 15, 2013

The supclust Package

Package calibrar. August 29, 2016

Package fcr. March 13, 2018

Package MSwM. R topics documented: February 19, Type Package Title Fitting Markov Switching Models Version 1.

Package freeknotsplines

Package msgps. February 20, 2015

Package obliquerf. February 20, Index 8. Extract variable importance measure

Package simr. April 30, 2018

Package listdtr. November 29, 2016

Package naivebayes. R topics documented: January 3, Type Package. Title High Performance Implementation of the Naive Bayes Algorithm

Package StVAR. February 11, 2017

Package lspls. July 27, 2018

Package caretensemble

Package mtsdi. January 23, 2018

Package bigreg. July 25, 2016

Maximum Likelihood estimation: Stata vs. Gauss

Package lmesplines. R topics documented: February 20, Version

Package BayesLogit. May 6, 2012

Package sfadv. June 19, 2017

Package robustfa. February 20, 2015

Package TANDEM. R topics documented: June 15, Type Package

Package kernelfactory

Package pampe. R topics documented: November 7, 2015

Package ConvergenceClubs

Package datasets.load

Package intreg. R topics documented: February 15, Version Date Title Interval Regression

Package MTLR. March 9, 2019

Package Modeler. May 18, 2018

Package GLMMRR. August 9, 2016

Package ICEbox. July 13, 2017

Package subsemble. February 20, 2015

Package EBglmnet. January 30, 2016

Package AnDE. R topics documented: February 19, 2015

Package RSNPset. December 14, 2017

Package rknn. June 9, 2015

Package CompGLM. April 29, 2018

Package treethresh. R topics documented: June 30, Version Date

Package SmoothHazard

Transcription:

Package mnlogit November 8, 2016 Type Package Title Multinomial Logit Model Version 1.2.5 Date 2016-11-6 Suggests VGAM, nnet Imports mlogit, lmtest, Formula, stats Author Asad Hasan, Wang Zhiyu, Alireza S. Mahani Maintainer Asad Hasan <asadhasan32@gmail.com> Description Time and memory efficient estimation of multinomial logit models using maximum likelihood method. Numerical optimization performed by Newton-Raphson method using an optimized, parallel C++ library to achieve fast computation of Hessian matrices. Motivated by large scale multiclass classification problems in econometrics and machine learning. License GPL (>= 2) NeedsCompilation yes Repository CRAN Date/Publication 2016-11-08 10:56:49 R topics documented: Fish............................................. 2 Hypothesis Testing..................................... 3 mnlogit........................................... 4 Index 9 1

2 Fish Fish Choice of Fishing Mode Description A data.frame containing data on choices of recreational fishing mode. Data may depend on both the individual and the alternative. number of observations : 1182 country : United States Usage data(fish) Format A dataframe containing : mode - recreation mode choice, one of : beach, pier, boat and charter price - price for a mode for an individual catch - fish catch rate for a mode for an individual income - monthly income of an individual chid - chooser ID: serial number of the individual Source Data taken from the R package mlogit by Yves Croissant, which lists the source as: Herriges, J. A. and C. L. Kling (1999) Nonlinear Income Effects in Random Utility Models, Review of Economics and Statistics, 81, 62-72. References Cameron, A.C. and P.K. Trivedi (2005) Microeconometrics : methods and applications, Cambridge, pp. 463 466, 486 and 491 495.

Hypothesis Testing 3 Hypothesis Testing Hypothesis testing for multinomial logit models Description Usage Three hypothesis tests applicable to any MLE (Likelihood ratio test, Wald test, Rao score test) and the Hausman-McFadden test for IIA (independence of irrelevant alternatives) are provided. lrtest(object,...) waldtest(object,...) scoretest(object,...) lrtest(object,...) scoretest(object,...) waldtest(object,...) hmftest(x,...) ## S3 method for class 'formula' hmftest(x, alt.subset,...) hmftest(x, z,...) Arguments object An fitted model which is an object of class mnlogit.... For lrtest and waldtest a fitted mnlogit object or a formula object maybe given. However for scoretest ONLY an fitted mnlogit is accepted. For hmftest either a subset of alternatives or an mnlogit object estimated using a subset of alternatives must be given. x z Value alt.subset A fitted object of class mnlogit or a formula object. An object of class mnlogit or a subset of alternatives for the hmftest.mnlogit method. Must be the same model as x estimated on a subset of alternatives. A subset of alternatives to do testing on. An object of class htest, with elements: statistic parameter data.name The value of the test statistic. the value of the underlying test distribution s parameter. In this case, the numbe r of degrees of freedom of chi-squared distribution. The data frame used.

4 mnlogit p.value method alternative Probability for accepting the null hypothesis. The name of the hypothesis test. Alternative hypothesis. Author(s) Asad Hasan, Wang Zhiyu, Alireza S. Mahani References Code for the last two tests (Score and IIA test) is gratefully adapted from the CRAN package mlogit, while the first 2 tests are performed by functions in the CRAN package lmtest. Croissant, Yves. Estimation of multinomial logit models in R: The mlogit Packages. Achim Zeileis, Torsten Hothorn (2002) Diagnostic Checking in Regression Relationships, R News 2(3), 7-10. Examples library(mnlogit) data(fish, package = "mnlogit") # Unconstrained model fm <- formula(mode ~ price income catch) fit <- mnlogit(fm, Fish) # Constrained model - intercep dropped fm.c <- formula(mode ~ price income - 1 catch) fit.c <- mnlogit(fm.c, Fish) ## MLE hypothesis tests lrtest(fit, fit.c) waldtest(fit, fit.c) scoretest(fit, fit.c) ## IIA test alt.subset <- c("beach", "boat", "charter") hmftest(fit, alt.subset) mnlogit Fast estimation of multinomial logit models Description Time and memory efficient estimation of multinomial logit models using maximum likelihood method. Targeted at large scale multiclass classification problems in econometrics and machine learning. Numerical optimization is performed by the Newton-Raphson method using an optimized, parallel C++ library to achieve fast computation of Hessian matrices. The user interface closely related to the CRAN package mlogit.

mnlogit 5 Usage mnlogit(formula, data, choicevar=null, maxiter = 50, ftol = 1e-6, gtol = 1e-6, weights = NULL, ncores = 1, na.rm = TRUE, print.level=0, lindeptol = 1e-6, start=null, alt.subset=null,...) fitted(object, outcome=true,...) residuals(object, outcome=true,...) df.residual(object,...) terms(x,...) update(object, new,...) print(x, digits = max(3, getoption("digits") - 2), width = getoption("width"), what = c("obj", "eststat", "modsize"),...) vcov(object,...) loglik(object,...) summary(object,...) print.summary(x, digits = max(3, getoption("digits") - 2), width = getoption("width"),... ) index(object,...) predict(object, newdata = NULL, probability = TRUE, returndata=false, choicevar=null,...) coef(object, order=false, as.list = FALSE,...) Arguments formula data, newdata choicevar formula object or string specifying the model to be estimated (see Note). A data.frame object with data organized in the long format (see Note).This can also be a mlogit.data class object. newdata is used in the predict method. A string naming the column in data which has the list of choices. Note: This argument is not used if data or newdata is a mlogit.data object. maxiter An integer indicating maximum number of Newton s iterations. If maxiter <= 0, then only Hessian, gradient and the loglikelihood are calculated at initial point. ftol gtol A real number indicating tolerance on the difference of two subsequent loglikelihood values. A real number indicating tolerance on norm of the gradient.

6 mnlogit Value weights ncores na.rm print.level lindeptol start alt.subset... Currently unused. object, x outcome new digits width what probability returndata order as.list Optional vector of (positive) frequency weights, one for each observation. An integer indicating number of processors allowed for Hessian calculations. a logical variable which indicates whether rows of the data frame containing NAs will be removed. An integer which controls the amount of information to be printed during execution. Tolerance for detecting linear dependence between columns in input data. Dependent columns are removed from the estimation. Named vector of coefficients to use as initial guess. Use naming convention as given by names(coeffit()), where fit is a mnlogit class object. Subset of alternatives to perform estimation on. An object of class mnlogit. a boolean which indicates, for the fitted and the residuals methods whether a matrix (for each choice, one value for each alternative) or a vector (for each choice, only a value for the alternative chosen) should be returned. An formula for the update method. It must obey all rules specified for the formula argument. Number of digits to print. The width of printing. Specifies what to print. Default option is obj is the print function for mnlogit objects. Option eststat prints etimation stats and option mdsize prints model size information. If TRUE predict output the probability matrix, otherwise the chocice with the highest probability for each observation is returned. If TRUE a data attribute is added to the returned object. If TRUE coefficients are ordered by variable name. Returns estimated model coefficients grouped by variable type. An object of class mnlogit, with elements: coefficients loglik gradient hessian est.stat fitted.values probabilities the named vector of coefficients. the value of the log-likelihood function at exit. the gradient of the log-likelihood function at exit. the Hessian of the log-likelihood function at exit. Newton Raphson stats. Estimated probabilities of the alternative selected in each observation. the probability matrix: (i,j) entry denotes the probability of the jth alternative being chosen in the ith observation.

mnlogit 7 residuals df AIC choices model.size ordered.coeff model freq formula call The residual. Has attribute outcome which is the probability of not choosing the selected alternative. The number of estimated coefficients in the model. The AIC value of the fitted model. The vector of alternatives s names. Information about number of parameters in model. Vector of coefficients ordered by variable name. The data.frame used in model estimation. The relative frequency of each choice in input data. The formula specifying the model. The mnlogit function call that user made, Note 1. The data must be in the long format. This means that for each observation there must be as many rows as there are alternatives (which should be grouped together). 2. The formula should be specified in the format: responsevar ~ choice specific variables with generic coefficients individual specific variables choice specific variables with choice specific coefficients. These are the 3 available variable types. 3. Any type of variables may be omitted. To omit use "1" as a placeholder. 4. An alternative specific intercept is included by default in the estimation. To omit it, use a -1 or 0 anywhere in the formula. Author(s) Asad Hasan, Wang Zhiyu, Alireza S. Mahani References Asad Hasan, Zhiyu Wang, Alireza S. Mahani (2016).Fast Estimation of Multinomial Logit Models: R Package mnlogit. Journal of Statistical Software, 75(3), 1-24. doi:10.18637/jss.v075.i03 Croissant, Yves. Estimation of multinomial logit models in R: The mlogit Packages. https:// cran.r-project.org/package=mlogit Train, K. (2004). Discrete Choice Methods with Simulation, Cambridge University Press. Examples library(mnlogit) data(fish, package = "mnlogit") fm <- formula(mode ~ price income catch) fit <- mnlogit(fm, Fish, ncores = 2) ## Not run: fit <- mnlogit(fm, Fish, choicevar="alt", ncores = 2) # same effect as previous

8 mnlogit summary(fit) print(fit) predict(fit) print(fit, what = "eststat") print(fit, what = "modsize") # Formula examples (see also Note) fm <- formula(mode ~ 1 income) # Only type-2 with intercept fm <- formula(mode ~ price - 1) # Only type-1, no intercept fm <- formula(mode ~ 1 1 catch) # Only type-3, including intercept ## End(Not run)

Index Topic datasets Fish, 2 Topic mnlogit, logistic, classification, multinomial, mlogit, parallel mnlogit, 4 coef.mnlogit (mnlogit), 4 df.residual.mnlogit (mnlogit), 4 Fish, 2 Fishing (Fish), 2 fitted.mnlogit (mnlogit), 4 hmftest (Hypothesis Testing), 3 Hypothesis Testing, 3 index (mnlogit), 4 loglik.mnlogit (mnlogit), 4 lrtest (Hypothesis Testing), 3 mnlogit, 4 predict.mnlogit (mnlogit), 4 print.est.stats (mnlogit), 4 print.mnlogit (mnlogit), 4 print.model.size (mnlogit), 4 print.summary.mnlogit (mnlogit), 4 residuals.mnlogit (mnlogit), 4 scoretest (Hypothesis Testing), 3 summary.mnlogit (mnlogit), 4 terms.mnlogit (mnlogit), 4 update.mnlogit (mnlogit), 4 vcov.mnlogit (mnlogit), 4 waldtest (Hypothesis Testing), 3 9