Dear Dan,
Good question, I'm forwarding it to the list as well, in case others
have the same problem.
R has two broad types of objects, S3 and S4 objects. In order to get
multiple imputation working for the S4 objects, we've had to make some
changes in the more recent versions of Zelig (2.8-3 and up). These
changes only apply to the output from zelig() itself, and do not
affect setx and sim (or rather, fixed setx and sim). An overview:
Most models in zelig produce S3 objects, which are lists. You can use
names() to see what's in an S3 object, and $ or [[...]] to extract
individual elements from the S3 object, and you can add things to an
S3 object just by doing s3object$newelement <- stuff, for example.
The output from blogit, bprobit, and mlogit are S4 objects. S4
objects have formally-defined "slots" and you can't add anything to an
S4 object; you can replace an existing slot only if whatever you're
putting into the slot "fits" as it were. To see what's in an S4
object, use slotNames(object), and to extract individual elements, use
@ (just as you would use $ for an S3 list).
I know this may be confusing -- so I suggest that if you want to see
the coefficients for example, just use coef(z.out). This will work
for every Zelig model, whether S3 or S4 output, and as you've already
pointed out, summary(z.out) works for all zelig output as well.
I hope this helps, and please let me know if you have any further
questions. Yours,
Olivia
On 6/5/07, B. Dan Wood <bdanwood(a)polisci.tamu.edu> wrote:
Olivia,
Thanks. That helps.
What about the names(model.out) part of the question? Is this inoperative in
mlogit?
Dan
B. Dan Wood
Professor
Department of Political Science
Texas A&M University
4348 TAMU
College Station, TX 77843-4348
Office Phone: 979-845-1610
Office FAX: 979-847-8924
Web:
http://www-polisci.tamu.edu/bdanwood
Email: bdanwood(a)polisci.tamu.edu
-----Original Message-----
From: monkeykupo(a)gmail.com [mailto:monkeykupo@gmail.com] On Behalf Of Olivia
Lau
Sent: Tuesday, June 05, 2007 2:38 PM
To: B. Dan Wood
Cc: zelig(a)lists.gking.harvard.edu
Subject: Re: [zelig] mlogit outputs
Dear Dan,
mlogit output is of the S4 class, use @ where you would use $.
Yours, Olivia
On 6/5/07, B. Dan Wood <bdanwood(a)polisci.tamu.edu> wrote:
The "names(model.out)" syntax does not seem to be working for the mlogit
procedure as it does for the other procedures. Also, the normal syntax
given
on your website for calling particular outputs
(model.out$output) does not
seem to work. However, an alternative syntax does work
(output(model.out)).
For example here is some output that shows the
difficulties.
library(Zelig)
mlogit.out <- zelig(as.factor(LETTERS) ~ GPA +
TUCE + PSI, model =
"mlogit", data = Spector)
There were 22 warnings (use warnings() to see them)
summary(mlogit.out)
Call:
zelig(formula = as.factor(LETTERS) ~ GPA + TUCE + PSI, model = "mlogit",
data = Spector)
Pearson Residuals:
Min 1Q Median 3Q Max
log(mu[,1]/mu[,3]) -0.61 -0.0012 -2.9e-07 1.9e-08 2.3
log(mu[,2]/mu[,3]) -1.67 -0.5765 -2.3e-01 6.6e-01 2.7
Coefficients:
Value Std. Error t value
(Intercept):1 53.007 30.26 1.752
(Intercept):2 5.746 3.66 1.570
GPA:1 -21.779 11.75 -1.853
GPA:2 -1.241 1.07 -1.160
TUCE:1 0.449 0.49 0.922
TUCE:2 -0.036 0.13 -0.283
PSI:1 -31.341 660.80 -0.047
PSI:2 -2.478 0.98 -2.537
Number of linear predictors: 2
Names of linear predictors: log(mu[,1]/mu[,3]), log(mu[,2]/mu[,3])
Dispersion Parameter for multinomial family: 1
Residual Deviance: 36.39 on 56 degrees of freedom
Log-likelihood: -18.19 on 56 degrees of freedom
Number of Iterations: 16
names(mlogit.out)
NULL
# Model Coefficients
beta <-coefficients(mlogit.out)
beta
(Intercept):1 (Intercept):2 GPA:1 GPA:2 TUCE:1
53.00740 5.74626 -21.77885 -1.24076 0.44857
TUCE:2 PSI:1 PSI:2
-0.03565 -31.34106 -2.47849
beta <- mlogit.out$coefficients
Warning message:
$ operator not defined for this S4 class, returning NULL in:
mlogit.out$coefficients
B. Dan Wood
Professor
Department of Political Science
Texas A&M University
4348 TAMU
College Station, TX 77843-4348
Office Phone: 979-845-1610
Office FAX: 979-847-8924
Web:
http://www-polisci.tamu.edu/bdanwood
Email: bdanwood(a)polisci.tamu.edu
-
Zelig Mailing List, served by Harvard-MIT Data Center
Send messages: zelig(a)lists.gking.harvard.edu
[un]subscribe Options: