[R] length of variable in mlogit

R. Michael Weylandt michael.weylandt at gmail.com
Sun Aug 12 18:15:19 CEST 2012


Hi Lee,

I've finally had time to look at this:

If you look at

?mlogit.data

you'll see that choice must be "the variable indicating the choice
made: it can be either a logical vector, a numerical vector with 0
where the alternative is not chosen, a factor with level 'yes' when
the alternative is chosen."

For the data and script you provided me, we have a few problems:
firstly, masterdata.wide should be a data.frame, not a matrix -- this
can be rectified by wrapping it in as.data.frame. Once you do that,
take a look at the column "Y" which you supply for the choice
variable. It is a numerical vector, but it has no 0's so it doesn't
fit the requested input format.

For anyone else who wants to look at this:

dput(masterdata.wide)

structure(c(1, 2, 1, 4, 1, 5, 4, 1, 4, 3, 1, 2, 4, 0, 1, 0, 0,
0, 0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 1, 0, 0, 1, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), .Dim = c(13L, 7L), .Dimnames = list(
    NULL, c("Y", "X.2", "X.3", "X.4", "X.5", "X.6", "X.7")), na.action
= structure(c(1,
3, 7, 8, 12, 14, 17), class = "omit"))

Hope that helps,
Michael

On Fri, Aug 10, 2012 at 2:31 AM, Lee van Cleef <l.van.cleef at gmx.net> wrote:
> Hi Michael,
>
> I have sent youi the data.
>
> Best,
> Lee
>
>
>
>
> --
> View this message in context: http://r.789695.n4.nabble.com/length-of-variable-in-mlogit-tp4638323p4639873.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.



More information about the R-help mailing list