[R] mlogit is not an S4 object error

Achim Zeileis Achim.Zeileis at uibk.ac.at
Wed Feb 24 22:20:28 CET 2010


On Wed, 24 Feb 2010, Steve_Friedman at nps.gov wrote:

>
> Hello,
>
> I've been getting the following error  when using the mlogit function from
> the mlogit package
>
> This is one of the examples provided in the Package "mlogit" January 27,
> 2010 description
>
> data("Fishing", package="mlogit")
> Fish <- mlogit.data(Fishing, varying = c(4:11), shape="wide",
> choice="mode")
> summary(mlogit(mode ~ pr + ca - 1, data = Fish))
>
>
> Call:
> Error in deparse(object at call) :
>  trying to get slot "call" from an object (class "mlogit") that is not an
> S4 object
>
> I'm running on Windows XP  R 2.10.1
>
> Does anyone have any ideas why this is failing ?

I cannot replicate this problem. I get the desired result (see below). 
This is also unlikely to be a problem in the package itself because the 
examples are checked daily on CRAN, see
   http://CRAN.R-project.org/web/checks/check_results_mlogit.html

My guess is that you have loaded some other package (other than "mlogit") 
that defines an S4 generic for summary() that somehow messes up the 
dispatch for mlogit. Please try to reinstall the package and run the 
package in a fresh R session to check whether the problem persists.

Best,
Z


R> library("mlogit")
Loading required package: Formula
Loading required package: statmod
R> data("Fishing", package="mlogit")
R>  Fish <- mlogit.data(Fishing, varying = c(4:11), shape="wide",
+  choice="mode")
R>  summary(mlogit(mode ~ pr + ca - 1, data = Fish))

Call:
mlogit(formula = mode ~ pr + ca - 1, data = Fish, method = "nr",
     print.level = 0)

Frequencies of alternatives:
   beach    boat charter    pier
0.11337 0.35364 0.38240 0.15059

nr method
6 iterations, 0h:0m:0s
g'(-H)^-1g = 7.22E-11
optimum reached

Coefficients :
      Estimate Std. Error t-value  Pr(>|t|)
pr -0.0204765  0.0012231 -16.742 < 2.2e-16 ***
ca  0.9530985  0.0894134  10.659 < 2.2e-16 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Log-Likelihood: -1312



> Thanks
> Steve
>
> Steve Friedman Ph. D.
> Spatial Statistical Analyst
> Everglades and Dry Tortugas National Park
> 950 N Krome Ave (3rd Floor)
> Homestead, Florida 33034
>
> Steve_Friedman at nps.gov
> Office (305) 224 - 4282
> Fax     (305) 224 - 4147
>
> ______________________________________________
> 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