Thanks for the bug report. Not sure what's going on here since adding
as.factor(country) to demo(ls) seems to work fine. We'll have a look.
For the meantime, please convert a variable to a factor outside of the
zelig() call via:
data$x <- as.factor(data$x)
Thanks,
Kosuke
--
Department of Politics
Princeton University
Hello all,
setx() appears not to be working when a categorical variable is specified
using as.factor() in the model. From the list archives, it seems that this
was a bug in older versions of Zelig and was fixed in 3.0, but perhaps it is
back. A reproducible example is below:
y <- rnorm(100)
x <- sample(c(1, 2, 3), 100, replace=TRUE)
data <- as.data.frame(cbind(y, x))
model1 <- zelig(y ~ x, model="ls", data=data)
How to cite this model
in Zelig:
Kosuke Imai, Gary King, and Oliva Lau. 2007. "ls: Least Squares Regression
for Continuous Dependent Variables" in Kosuke Imai, Gary King, and Olivia
Lau, "Zelig: Everyone's Statistical Software,"
http://gking.harvard.edu/zelig
stx1 <- setx(model1)
stx1
(Intercept) x
1 1 2.14
model2 <- zelig(y ~ as.factor(x),
model="ls", data=data)
How to cite this model in Zelig:
Kosuke Imai, Gary King, and Oliva Lau. 2007. "ls: Least Squares Regression
for Continuous Dependent Variables" in Kosuke Imai, Gary King, and Olivia
Lau, "Zelig: Everyone's Statistical Software,"
http://gking.harvard.edu/zelig
stx2 <- setx(model2)
Error in
`contrasts<-`(`*tmp*`, value = "contr.treatment") :
contrasts can be applied only to factors with 2 or more levels
packageDescription("Zelig")
Package: Zelig
Version: 3.4-7
Date: 2009-10-23
Title: Everyone's Statistical Software
Author: Kosuke Imai <kimai(a)Princeton.Edu>du>, Gary King
<king(a)harvard.edu>du>, Olivia Lau <olivia.lau(a)post.harvard.edu>
Maintainer: Kosuke Imai <kimai(a)Princeton.Edu>
Depends: R (>= 2.6.0), MASS, boot
Description: Zelig is an easy-to-use program that can estimate, and
help interpret the results of, an enormous range of statistical
models. It literally is ``everyone's statistical software''
because Zelig's simple unified framework incorporates everyone
else's (R) code. We also hope it will become ``everyone's
statistical software'' for applications and teaching, and so
have designed Zelig so that anyone can easily use it or add
their programs to it. Zelig also comes with infrastructure
that facilitates the use of any existing method, such as by
allowing multiply imputed data for any model, and mimicking the
program Clarify (for Stata) that takes the raw output of
existing statistical procedures and translates them into
quantities of direct interest.
License: GPL (>=2)
URL:
http://gking.harvard.edu/zelig
Suggests: VGAM (>= 0.7-5), MCMCpack (>= 0.8-2), mvtnorm, survival,
sandwich (>= 2.1-0), zoo (>= 1.5-0), coda, nnet, sna, gee,
systemfit, mgcv, lme4, anchors (>= 2.0), survey
Packaged: 2009-10-23 16:29:00 UTC; rbuild
Built: R 2.10.0; ; 2009-12-20 19:06:41 UTC; unix
-
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/
-
Zelig Mailing List, served by Harvard-MIT Data Center
Send messages: zelig(a)lists.gking.harvard.edu
[un]subscribe Options: