Do you have the latest version of Zelig? It works for me:
setx(z.out1, age = 20)
(Intercept) age
as.factor(race)white
1 1 20 1
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, 15 May 2008, Andrew Stokes wrote:
Hello,
When I run a regression using as.factor to create indicator variables from
categorical variables, the subsequent simulation steps using setx and sim do
not work. When I run the regression where the indicator variables were
created beforehand, the simulation steps work. So for example, I run
z.out<-zelig(severe_anemic ~ net_status + anc_visit + as.factor(age) +
as.factor(wealth) + as.factor(region), model = "logit", data = my.data)
And then I run:
x.out0<-setx(z.out, net_status = 0)
x.out1<-setx(z.out, net_stutus = 1)
s.out<-sim(z.out, x=x.out0, x1=x.out1, num=1000)
After each of the preceding lines, I receive this error:
Error in `contrasts<-`(`*tmp*`, value = "contr.treatment") :
contrasts can be applied only to factors with 2 or more levels
Thanks for any advice!
Andrew Stokes
Institute for Health Metrics and Evaluation
-
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/