David,
Here's my sessionInfo:
> sessionInfo()
R version 2.11.0 Under development (unstable) (2010-03-02 r51195)
i386-pc-mingw32
locale:
[1] LC_COLLATE=English_Canada.1252 LC_CTYPE=English_Canada.1252
[3] LC_MONETARY=English_Canada.1252 LC_NUMERIC=C
[5] LC_TIME=English_Canada.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] mlogit_0.1-4 statmod_1.4.3 Formula_0.2-0
Note that I'm using mlogit_0.1-4; I note from the change log
that there were major changes from version 0.1-2. That's probably
where the error has crept in.
I tried also with R version 2.10.1 Patched (2010-01-05 r50896).
Same result. So I suspect it's the version of mlogit.
I should have cc'd Yves; doing so now.
-Peter Ehlers
On 2010-03-07 11:30, David Winsemius wrote:
Looks like a problem that the maintainer should be copied with:
> maintainer("mlogit")
[1] "Yves Croissant <yves.croiss...@let.ish-lyon.cnrs.fr>"
Not sure why it should affect your systems and not mine, but here is my
sessionInfo() if it helps:
> sessionInfo()
R version 2.10.1 RC (2009-12-09 r50695)
x86_64-apple-darwin9.8.0
locale:
[1] en_US.UTF-8/en_US.UTF-8/C/C/en_US.UTF-8/en_US.UTF-8
attached base packages:
[1] splines stats graphics grDevices utils datasets methods
[8] base
other attached packages:
[1] mlogit_0.1-2 maxLik_0.6-0 mgcv_1.6-1 gdata_2.6.1
[5] Design_2.3-0 Hmisc_3.7-0 survival_2.35-7 chron_2.3-33
loaded via a namespace (and not attached):
[1] cluster_1.12.1 grid_2.10.1 gtools_2.6.1 lattice_0.17-26
[5] Matrix_0.999375-32 nlme_3.1-96 tools_2.10.1
On Mar 7, 2010, at 12:50 PM, Peter Ehlers wrote:
On 2010-03-07 10:30, David Winsemius wrote:
On Mar 7, 2010, at 12:06 PM, cmc wrote:
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,]
You do not get the same result as the example page, (while I do). You
need to see if you have other objects with names that may be confusing
the interpreter. I did not attach() mydata, which despite the UCLA's use
of it is considered bad practice in R programming because of frequent
obscure bugs that trip up newbies such as us. The errors do not occur
when the next commands are run.
I do get the same error (I didn't use attach() either), but I
can avoid the error if I don't call the mlogit.data() output
'mldata'. This seems to be a hardcoded name in mlogit() which
appears to cause the problem. This works:
mdata<-mlogit.data(mydata, varying=NULL, choice="brand", shape="wide")
mlogit.model<- mlogit(brand~1|female+age, data = mdata, reflevel="1")
-Peter Ehlers
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
--
David Winsemius, MD
West Hartford, CT
______________________________________________
R-help@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.
--
Peter Ehlers
University of Calgary
David Winsemius, MD
West Hartford, CT
--
Peter Ehlers
University of Calgary
______________________________________________
R-help@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.