[R] mlogit

cmc calum.mcconnell at gmail.com
Sun Mar 7 18:06:10 CET 2010



I am trying to follow this example for multinomial logistic regression

http://www.ats.ucla.edu/stat/r/dae/mlogit.htm

However, I cannot get it to work properly.

This is the output I get, and I get an error when I try to use the mlogit
function. Any ideas as to why this happens?



> mydata <- read.csv(url("http://www.ats.ucla.edu/stat/r/dae/mlogit.csv"))
> attach(mydata)
> names(mydata)
[1] "brand"  "female" "age"   
> library(mlogit)
Loading required package: Formula
Loading required package: statmod
> 
> mydata[1:10,]
   brand female age
1      1      0  24
2      1      0  26
3      1      0  26
4      1      1  27
5      1      1  27
6      3      1  27
7      1      0  27
8      1      0  27
9      1      1  27
10     1      0  27
> mydata$brand<-as.factor(mydata$brand)
> mldata<-mlogit.data(mydata, varying=NULL, choice="brand", shape="wide")
> 
> mldata[1:10,]
    brand female age
1.1  TRUE      0  24
1.2 FALSE      0  24
1.3 FALSE      0  24
2.1  TRUE      0  26
2.2 FALSE      0  26
2.3 FALSE      0  26
3.1  TRUE      0  26
3.2 FALSE      0  26
3.3 FALSE      0  26
4.1  TRUE      1  27
> mlogit.model<- mlogit(brand~1|female+age, data = mldata, reflevel="1")
Error in as.data.frame.default(data) : 
  cannot coerce class "call" into a data.frame
> summary(mlogit.model)
Error in summary(mlogit.model) : object 'mlogit.model' not found
> 
-- 
View this message in context: http://n4.nabble.com/mlogit-tp1583698p1583698.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list