[R] mlogit: message "invalid 'row.names' length" after subsetting data

William Dunlap wdunlap at tibco.com
Thu Jan 30 20:22:09 CET 2014


> dd1 <- subset(dd, dd$Effect=='none')

Try using
   dd1 <- dd[dd$Effect=='none', ]
instead of that call to subset().  subset() strips
the non-data.frame attributes from its output.

It may be easier to use the subset argument to mlogit,
as in mlogit(..., subset = Effect=="none").

Bill Dunlap
TIBCO Software
wdunlap tibco.com


> -----Original Message-----
> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On Behalf
> Of craux
> Sent: Thursday, January 30, 2014 10:14 AM
> To: r-help at r-project.org
> Subject: [R] mlogit: message "invalid 'row.names' length" after subsetting data
> 
> Hi!
> I have been working a while with mlogit, estimating successfully a series of
> models.
> This time I have a series of discrete choice experiments with different
> effects to test (var Effect). I use the code below: when I estimate the
> first model with "dd" it's work fine. Then I perform subset dd into dd1,
> filtering the category of Effect "none", and I get the expected subset of
> experiment (1800 rows = choices). When I estimate the model with dd1 I get
> the error message "invalid 'row.names' length".
> What is wrong?
> -------
> library(mlogit)
> dd <- mlogit.data(Dataset, varying = 17:24, choice = "choice", id.var =
> "ID", shape = "wide", sep = "_")
> summary(m1 <- mlogit(choice ~ price + duration, dd))
> dd1 <- subset(dd, dd$Effect=='none')
> summary(m1 <- mlogit(choice ~ price + duration, dd1))
> ------
> 
> 
> 
> 
> --
> View this message in context: http://r.789695.n4.nabble.com/mlogit-message-invalid-
> row-names-length-after-subsetting-data-tp4684465.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