Dear authors,
I was messing with zelig (namely logistic regression) on a data set with
categorical covariates:
hisp = 0 or 1
coll = 0 or 1
inc = 1, 2 or 3
I get the following error with the setx() step:
> z1 <- zelig(grad ~ factor(hisp) + factor(coll) + factor(inc), model="logit",
data=hsgrad)
>
> x1 <- setx(z1, coll=0)
Error in "contrasts<-"(`*tmp*`, value = "contr.treatment") :
contrasts can be applied only to factors with 2 or more levels
I tried
> x1 <- setx(z1, factor(coll)=0)
Error in "contrasts<-"(`*tmp*`, value = "contr.treatment") :
contrasts can be applied only to factors with 2 or more levels
and got the same error. However, when I make the variables into factors
within the dataframe, things work:
> hsgrad$f1 = factor(hsgrad$coll)
> hsgrad$f2 = factor(hsgrad$hisp)
> hsgrad$f3 = factor(hsgrad$inc)
>
> z1 <- zelig(grad ~ f1+f2+f3, model="logit", data=hsgrad)
> x1 <- setx(z1, f1=1)
> s1 <- sim(z1,x1)
Was wondering whether this step is always necessary when dealing with
categorical covariates or is there an easier way to setx() and do things like
the above?
Thanks!
Vinh
-
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,
We've just released a new version of Zelig with some bug fixes in
setx, and for the multinomial logit model. This version is currently
available both from CRAN and from Gary's website, and is compatible
with the current R release (2.3.1, not 2.4.0 alpha). Please let us
know as you use Zelig, and find more bugs.
Best,
Olivia
-
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/