Dear Eduardo,
I would not do this because it will be a pure extrapolation. Actually,
such an extrapolation is not possible with a factor variable because an
effect of the new level, which does not exist in the data set, will not be
estimated in the original model. So, I think there is a good reason why
zelig won't allow for this. If you still want to do such an extrapolation,
you would need to convert the factor variable to, say, a continuous
(numerical) variable so that linear or some other extrapolation can be
performed.
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 Wed, 26 Jul 2006, Eduardo Leoni wrote:
Hi -
when I use setx whith a factor that has extra levels not in the
dataset it gives "non-conformable arguments".
dta <-
data.frame(y=rnorm(10),x1=1:10,x2=factor(c(rep(1,3),rep(2,4),rep(3,3))))
z1 <- zelig(y~x1+x2,model="ls",data=dta)
v1 <- setx(z1)
s1 <- sim(z1,x=v1)
##this works
##now change data, coding factor 3 as 2
dta$x2[7:10] <- 2
z1 <- zelig(y~x1+x2,model="ls",data=dta)
v1 <- setx(z1)
Warning message:
There is more than one mode. The first level is selected. in: FUN(X[[1]],
...)
s1 <- sim(z1,x=v1)
Error in coef %*%
t(x) : non-conformable arguments
If this is indeed a bug, a possible solution is to set somewhere in
setx function
for (i in 1:ncol(dta)) {
vnow <- dta[,i]
dta[,i] <- vnow[drop=TRUE]
}
but may have unintended consequences that I am not aware of.
best,
-eduardo
-
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:
http://lists.gking.harvard.edu/?info=zelig
Zelig program information:
http://gking.harvard.edu/zelig/