auth 6ef9d23c0a91e16c subscribe zelig_at_lists_gking_harvard_edu falimadhi(a)iq.harvard.edu
-
Zelig Mailing List, served by Harvard-MIT Data Center
Send messages: zelig(a)lists.gking.harvard.edu
[un]subscribe Options: http://lists.gking.harvard.edu/?info=zelig
Zelig program information: http://gking.harvard.edu/zelig/
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: http://lists.gking.harvard.edu/?info=zelig
Zelig program information: http://gking.harvard.edu/zelig/
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
Hi Xavier,
We reply on package "sandwich" for these functionalities in logit and
other glm models. It appears to me that they currently do not have a
clustering option although it might be possible to tweak some of their
options to do it. You can ask the author of the package to see if that is
possible. If it is possible, then you can supply any options in zelig()
via for example:
list(method="vcovHAC", order.by=hoff$year, adjust=TRUE)
Kosuke
On Fri, 1 Jun 2007, Xavier [utf-8] Fernández i Marín wrote:
> On dj, 31 mai 2007, Kosuke Imai wrote:
>
>> Actually, robust standard errors for logit and some other models (glm
>> family) are available. The basic option is robust=TRUE, but there are
>> other options as well.
>> http://gking.harvard.edu/zelig/docs/Additional_Inputs7.html
>>
>> also see demo(robust)
>
> Dear Kosuke,
>
> Thank you for your answer. Maybe I wasn't clear enough in my previous
> message. My main concern was not about the 'robust' option, but the
> 'cluster' option. I have used the 'robust' option in the models, but what
> I'm interested on is in the clusters.
>
> And for the answer in the mailing list I can see that the 'cluster' option
> is not implemented in the "logit" family (or it wasn't in october 2006).
> Hence, my question was whether it was planned to add this feature in the
> future.
>
>
> (BTW, thank you for your contribution in the MNP package! which I use a
> lot)
>
> Best regards,
>
>>
>> Kosuke
>>
>> -----------------------------------------------------
>> Kosuke Imai Office: Corwin Hall 041
>> Assistant Professor Phone: 609-258-6601
>> Department of Politics eFax: 973-556-1929
>> Princeton University Email: kimai(a)Princeton.Edu
>> Princeton, NJ 08544-1012 http://imai.princeton.edu
>> -----------------------------------------------------
>>
>> On Thu, 31 May 2007, Olivia Lau wrote:
>>
>>> Dear Xavier,
>>>
>>> I'm actually not in charge of robust standard errors; I am cc'ing my
>>> coauthor Kosuke who implemented them.
>>>
>>> Best,
>>> Olivia Lau
>>>
>>> On 5/31/07, Xavier Fernández i Marín <xavier.fernandez(a)upf.edu> wrote:
>>>> Hello Olivia,
>>>>
>>>> I've been an R user for long time and I'm starting to discover Zelig and
>>>> its abilities.
>>>>
>>>> I have tried to build a logit model with robust errors and clusters for
>>>> one
>>>> variable, but according to the mailing list this feature hasn't been (yet)
>>>> released (or it wasn't in october 2006):
>>>> http://lists.hmdc.harvard.edu/lists/zelig/2006_10/msg00001.html
>>>>
>>>> My question is about the availability of this feature. Is it on the list
>>>> of
>>>> features to include? Any idea about the possible periodicity? The
>>>> questions
>>>> are just to have an idea and whether I would have to wait or program it
>>>> for
>>>> myself. So in any case it pretends to be a "demand".
>>>>
>>>> Since from the mailing list you seemed to be the programmer dedicated to
>>>> this functions I have sent the email directly to you.
>>>>
>>>>
>>>> Thank you very much for all your work.
>>>>
>>>>
>>>> Best regards,
>>>>
>>>> --
>>>> Xavier Fernández i Marín
>>>>
>>>> xavier.fernandez(a)upf.edu
>>>> http://giptsi.upf.edu/xavier/
>>>>
>>>>
>>>
>
>
>