Kusuke and Gary,
As I've been testing out past programs for my upcoming class, I've found
another possible bug in Zelig.
The following worked fine under R 2.1.1. However, it does not work under R
2.3.1.
Here are the commands and output. I can provide the data if you need it.
> ShipAccidents <- read.table("C:/Documents and Settings/B. Dan Wood/My
Documents/My Teaching/Maximum Likelihood/Data/ShipAccidents.txt",
+ header=TRUE, na.strings=".")
> attach(ShipAccidents)
>
> # Let's go ahead and remove the missing values from the dataset.
> detach(ShipAccidents)
> ShipAccidents <- na.omit(ShipAccidents)
> attach(ShipAccidents)
>
> ShipAccidents$Logmonths <- log(Months)
> detach(ShipAccidents)
> attach(ShipAccidents)
>
> library(Zelig)
Loading required package: boot
Attaching package: 'boot'
The following object(s) are masked _by_ .GlobalEnv :
logit
The following object(s) are masked from package:car :
logit
##
## Zelig (Version 2.6-3, built: 2006-06-19)
## Please refer to http://gking.harvard.edu/zelig for full documentation
## or help.zelig() for help with commands and models supported by Zelig.
##
Attaching package: 'Zelig'
The following object(s) are masked _by_ .GlobalEnv :
sim
> poisson.out <- zelig(Acc ~ TB + TC + TD + TE + T6569+ T7074 + T7579 +
O7579 + Logmonths,
+ model = "poisson", data = ShipAccidents)
> summary(poisson.out)
Call:
zelig(formula = Acc ~ TB + TC + TD + TE + T6569 + T7074 + T7579 +
O7579 + Logmonths, model = "poisson", data = ShipAccidents)
Deviance Residuals:
Min 1Q Median 3Q Max
-1.657 -0.887 -0.484 0.479 2.744
Coefficients:
Estimate Std. Error z value Pr(>|z|)
(Intercept) -5.619 0.874 -6.43 1.3e-10 ***
TB -0.359 0.270 -1.33 0.1836
TC -0.762 0.338 -2.25 0.0243 *
TD -0.131 0.297 -0.44 0.6582
TE 0.270 0.242 1.11 0.2649
T6569 0.662 0.154 4.30 1.7e-05 ***
T7074 0.760 0.178 4.27 2.0e-05 ***
T7579 0.361 0.247 1.46 0.1438
O7579 0.370 0.118 3.13 0.0018 **
Logmonths 0.906 0.102 8.91 < 2e-16 ***
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
(Dispersion parameter for poisson family taken to be 1)
Null deviance: 614.539 on 33 degrees of freedom
Residual deviance: 38.132 on 24 degrees of freedom
AIC: 156
Number of Fisher Scoring iterations: 5
>
> means.out <- setx(poisson.out)
> means.out
(Intercept) TB TC TD TE T6569 T7074 T7579 O7579
Logmonths
1 1 0.2059 0.2059 0.2059 0.1765 0.2941 0.2941 0.1765 0.5882
7.049
>
> fitted.out <- sim(poisson.out, x = means.out)
Error in sim(poisson.out, x = means.out) :
unused argument(s) (x ...)
> summary(fitted.out)
Error in summary(fitted.out) : object "fitted.out" not found
>
> Logmonths.low <- setx(poisson.out, Logmonths = mean(Logmonths))
> Logmonths.high <- setx(poisson.out, Logmonths = mean(Logmonths) +
sd(Logmonths))
> fd.Logmonth <- sim(poisson.out, x = Logmonths.low, x1 = Logmonths.high)
Error in sim(poisson.out, x = Logmonths.low, x1 = Logmonths.high) :
unused argument(s) (x ...)
> summary(fd.Logmonth)
Error in summary(fd.Logmonth) : object "fd.Logmonth" not found
>
>
Best,
Dan
B. Dan Wood
Professor and University Faculty Fellow
Department of Political Science
Texas A&M University
4348 TAMUS
College Station, TX 77843-4348
Phone Numbers
Office: 979-845-1610
Home: 979-690-0390
Cell: 979-204-9147
FAX: 979-847-8924
Email: bdanwood(a)polisci.tamu.edu
Homepage: http://www-polisci.tamu.edu/faculty/wood/
I'm teaching MLE with R 2.3.1 using Zelig. I've updated both Zelig and VGAM
to the current version of R.
I have a set of commands that worked fine under R 2.1.1 with Zelig to
estimate a multinomial logit.
They are as follows:
Spector <- read.table("c:/Data/Letters.txt", header=TRUE)
attach(Spector)
summary(Spector)
library(Zelig)
mlogit.out <- zelig(LETTERS ~ GPA + TUCE + PSI, model = "mlogit", data =
Spector)
summary(mlogit.out)
Here's the output:
> library(Zelig)
Loading required package: MASS
Loading required package: boot
##
## Zelig (Version 2.6-3, built: 2006-06-19)
## Please refer to http://gking.harvard.edu/zelig for full documentation
## or help.zelig() for help with commands and models supported by Zelig.
##
> mlogit.out <- zelig(LETTERS ~ GPA + TUCE + PSI, model = "mlogit", data =
Spector)
Loading required package: VGAM
Loading required package: splines
Loading required package: stats4
Creating a new generic function for 'print' in 'VGAM'
Creating a new generic function for 'coefficients' in 'VGAM'
Creating a new generic function for 'fitted.values' in 'VGAM'
Attaching package: 'VGAM'
The following object(s) are masked from package:splines :
bs ns
The following object(s) are masked from package:boot :
logit simplex
The following object(s) are masked from package:stats :
poly
The following object(s) are masked from package:base :
scale.default
Error in lm2vlm.model.matrix(x, Blist, xij = control$xij) :
length of 'dimnames' [1] not equal to array extent
> summary(mlogit.out)
Error: object "mlogit.out" not found
Error in summary(mlogit.out) : unable to find the argument 'object' in
selecting a method for function 'summary'
>
>
Has anyone seen this before?
Thanks,
Dan
B. Dan Wood
Professor and University Faculty Fellow
Department of Political Science
Texas A&M University
4348 TAMUS
College Station, TX 77843-4348
Phone Numbers
Office: 979-845-1610
Home: 979-690-0390
Cell: 979-204-9147
FAX: 979-847-8924
Email: bdanwood(a)polisci.tamu.edu
Homepage: http://www-polisci.tamu.edu/faculty/wood/
I get the following error when I call the summary() method of the
result of a multiply-imputed zelig model with model='mlogit' (with 5
imputations):
> post92 <- as.factor(presvote) ~ (variables...)
> z.mod92 <- zelig(post92, model='mlogit', data=midata)
> summary(z.mod92)
Error in array("", c(n, 3), list(names(object), c("Length", "Class", "Mode"))):
length of 'dimnames' [1] not equal to array extent
I can extract each of the imputation results from the object to see
the coefficients for each of the 5 imputed data sets (although summary
doesn't work right on each of those either).
I can summarize models run on each of the imputed data sets separately.
I can also summarize multiply imputed models with other methods like
probit without trouble.
I also tried to use 'mlogit.bayes' to estimate the model, and got a
different error message:
> summary(z.mod92)
Error in apply(coef, 1, mean) : dim(X) must have a positive length
I'm using Zelig 2.6-3. Thanks in advance, and let me know if you need
any additional information.
Chris
--
Christopher N. Lawrence <clawren6(a)slu.edu>
Assistant Professor of Political Science, Saint Louis University
109 Fitzgerald Hall
3500 Lindell Boulevard
St. Louis, Missouri 63103-1021
-
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 Murthy,
If you would like to use the informative prior, you can approximate the
posterior of the previous year using the normal distribution (e.g.,
compute the sample mean and variance of the posterior and use them as the
parameters of the normal prior).
Hope this helps,
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 Tue, 8 Aug 2006, Murthy Mittinty wrote:
> Dear Prof Kosuke,
>
> Myself Murthy.N.Mittinty. I am currently working at NIWA in New Zealand. For
> one of my projects I am using the Zelig package that you had developed in R.
> In this I am making use of logit.bayes and mlogit.bayes models.
> I had gone through the webpage examples given in Gary king's web page and
> used the same syntax and could get results. I am happy till this aspect.
>
> But I have a question on the prior and supplying the prior, the current
> program uses as flat prior which follows Normal distribution with mean b and
> variance B (Var-cov) computed from the data. Since my work needs to take the
> posterior of the previous year as the prior for predicting next year
> proportion of fish in a catch, how can I supply this information to the
> current program? Is there a way for used to define priors?
>
> I will be thankful to you for your advise help and suggestions on this
> aspect.
>
> Thanks for your help and time.
>
> Sincerely,
> Murthy.N. Mittinty
>
>
-
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/
On 7/31/06, Eduardo Leoni <eleoni(a)hmdc.harvard.edu> wrote:
> "Y1, Y2, and Y3: Y1 contains the items for subject ``Y1'', Y2 contains the
> items for subject ``Y2'', and so on"
>
> are you sure variables are in the columns?
I assume so. Just to be clear, I have about 30 variables and
about 1,200 cases, so I should have cbind(Y1, Y2, Y3, ... , Y1199,
Y1200) in the call, right?
> anyway, just using MCMCpack might
> currently a better option.
>
> library(MCMCpack)
> posterior<-MCMCirt1d(vars)
> summary(posterior)
That certainly does seem easier, since cbind(names(m)) gives me an
error, and I really don't want to hand-code all 1200 case ids in the
call to the IRT model. But it looks like MCMCirt1d requires a matrix,
and further states:
The matrix of data. Must be 0, 1, or missing values. The
rows of 'datamatrix' correspond to subjects and the columns
correspond to items.
That's not what I've got, which is a bunch of variables scaled
from 0 to 1. Is that a problem, or does this model only work on
binary data?
-- Chris
-
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/
Hi all --
I'm following the instructions in trying to run a 1-dimensional IRT
model from some NES data. It's pretty simple, I've got a data.frame
that has the respondents in rows and the variables in columns. But,
the IRT model requires subjects in columns, so I first do:
m = as.data.frame(t(vars));
... this gives me a new data.frame, with respondents in columns and
the variables in rows. I should, I think, be able to run the model
like so:
z.out <- zelig(m ~ NULL, model = "irt1d", data = m);
... but I get an error:
Error in model.frame(formula, rownames, variables, varnames, extras,
extranames, :
invalid variable type for 'm'
All of the variables are numeric, with scattered "NA"s. I'm not sure
why I get the error, and I'm also curious why the "data" argument is
manditory, since I'm not referencing any variables that aren't in the
global namespace already.
Can anyone enlighten me?
-- Chris
-
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/