Try converting the variable into a factor before using it in the formula and see if the
problem goes away.
Best,
Kosuke
Department of Politics
Princeton University
Hi Professor Imai,
I'm having a problem with the Zelig package that I was hoping you might be able to
help with. I'm running a logit model on panel data with country fixed-effects (using
as.factor(ccode) for the fixed effects). Everything works fine until I do
"setx()"; when I do that, I get the following error message: "Error in
`contrasts<-`(`*tmp*`, value = contr.funs[1 + isOF[nn]]) : contrasts can be applied
only to factors with 2 or more levels". The R code is below.
When I run the model without "as.factor(ccode)", everything works fine, so I
think it has something to do with that. James Honaker suggested that I try installing the
latest version of Zelig (3.5.3), but even after doing that, I still have the same problem.
Do you have any idea what I can do to fix this? Thanks very much, I appreciate your
help.
Best,
Andrew Boutton
z.out <- zelig(fail4 ~ ln_totaidpct_1 +
rivalXtotaidpc + rivalryt_1 + ln_gdpt_1 + democt_1 + numgroups + ter + rc + t + t2 + t3 +
as.factor(ccode), model = "logit", +data = data)
ln_totaidpct_1.range<--8:8
xc.range<- setx(z.out, ln_totaidpct_1=ln_totaidpct_1.range,
rivalXtotpc=ln_totaidpct_1.range, rivalryt_1=1)
Error in `contrasts<-`(`*tmp*`,
value = contr.funs[1 + isOF[nn]]) : contrasts can be applied only to factors with 2 or
more levels
--
Andrew Boutton
Graduate Assistant
Peace Science Society International
Department of Political Science
The Pennsylvania State University
207 Pond Laboratory
University Park, PA 16802
atb171(a)psu.edu