Dear Phil,
Can you send the Zelig version number? At the R prompt, type
packageDescription("Zelig")
Yours,
Olivia
On 7/24/07, Phil Jones <pjones(a)fas.harvard.edu> wrote:
Hi all,
I'm having some problems getting setx() to work on a regression model
that has a factor as an independent variable and uses 5 multiply imputed
datasets. As you can see from the length of this email (apologies), I've
tried a number of solutions this morning but can't seem to fix the problem.
The basic model is:
z.out <-
zelig(pba.correct~age+as.factor(r.race),
model="poisson",
data=mi(mi1, mi2, mi3, mi4, mi5))
where "pba.correct" is a count of the number of questions a survey
respondent correctly answered, "age" is a continuous variable, and
"r.race" is a factor that describes the survey respondent's race. mi1
through mi5 are multiply imputed datasets with no missing data.
This code runs without problem, and summary(z.out) produces everything
I've come to know and love from zelig. The problem comes with:
x.out <- setx(z.out)
Error in
`contrasts<-`(`*tmp*`, value = "contr.treatment") :
contrasts can be applied only to factors with 2 or more levels
This error message seems to be the same as the one Vinh describes here:
http://lists.hmdc.harvard.edu/lists/zelig/2006_09/msg00004.html
But the solution that worked there -- to make sure that the categorical
variable is correctly specified as a factor -- doesn't seem to work for
me. "r.race" is defined as a factor, with 8 levels, and no missing data,
outside of the zelig() command.
In fact, the problem seems to be very specific to using a categorical
variable and the multiply imputed datasets. I ran the same model on just
one of the datasets, as below:
z.out <- zelig(pba.correct~age+r.race,
model="poisson",
data=mi1)
and setx() works perfectly normally. Likewise, I tried omitting the
factor and using all of the multiply imputed datasets:
z.out <- zelig(pba.correct~age,
model="poisson",
data=mi(mi1, mi2, mi3, mi4, mi5))
and that again works fine. The problem is also not one of model choice
(trying "negbin", "ologit" or even "ls" still led me to the
error
message). I've tried everything I can think of and am stuck! If anyone
can think of a possible solution, I'd really appreciate your help.
Thanks, Phil
--
Ph.D. Candidate
Harvard University Department of Government
1737 Cambridge Street, Cambridge, MA 02138
-
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: