[R-marketing-bugs] Error with mlogit

sree datta sreedta8 at gmail.com
Thu Oct 29 23:47:32 CET 2020


Hi

I was training some colleagues on use of mlogit (version 1.0-1 as specified
in the errata) for cbc using R and your example data set cbc.df in the
book. It still failed. Here is the output. I installed the package from a
local file

> install.packages("~/Downloads/mlogit_*1.0-1*.tar.gz", repos=NULL,
type="source")
Installing package into ‘/home/datasci/R/x86_64-pc-linux-gnu-library/4.0’
(as ‘lib’ is unspecified)
* installing *source* package ‘mlogit’ ...
** package ‘mlogit’ successfully unpacked and MD5 sums checked
** using staged installation
** R
** data
** inst
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
** building package indices
** installing vignettes
** testing if installed package can be loaded from temporary location
** testing if installed package can be loaded from final location
** testing if installed package keeps a record of temporary installation
path
* DONE (mlogit)
> library(mlogit)
> cbc.mlogit <- mlogit.data(data=cbc.df, choice="choice", shape="long",
+ varying =3:6, alt.levels= paste("pos" ,1:3), id.var="resp.id ")
Error in guess(varying) :
 failed to guess time-varying variables from their names
In addition: Warning message:
In dfidx::dfidx(data = data, dfa$idx, drop.index = dfa$drop.index,  :
 the levels shouldn't be provided with a data set in wide format

Next I tried version 1.0-0 of mlogit but no success still:

> install.packages("~/Downloads/mlogit_1.0-0.tar.gz", repos=NULL,
type="source")
Installing package into ‘/home/sreezach/R/x86_64-pc-linux-gnu-library/4.0’
(as ‘lib’ is unspecified)
* installing *source* package ‘mlogit’ ...
** package ‘mlogit’ successfully unpacked and MD5 sums checked
** using staged installation
** R
** data
** inst
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
** building package indices
** installing vignettes
** testing if installed package can be loaded from temporary location
** testing if installed package can be loaded from final location
** testing if installed package keeps a record of temporary installation
path
* DONE (mlogit)
> library(mlogit)
> cbc.mlogit <- mlogit.data(data=cbc.df, choice="choice", shape="long",
+ varying =3:6, alt.levels= paste("pos" ,1:3), id.var="resp.id ")
Error in guess(varying) :
 failed to guess time-varying variables from their names
In addition: Warning message:
In dfidx::dfidx(data = data, dfa$idx, drop.index = dfa$drop.index,  :
 the levels shouldn't be provided with a data set in wide format

Any help/feedback would be great. Thanks for an excellent book - my top
go-to reference book for my day-to-day R analytics and one I recommend the
most for a lot of colleagues and new R learners in analytics

Sree
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/r-marketing-bugs/attachments/20201029/78e9c080/attachment.html>


More information about the R-marketing-bugs mailing list