Try setting as.factor(country) outside of the formula. that is,
mydata$country <- as.factor(mydata$country)
and then use the setx() in the usual way.
Kosuke
Department of Politics
Princeton University
http://imai.princeton.edu
On Sep 21, 2010, at 4:02 PM, Wu, Jun-Deh wrote:
Hi,
I got a problem when I use the "as.factor" and "setx" command.
Respondensts in the dataset I used come from 20 countries (coded as 1 to 20). I use
as.factor to generate country dummies and run a probit regression like this: p.out <-
zelig(y ~ x1 + x2 + as.factor(country), model="probit.survey", data=mydata,
weights=~weight, x=TRUE).
As a result, summary(p.out) returns coefficients of x1, x2, and 19 country dummies
labeled as as.factor(country)2, as.factor(country)3......as.factor(country)20.
When I use "setx" and "sim" commands to calculate first difference, I
need to set values for these country dummies. Supposed that a typical case is from country
3, I therefore need to set the dummy of country 3 = 1, else 0. However, I have difficulty
in setting these values.
When I do x.low <- setx(p.out, x1=1, x2=0, country=c(rep(0,2),1,rep(0,17))), x.high
<- setx(p.out, x1=1, x2=1, country=c(rep(0,2),1,rep(0,17))), they are fine. But fd
<- sim(p.out, x=x.low, x1=x.high) returns "Error in coef %*% t(x) :
non-conformable arguments"
I have tried different ways to set values for these country dummies. The only way that
sim command works is to do x.low <- setx(p.out, x1=1, x2=0, country=c(seq(1,20))),
x.low <- setx(p.out, x1=1, x2=1, country=c(seq(1,20))), and then do fd <- sim(p.out,
x=x.low, x1=x.high). This setting doesn't make sense, but it can make "sim"
run. However, When I run summary(fd), I found that all country dummies are set at 0.05.
How do I set values for these country dummies?
Thank you very much
Jun-deh Wu
Ph.D candidate
University of North Texas
-
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/